Deploying our first Lambda with CloudFormation

In this section, we will create our first template and deploy the stack using our Gradle script. We can start writing our template by creating a text file named cloudformation.template in the root directory of our project:

    $ cd ~/serverlessbook
    $ touch cloudformation.template
  

In this section, we will be defining three CloudFormation resources:

  • The IAM role
  • A custom IAM policy to be attached to the role created earlier
  • A Lambda function

For the first resource, we can start with IAM Role, which our Lambda function will use for execution. In the first chapter, we briefly looked at what an IAM Role is. Let's assume that our Lambda function will access S3 buckets in our accounts. How we can allow ...

Get Building Serverless Architectures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.