Explore using the standard "Getting Started" tutorial resources provided by Amazon, a simple application will be created within the Lambda console. This code will be created and executed completely within the console. We will make some changes to the example to better understand how this interface gives you the ability to work with Lambda.
- [Instructor] For our first Lamda exercise we'll be creating a function which will be triggered whenever a new file is created in one S3 bucket copying that file over to the backup bucket. To get to the Lamda dashboard, click services and then under compute, click Lamda. Click get started now to get started with our first exercise. The next page provides a selection of blueprints to get you started. Take a moment to review these blueprints as it will give you an idea of the sorts of functions you can create and how they would be managed by Lamda code.
We're going to be working with Python for this course, so select the Python 2.7 runtime. To find the right blueprint, type S3 in the filter window and you'll get the S3 get object Python blueprint. This function will retrieve an object from an S3 bucket and we'll start with this code and edit it to copy the files between the S3 buckets. Click on the box to get started. Under configure triggers, you're able to configure interactions between your Lamda function and other AWS services.
In this case, we'll be interacting with S3, which is what is selected here. Under bucket make sure that your main non-backup bucket is selected. Under event type, choose object created all. This will trigger whenever any object is created in the specified bucket. Click enable trigger to get it all set up and then next to get to the verification screen. Your function needs a name. I'm going to call mine backup files. This name is used to organize your Lamda functions in the dashboard, so pick something you'll remember when you see it in the list later.
Let's update the description to be more appropriate to what we're doing. Function to copy files from one S3 bucket to backup S3 bucket. The Python 2.7 runtime is already selected, so scroll down. Under code entry type, we're going to edit the code inline here in the console. Although in the next chapter we'll be working with the code locally and uploading to the system.
The next section allows you to set environment variables for your function so you can modify the behavior of your function without changing the code. Next comes the roles and permissions. Here, the blueprint assumes the function only needs S3 read only permissions, but that won't work for our use case. We want to copy the file into another bucket, which is a write operation. Fortunately, during setup we created the necessary role and we can select that here. So, select an existing role, existing role S3 Lamda.
Advanced settings allows you to set scalability and other performance features for Lamda, but we don't need them here, so click next to continue. Check to make sure all the settings look correct to you, then click create function and we're ready to test it out.
- Working with the Lambda console
- Creating a Lambda function
- Exploring the Lambda console
- Lambda CloudWatch and monitoring
- Lambda application development
- Creating a Lambda API
- API framework setup
- Setting up API integration for READ
- Testing the API with HTTPie or cURL