Expand description
Provides an VPC subnet resource.
NOTE: Due to AWS Lambda improved VPC networking changes that began deploying in September 2019, subnets associated with Lambda Functions can take up to 45 minutes to successfully delete. To allow for successful deletion, the provider will wait for at least 45 minutes even if a shorter delete timeout is specified.
§Example Usage
§Basic Usage
resources:
main:
type: aws:ec2:Subnet
properties:
vpcId: ${mainAwsVpc.id}
cidrBlock: 10.0.1.0/24
tags:
Name: Main
§Subnets In Secondary VPC CIDR Blocks
When managing subnets in one of a VPC’s secondary CIDR blocks created using a aws.ec2.VpcIpv4CidrBlockAssociation
resource, it is recommended to reference that resource’s vpc_id
attribute to ensure correct dependency ordering.
ⓘ
use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
let inSecondaryCidr = subnet::create(
"inSecondaryCidr",
SubnetArgs::builder()
.cidr_block("172.20.0.0/24")
.vpc_id("${secondaryCidr.vpcId}")
.build_struct(),
);
let secondaryCidr = vpc_ipv_4_cidr_block_association::create(
"secondaryCidr",
VpcIpv4CidrBlockAssociationArgs::builder()
.cidr_block("172.20.0.0/16")
.vpc_id("${main.id}")
.build_struct(),
);
}
§Import
Using pulumi import
, import subnets using the subnet id
. For example:
$ pulumi import aws:ec2/subnet:Subnet public_subnet subnet-9d4a7b6c
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments