Carina

Resource

aws.ec2.NatGateway

Describes a NAT gateway.

Example

let vpc = aws.ec2.Vpc {
  cidr_block = '10.0.0.0/16'

  tags = {
    Environment = 'example'
  }
}

let internet_gateway = aws.ec2.InternetGateway {
  vpc_id = vpc.vpc_id

  tags = {
    Environment = 'example'
  }
}

let subnet = aws.ec2.Subnet {
  vpc_id            = vpc.vpc_id
  cidr_block        = '10.0.1.0/24'
  availability_zone = aws.AvailabilityZone.ZoneName.ap_northeast_1a

  tags = {
    Environment = 'example'
  }
}

let public_route_table = aws.ec2.RouteTable {
  vpc_id = vpc.vpc_id

  tags = {
    Environment = 'example'
  }
}

let internet_route = aws.ec2.Route {
  route_table_id         = public_route_table.route_table_id
  destination_cidr_block = '0.0.0.0/0'
  gateway_id             = internet_gateway.internet_gateway_id
}

let public_subnet_route_table_association = aws.ec2.SubnetRouteTableAssociation {
  subnet_id      = subnet.subnet_id
  route_table_id = public_route_table.route_table_id
}

let eip = aws.ec2.Eip {
  domain = aws.ec2.Eip.Domain.vpc

  tags = {
    Environment = 'example'
  }
}

aws.ec2.NatGateway {
  allocation_id     = eip.allocation_id
  subnet_id         = subnet.subnet_id
  connectivity_type = aws.ec2.NatGateway.ConnectivityType.public

  directives {
    depends_on = [
      internet_gateway,
      internet_route,
      public_subnet_route_table_association,
    ]
  }

  tags = {
    Environment = 'example'
  }
}

Argument Reference

allocation_id

[Public NAT gateways only] The allocation ID of an Elastic IP address to associate with the NAT gateway. You cannot specify an Elastic IP address with a private NAT gateway. If the Elastic IP address is associated with another resource, you must first disassociate it.

availability_mode

Specifies whether to create a zonal (single-AZ) or regional (multi-AZ) NAT gateway. Defaults to zonal. A zonal NAT gateway is a NAT Gateway that provides redundancy and scalability within a single availability zone. A regional NAT gateway is a single NAT Gateway that works across multiple availability zones (AZs) in your VPC, providing redundancy, scalability and availability across all the AZs in a Region. For more information, see Regional NAT gateways for automatic multi-AZ expansion in the Amazon VPC User Guide.

availability_zone_addresses

For regional NAT gateways only: Specifies which Availability Zones you want the NAT gateway to support and the Elastic IP addresses (EIPs) to use in each AZ. The regional NAT gateway uses these EIPs to handle outbound NAT traffic from their respective AZs. If not specified, the NAT gateway will automatically expand to new AZs and associate EIPs upon detection of an elastic network interface. If you specify this parameter, auto-expansion is disabled and you must manually manage AZ coverage. A regional NAT gateway is a single NAT Gateway that works across multiple availability zones (AZs) in your VPC, providing redundancy, scalability and availability across all the AZs in a Region. For more information, see Regional NAT gateways for automatic multi-AZ expansion in the Amazon VPC User Guide.

connectivity_type

Indicates whether the NAT gateway supports public or private connectivity. The default is public connectivity.

private_ip_address

The private IPv4 address to assign to the NAT gateway. If you don't provide an address, a private IPv4 address will be automatically assigned.

subnet_id

The ID of the subnet in which to create the NAT gateway.

vpc_id

The ID of the VPC where you want to create a regional NAT gateway.

tags

The tags for the resource.

Enum Values

availability_mode (AvailabilityMode)

Value DSL Identifier
regional aws.ec2.NatGateway.AvailabilityMode.regional
zonal aws.ec2.NatGateway.AvailabilityMode.zonal

Shorthand formats: regional or AvailabilityMode.regional

connectivity_type (ConnectivityType)

Value DSL Identifier
private aws.ec2.NatGateway.ConnectivityType.private
public aws.ec2.NatGateway.ConnectivityType.public

Shorthand formats: private or ConnectivityType.private

Struct Definitions

availability_zone_addresses[]

Field Type Required Description
allocation_ids List<AllocationId (pattern: /^eipalloc-[0-9a-f]{8,}$/ (Full))> (unordered) No The allocation IDs of the Elastic IP addresses (EIPs) to be used for handling outbound NAT traffic in this specific Availability Zone.
availability_zone ZoneName (custom validator, DSL transform: HyphenToUnderscore) No For regional NAT gateways only: The Availability Zone where this specific NAT gateway configuration will be active. Each AZ in a regional NAT gateway has its own configuration to handle outbound NAT traffic from that AZ.

Attribute Reference

nat_gateway_id

The ID of the NAT gateway.