Show / Hide Table of Contents

Class Subnet

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.

Example Usage

Basic Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var main = new Aws.Ec2.Subnet("main", new Aws.Ec2.SubnetArgs
    {
        CidrBlock = "10.0.1.0/24",
        Tags = 
        {
            { "Name", "Main" },
        },
        VpcId = aws_vpc.Main.Id,
    });
}

}

Subnets In Secondary VPC CIDR Blocks

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var secondaryCidr = new Aws.Ec2.VpcIpv4CidrBlockAssociation("secondaryCidr", new Aws.Ec2.VpcIpv4CidrBlockAssociationArgs
    {
        CidrBlock = "172.2.0.0/16",
        VpcId = aws_vpc.Main.Id,
    });
    var inSecondaryCidr = new Aws.Ec2.Subnet("inSecondaryCidr", new Aws.Ec2.SubnetArgs
    {
        CidrBlock = "172.2.0.0/24",
        VpcId = secondaryCidr.VpcId,
    });
}

}
Inheritance
System.Object
Resource
CustomResource
Subnet
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.Ec2
Assembly: Pulumi.Aws.dll
Syntax
public class Subnet : CustomResource

Constructors

View Source

Subnet(String, SubnetArgs, CustomResourceOptions)

Create a Subnet resource with the given unique name, arguments, and options.

Declaration
public Subnet(string name, SubnetArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

SubnetArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Arn

The ARN of the subnet.

Declaration
public Output<string> Arn { get; }
Property Value
Type Description
Output<System.String>
View Source

AssignIpv6AddressOnCreation

Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false

Declaration
public Output<bool?> AssignIpv6AddressOnCreation { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

AvailabilityZone

The AZ for the subnet.

Declaration
public Output<string> AvailabilityZone { get; }
Property Value
Type Description
Output<System.String>
View Source

AvailabilityZoneId

The AZ ID of the subnet.

Declaration
public Output<string> AvailabilityZoneId { get; }
Property Value
Type Description
Output<System.String>
View Source

CidrBlock

The CIDR block for the subnet.

Declaration
public Output<string> CidrBlock { get; }
Property Value
Type Description
Output<System.String>
View Source

Ipv6CidrBlock

The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.

Declaration
public Output<string> Ipv6CidrBlock { get; }
Property Value
Type Description
Output<System.String>
View Source

Ipv6CidrBlockAssociationId

The association ID for the IPv6 CIDR block.

Declaration
public Output<string> Ipv6CidrBlockAssociationId { get; }
Property Value
Type Description
Output<System.String>
View Source

MapPublicIpOnLaunch

Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.

Declaration
public Output<bool?> MapPublicIpOnLaunch { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

OutpostArn

The Amazon Resource Name (ARN) of the Outpost.

Declaration
public Output<string> OutpostArn { get; }
Property Value
Type Description
Output<System.String>
View Source

OwnerId

The ID of the AWS account that owns the subnet.

Declaration
public Output<string> OwnerId { get; }
Property Value
Type Description
Output<System.String>
View Source

Tags

A map of tags to assign to the resource.

Declaration
public Output<ImmutableDictionary<string, object>> Tags { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>>
View Source

VpcId

The VPC ID.

Declaration
public Output<string> VpcId { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, SubnetState, CustomResourceOptions)

Get an existing Subnet resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static Subnet Get(string name, Input<string> id, SubnetState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

SubnetState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Subnet
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.