How to do it...

  1. Start with the usual CloudFormation template version and description:
      AWSTemplateFormatVersion: "2010-09-09"       Description: Create NAT Gateway and associated route.
  1. The template must take the following required parameters:
      Parameters:         PublicSubnetId:           Description: Public Subnet ID to add the NAT Gateway to           Type: AWS::EC2::Subnet::Id         RouteTableId:           Description: The private subnet route table to add the NAT          Gateway route to           Type: String
  1. In the Resources section, define an Elastic IP (EIP) that will be assigned to the NAT gateway:
      Resources:         EIP:           Type: AWS::EC2::EIP           Properties:             Domain: vpc
  1. Create the NAT gateway resource, assigning it the EIP you just defined in the public subnet:
      NatGateway:  Type: AWS::EC2::NatGateway ...

Get AWS Administration Cookbook 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.