Lambda Functions
- Lambda by Amazon Web Services (AWS) is an analogous serverless solution.
- Lambda can be used internall as well as for model deployments (we are focusing on the latter).
- We will repeat setting up the weather app and the recommender model, using the CLI (command line interface tools)
Aside: Setting up an IAM user
Hello World in Lambda
- Select the lambda service.
- Pick the python 3.7 runtime.
- You will see the green bar indicating a successful creation.
- We will initially not changed the code.
- The result looks like this.
Setting up an API Gateway
- We will slightly change the function so that it forms a proper HTTP response.
- Under the Designer section, we will ‘Add Trigger’ and select ‘API Gateway’.
- We choose HTTP API and security to be open for the time being.
- A block will appear on the designer tab in the Lambda function page.
- Once you click on the API Gateway link provided, you will see the response as expected:
See this documentation for more details.
Set up a Programmatic User to Access S3
What is IAM? IAM (Identity and Access Management) is a very useful tool for an organization to administer and control access to various resources.
- We will create a programmatic user, similar to the service account in GCP.
What is S3? S3 (Simple Storage Service) is a very popular service used by many large and small companies and individuals.
- For example, a typical data science work flow may involve ETL work on databases (such as Amazon Redshift) and then storing outputs on S3.
Start with finding the IAM service.
- Click on create a new user.
- We will make this user have programmatic access (for example via Python later on).
- For now, we let the user have full read and write access to S3.
- Lets review the user setup.
- In this step, copy the access key and secret key that will be needed for the programmatic access. They will not be shown again, so store them safely and securely.
- Here is the description of the user we just created.
Set up AWS CLI
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
- Head over to https://aws.amazon.com/cli/ and download a suitable installer for your OS.
Install it and open your terminal. If it is in the PATH, you should be able to verify the following:
which aws
#/usr/local/bin/aws #your location could be different.
aws --version
#aws-cli/2.0.45 Python/3.7.4 Darwin/18.6.0 exe/x86_64
Using the access and secret keys to configure aws using the aws configure
command.
Test S3 access by issing the following commmand: aws s3 ls
$ aws s3 ls
2020-09-03 12:27:48 chicagodatascience-com
2020-09-03 12:02:25 theja-model-store
Instead of programmatically creating a bucket (with the aws s3 mb s3://bucket-name
) we will do it using the GUI below.