Setting Up The Serverless Lambda Framework Within AWS

Setting Up The Serverless Lambda Framework Within AWS

Serverless Lambda - I’m sure you’ve heard all about it and are keen to get coding some serverless functions, but before we get started, we need to configure AWS to allow us to create and deploy Serverless projects, so today we’re going to cover getting setup with Serverless in AWS!

Create a new AWS account, and then log in to the AWS Management Console. Once you’re in AWS, search for “IAM” (Identity Access Management) within the services search bar.

Under “IAM”, select Users.

Within Users, select “Add User”.

Create a new user by providing a username, and ensuring you select to add “Programmatic Access” (this allows Serverless to work with AWS via the relevant SDK’s and CLI Tools).

Next choose “Permissions”. Within Permissions, we are going to attach an existing policy directly to our user account. The permission to select in this case is “AdministratorAccess” (which will allow Serverless to carry out whichever tasks it needs to, includng creating AWS Lambdas, S3 Buckets etc.)

Continue to the “Tags” page. We don’t need to set anything up in here to make Serverless work, so let’s continue to the “Review” page.

On the Review page, you will see that we now have a Serverless IAM user account, that has programmatic access and AdministratorAccess, so let’s create our user.

Now that our user has been created, we can see that we have an “Access Key ID” and a “Secret Access Key”.

The next step is to copy these values and navigate to a Terminal window. Once inside Terminal, we need to firstly install Serverless using the following command (be sure to use -g, in order to install serverless globally on your system).

Now that Serverless is successfully installed locally, we can setup our credentials, to allow Serverless to work on our AWS account.

Use the following command to apply our AWS credentials to our Serverless installation, which includes the Access Key ID and Secret Access Key from the newly created IAM User in AWS. You will also note that we add a “profile” configuration to the command, which allows us to apply a descriptive name to our Serverless Profile.

Serverless is applying our AWS credentials…

Now that Serverless is setup with our AWS credentials, we can use template commands to generate code and begin building Serverless software. A template that I commonly use is “serverless create –template aws-nodejs-typescript”.

You can also define a path in your command, to create your serverless service within a dedicated folder as follows “serverless create –template aws-nodejs-typescript –path MyServerlessService”.

Enjoy!