Skip to content

aws.ec2-subnet resource

Description

Subnet is an EC2 subnet: an IP range carved out of a VPC in one Availability Zone. The VPC, the zone, the IPv4 and IPv6 ranges, and an Outpost ARN are fixed when the subnet is created, so a change to any of them replaces the subnet; the launch-time options are reconciled in place. CreateSubnet accepts only the address and placement fields. The launch-time options each have no create-time setting and are applied after the subnet exists, one ModifySubnetAttribute call per option. A nil option is never sent: the value is AWS's to decide, the default for a new subnet or whatever an earlier apply set. EC2 has no reset call, so restoring a default after an apply set the option means setting the default explicitly.

Source: internal/service/ec2/subnet_rsrc.go:30

Example usage:

imports: {
  aws: 'github.com/cloudboss/unobin-library-aws'
}

resources: {
  example: aws.ec2-subnet {
    # Set input fields here.
  }
}

Inputs

vpc-id

string

required

availability-zone

optional(string)

availability-zone-id

optional(string)

cidr-block

optional(string)

ipv4-ipam-pool-id

optional(string)

ipv4-netmask-length

optional(integer)

ipv6-cidr-block

optional(string)

ipv6-ipam-pool-id

optional(string)

ipv6-native

optional(boolean)

ipv6-netmask-length

optional(integer)

outpost-arn

optional(string)

tags

map(string)

assign-ipv6-address-on-creation

optional(boolean)

The remaining fields each back a ModifySubnetAttribute call after create.

enable-dns64

optional(boolean)

enable-lni-at-device-index

optional(integer)

enable-resource-name-dns-aaaa-record-on-launch

optional(boolean)

enable-resource-name-dns-a-record-on-launch

optional(boolean)

map-public-ip-on-launch

optional(boolean)

private-dns-hostname-type-on-launch

optional(string)

customer-owned-ipv4-pool

optional(string)

map-customer-owned-ip-on-launch

optional(boolean)

Input Constraints

Field combinations

At most one of availability-zone or availability-zone-id.

Forbidden together: ipv4-netmask-length, cidr-block, and customer-owned-ipv4-pool.

Required together: ipv4-netmask-length and ipv4-ipam-pool-id.

At most one of ipv4-ipam-pool-id or customer-owned-ipv4-pool.

Required together: customer-owned-ipv4-pool, map-customer-owned-ip-on-launch, and outpost-arn.

Required together: map-customer-owned-ip-on-launch, customer-owned-ipv4-pool, and outpost-arn.

Forbidden together: ipv6-netmask-length and ipv6-cidr-block.

Required together: ipv6-netmask-length and ipv6-ipam-pool-id.

Private dns hostname type on launch rules

private-dns-hostname-type-on-launch must be ip-name or resource-name.

Rule logic
When
input.private-dns-hostname-type-on-launch != null
Require
input.private-dns-hostname-type-on-launch == 'ip-name'
|| input.private-dns-hostname-type-on-launch == 'resource-name'

Enable lni at device index rules

enable-lni-at-device-index must be a positive device position.

Rule logic
When
input.enable-lni-at-device-index != null
Require
input.enable-lni-at-device-index == null
|| input.enable-lni-at-device-index > 0

Outputs

arn

string

id

string

owner-id

string

availability-zone

string

availability-zone-id

string

cidr-block

string

ipv6-cidr-block

string

ipv6-cidr-block-association-id

string