Creating and attaching the internet gateway 

For the Lambdas that have to exist in a private subnet of the VPC, an internet gateway has to be created. The following code block has to be added under the Resources section of the vpc.yml file, at the same level as the letsPollVPC element. The following code block shows the way it is done:

        letsPollIGW:        Type: AWS::EC2::InternetGateway           letsPollVPCGatewayAttachment:        Type: AWS::EC2::VPCGatewayAttachment        Properties:          VpcId:            Ref: letsPollVPC          InternetGatewayId:            Ref: letsPollIGW          

A few points to note for the preceding code:

  • We created an Internet Gateway using the AWS::EC2::InternetGateway CloudFormation type.
  • We attached the newly created gateway to the letsPollVPC using the AWS::EC2::VPCGatewayAttachment ...

Get Hands-On Serverless Applications with Kotlin 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.