Skip to main content
Providers

Subnet

A resource of the AWS provider, version 0.3.0, in its Networking group. Import it with:

import Subnet from "aws/networking"

Example

resource Subnet example {
    vpcId                       = "example-value"
    cidrBlock                   = "example-value"
    ipv6CidrBlock               = "example-value"
    availabilityZone            = "example-value"
    mapPublicIpOnLaunch         = false
    assignIpv6AddressOnCreation = false
    tags                        = "..."
}

Properties

Set by your code in the resource block. A required one must be set; any other you leave out takes the value under Default, if it has one.

NameTypeDefaultRequiredDescription
vpcIdstring—NoThe VPC ID where the subnet will be created
cidrBlockstring—NoThe IPv4 CIDR block for the subnet (e.g., 10.0.1.0/24)
ipv6CidrBlockstring—NoThe IPv6 CIDR block for the subnet
availabilityZonestring—NoThe Availability Zone for the subnet (e.g., us-east-1a)
mapPublicIpOnLaunchbooleanfalseNoAuto-assign public IPv4 addresses to instances
assignIpv6AddressOnCreationbooleanfalseNoAssign IPv6 addresses to instances
tagsobject—NoTags to apply to the subnet

Set by AWS after the resource is created: your code can read them but not set them. An importable one identifies an existing resource.

NameTypeImportableDescription
subnetIdstringNoThe subnet ID assigned by AWS
statestringNoThe current state of the subnet (pending, available)
availabilityZoneIdstringNoThe Availability Zone ID
availableIpAddressCountnumberNoThe number of available IPv4 addresses
defaultForAzbooleanNoWhether this is the default subnet for the AZ
ownerIdstringNoThe AWS account ID that owns the subnet
arnstringYesThe Amazon Resource Name (ARN) of the subnet

On this page