Rusty  Shanahan

Rusty Shanahan


Deploying Your First Serverless Function With AWS Lambda

I was late to the “serverless” party.

But after a friend explained that it cut his startup’s infrastructure cost to almost zero, while improving speed, I had to check it out.

Lambda is AWS’ version of serverless.

We’re going to deploy code on Lambda to better understand how it works.

Login to your AWS console and follow along!

What is Serverless

“Serverless” (in AWS) is:

  • code run on demand
  • per a pre-defined trigger
  • that scales out (not up)
  • without any server administration

For example. A function that takes input from an HTTP request, performs calculations, and returns a response.

In the above example. If you received 5000 different HTTP requests at the same time, no problem. AWS will handle all of them concurrently.

This will make more sense after we set it up.

Our Lambda Function

Our serverless function is going to take an input, multiply it by 5, and return a response.

We’ll use API Gateway to receive requests, pass the request body to Lambda, then return lambda’s output to the client.

Here we go!

Create the Lambda

In AWS, navigate to the Lambda service, then click “Create function”.

Image for post


  • Select “Author from scratch”.
  • Input a name for your function. “myFunction” or anything else is fine.
  • Select the programming language. I’ve chosen “Python 3.7”.
  • Select “Create a new role with basic Lambda permissions”.
  • And click “Create function”.

#software-development #aws #devops #serverless #programming

What is GEEK

Buddha Community

Deploying Your First Serverless Function With AWS Lambda

Creating your first AWS Lambda Function in Node.js | Serverless Saturday

In this Serverless Saturday video, we’ll be going over how to create your first AWS Lambda function!
In the next video, we’ll be covering how to set up CI/CD with your AWS Lambda function so stay tuned and make sure to subscribe!

To get started, log-in to your AWS account here:

Found this video helpful? Feel free to support this channel here:

#node.js #node #lambda #aws #aws lambda #serverless

Christa  Stehr

Christa Stehr


How To Unite AWS KMS with Serverless Application Model (SAM)

The Basics

AWS KMS is a Key Management Service that let you create Cryptographic keys that you can use to encrypt and decrypt data and also other keys. You can read more about it here.

Important points about Keys

Please note that the customer master keys(CMK) generated can only be used to encrypt small amount of data like passwords, RSA key. You can use AWS KMS CMKs to generate, encrypt, and decrypt data keys. However, AWS KMS does not store, manage, or track your data keys, or perform cryptographic operations with data keys.

You must use and manage data keys outside of AWS KMS. KMS API uses AWS KMS CMK in the encryption operations and they cannot accept more than 4 KB (4096 bytes) of data. To encrypt application data, use the server-side encryption features of an AWS service, or a client-side encryption library, such as the AWS Encryption SDK or the Amazon S3 encryption client.


We want to create signup and login forms for a website.

Passwords should be encrypted and stored in DynamoDB database.

What do we need?

  1. KMS key to encrypt and decrypt data
  2. DynamoDB table to store password.
  3. Lambda functions & APIs to process Login and Sign up forms.
  4. Sign up/ Login forms in HTML.

Lets Implement it as Serverless Application Model (SAM)!

Lets first create the Key that we will use to encrypt and decrypt password.

    Type: AWS::KMS::Key
      Description: CMK for encrypting and decrypting
        Version: '2012-10-17'
        Id: key-default-1
        - Sid: Enable IAM User Permissions
          Effect: Allow
            AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
          Action: kms:*
          Resource: '*'
        - Sid: Allow administration of the key
          Effect: Allow
            AWS: !Sub arn:aws:iam::${AWS::AccountId}:user/${KeyAdmin}
          - kms:Create*
          - kms:Describe*
          - kms:Enable*
          - kms:List*
          - kms:Put*
          - kms:Update*
          - kms:Revoke*
          - kms:Disable*
          - kms:Get*
          - kms:Delete*
          - kms:ScheduleKeyDeletion
          - kms:CancelKeyDeletion
          Resource: '*'
        - Sid: Allow use of the key
          Effect: Allow
            AWS: !Sub arn:aws:iam::${AWS::AccountId}:user/${KeyUser}
          - kms:DescribeKey
          - kms:Encrypt
          - kms:Decrypt
          - kms:ReEncrypt*
          - kms:GenerateDataKey
          - kms:GenerateDataKeyWithoutPlaintext
          Resource: '*'

The important thing in above snippet is the KeyPolicy. KMS requires a Key Administrator and Key User. As a best practice your Key Administrator and Key User should be 2 separate user in your Organisation. We are allowing all permissions to the root users.

So if your key Administrator leaves the organisation, the root user will be able to delete this key. As you can see **KeyAdmin **can manage the key but not use it and KeyUser can only use the key. ${KeyAdmin} and **${KeyUser} **are parameters in the SAM template.

You would be asked to provide values for these parameters during SAM Deploy.

#aws #serverless #aws-sam #aws-key-management-service #aws-certification #aws-api-gateway #tutorial-for-beginners #aws-blogs

Luna  Hermann

Luna Hermann


Calling an AWS Lambda function from another Lambda function

In this article, I am going to explain how to create an AWS Lambda function and then call this function from another Lambda function within the same region. This is a useful scenario in which we may need to execute a second lambda function based on the outcome of some previous logic. Another scenario may be to execute a second lambda function several times by using different parameters.

For the sake of this article, we will consider a typical retailer application, in which we can purchase different products from a retailer site using a lambda function.

Architecture Diagram

Figure 1 – Architecture Diagram

If you consider the above architecture diagram, you can see that we have an AWS lambda function – the ParentFunction, which assumes a specific role from the IAM (Invoke Other Lambda Function) and then calls another lambda function – the ChildFunction with a payload. Once the execution of the ChildFunction is completed, it returns a response, which is then passed on to the ParentFunction. The ParentFunction receives the response and handles the job accordingly.

As in this example, let us assume that the ParentFunction is going to call the ChildFunction with a payload of ProductName, Quantity, and the UnitPrice of that product. The ChildFunction, in turn, will process this payload, calculate the total sales amount, generate a transaction reference ID, and return this information to the ParentFunction.

Creating the first AWS Lambda Function – ChildFunction

Let us first go ahead and create the ChildFunction, which will process the input payload and return the results to the ParentFunction.

#aws rds #functions #aws #lambda function

Hermann  Frami

Hermann Frami


Deploying an Apollo GraphQL Application As An AWS Lambda Function Through Serverless

This article is in continuation of my previous article wherein we built a minimalistic application to pull AWS DynamoDB data from a locally hosted Graphql server.

Now we will modify the code further to run the same code as AWS Lambda function deployed through Serverless.

STEP 4: Make a lambda function

Apollo Server provides binding for lambda function through apollo-server-lambda module.

Change server.js, and rather than running Apollo Server, export an apollo GraphQL lambda function which AWS lambda will invoke based on HTTP event.

const { ApolloServer, gql } = require(‘apollo-server-lambda’);

const handler = server.createHandler({
  cors: {
    origin: true,
    credentials: true,
exports.graphqlHandler = handler;

#aws #graphql #aws-lambda #serverless #javascript

Gordon  Matlala

Gordon Matlala


Adding Code to AWS Lambda, Lambda Layers, and Lambda Extensions Using Docker

2020 was a difficult year for all of us, and it was no different for engineering teams. Many software releases were postponed, and the industry slowed its development speed quite a bit.

But at least at AWS, some teams released updates out of the door at the end of the year. AWS Lambda received two significant improvements:

  • AWS Lambda Extensions; and
  • Support of Docker images for your functions.

With these two new features and Lambda Layers, we now have three ways to add code to Lambda that isn’t directly part of our Lambda function.

The question is now: when should we use what?

In this article, I try to shine some light on the Lambda Layers, Lambda Extensions, and Docker image for Lambda.

First things first. All these Lambda features can be used together. So if you think about where to put your code, at least your decisions aren’t mutually exclusive. You can upload a Docker image and attach a regular Lambda Layer and a Lambda Extension. The same is possible if your Lambda function is based on a ZIP archive.

What does this all mean? Keep reading and find out.

#aws #aws-lambda #serverless #devops #docker #lambda