Show / Hide Table of Contents

Class Subnet

Represents a new VPC subnet resource.

Inheritance
System.Object
Construct
Resource
Subnet
PrivateSubnet
PublicSubnet
Implements
ISubnet
IResource
IConstruct
Constructs.IConstruct
IDependable
Inherited Members
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(String, IArnComponents)
Resource.GetResourceNameAttribute(String)
Resource.Env
Resource.PhysicalName
Resource.Stack
Construct.IsConstruct(Object)
Construct.OnPrepare()
Construct.OnSynthesize(ISynthesisSession)
Construct.OnValidate()
Construct.Prepare()
Construct.Synthesize(ISynthesisSession)
Construct.Validate()
Construct.Node
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.AWS.EC2.dll
Syntax (csharp)
public class Subnet : Resource, ISubnet, IResource, IConstruct, IDependable
Syntax (vb)
Public Class Subnet
    Inherits Resource
    Implements ISubnet, IResource, IConstruct, IDependable
Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

Examples
Cluster cluster;

var loadBalancedFargateService = new ApplicationLoadBalancedFargateService(this, "Service", new ApplicationLoadBalancedFargateServiceProps {
    Cluster = cluster,
    MemoryLimitMiB = 1024,
    DesiredCount = 1,
    Cpu = 512,
    TaskImageOptions = new ApplicationLoadBalancedTaskImageOptions {
        Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample")
    },
    TaskSubnets = new SubnetSelection {
        Subnets = new [] { Subnet.FromSubnetId(this, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0") }
    }
});

Synopsis

Constructors

Subnet(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

Subnet(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Subnet(Construct, String, ISubnetProps)

Properties

AvailabilityZone

The Availability Zone the subnet is located in.

DependencyElements

Parts of this VPC subnet.

InternetConnectivityEstablished

Dependable that can be depended upon to force internet connectivity established on the VPC.

Ipv4CidrBlock

The IPv4 CIDR block for this subnet.

NetworkAcl

Network ACL associated with this Subnet.

RouteTable

The routeTableId attached to this subnet.

SubnetAvailabilityZone
SubnetId

The subnetId for this particular subnet.

SubnetIpv6CidrBlocks
SubnetNetworkAclAssociationId
SubnetOutpostArn

The Amazon Resource Name (ARN) of the Outpost for this subnet (if one exists).

SubnetVpcId

Methods

AddDefaultInternetRoute(String, IDependable)

Create a default route that points to a passed IGW, with a dependency on the IGW's attachment to the VPC.

AddDefaultNatRoute(String)

Adds an entry to this subnets route table that points to the passed NATGatewayId.

AddRoute(String, IAddRouteOptions)

Adds an entry to this subnets route table.

AssociateNetworkAcl(String, INetworkAcl)

Associate a Network ACL with this subnet.

FromSubnetAttributes(Construct, String, ISubnetAttributes)
FromSubnetId(Construct, String, String)

Import existing subnet from id.

IsVpcSubnet(Object)

Constructors

Subnet(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected Subnet(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

Subnet(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected Subnet(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Subnet(Construct, String, ISubnetProps)

public Subnet(Construct scope, string id, ISubnetProps props)
Parameters
scope Constructs.Construct
id System.String
props ISubnetProps

Properties

AvailabilityZone

The Availability Zone the subnet is located in.

public virtual string AvailabilityZone { get; }
Property Value

System.String

DependencyElements

Parts of this VPC subnet.

public virtual IDependable[] DependencyElements { get; }
Property Value

IDependable[]

InternetConnectivityEstablished

Dependable that can be depended upon to force internet connectivity established on the VPC.

public virtual IDependable InternetConnectivityEstablished { get; }
Property Value

IDependable

Ipv4CidrBlock

The IPv4 CIDR block for this subnet.

public virtual string Ipv4CidrBlock { get; }
Property Value

System.String

Remarks

Attribute: true

NetworkAcl

Network ACL associated with this Subnet.

public virtual INetworkAcl NetworkAcl { get; }
Property Value

INetworkAcl

Remarks

Upon creation, this is the default ACL which allows all traffic, except explicit DENY entries that you add.

You can replace it with a custom ACL which denies all traffic except the explicit ALLOW entries that you add by creating a NetworkAcl object and calling associateNetworkAcl().

RouteTable

The routeTableId attached to this subnet.

public virtual IRouteTable RouteTable { get; }
Property Value

IRouteTable

SubnetAvailabilityZone

public virtual string SubnetAvailabilityZone { get; }
Property Value

System.String

Remarks

Attribute: true

SubnetId

The subnetId for this particular subnet.

public virtual string SubnetId { get; }
Property Value

System.String

SubnetIpv6CidrBlocks

public virtual string[] SubnetIpv6CidrBlocks { get; }
Property Value

System.String[]

Remarks

Attribute: true

SubnetNetworkAclAssociationId

public virtual string SubnetNetworkAclAssociationId { get; }
Property Value

System.String

Remarks

Attribute: true

SubnetOutpostArn

The Amazon Resource Name (ARN) of the Outpost for this subnet (if one exists).

public virtual string SubnetOutpostArn { get; }
Property Value

System.String

Remarks

Attribute: true

SubnetVpcId

public virtual string SubnetVpcId { get; }
Property Value

System.String

Remarks

Attribute: true

Methods

AddDefaultInternetRoute(String, IDependable)

Create a default route that points to a passed IGW, with a dependency on the IGW's attachment to the VPC.

public virtual void AddDefaultInternetRoute(string gatewayId, IDependable gatewayAttachment)
Parameters
gatewayId System.String

the logical ID (ref) of the gateway attached to your VPC.

gatewayAttachment IDependable

the gateway attachment construct to be added as a dependency.

AddDefaultNatRoute(String)

Adds an entry to this subnets route table that points to the passed NATGatewayId.

public virtual void AddDefaultNatRoute(string natGatewayId)
Parameters
natGatewayId System.String

The ID of the NAT gateway.

AddRoute(String, IAddRouteOptions)

Adds an entry to this subnets route table.

public virtual void AddRoute(string id, IAddRouteOptions options)
Parameters
id System.String
options IAddRouteOptions

AssociateNetworkAcl(String, INetworkAcl)

Associate a Network ACL with this subnet.

public virtual void AssociateNetworkAcl(string id, INetworkAcl networkAcl)
Parameters
id System.String
networkAcl INetworkAcl

FromSubnetAttributes(Construct, String, ISubnetAttributes)

public static ISubnet FromSubnetAttributes(Construct scope, string id, ISubnetAttributes attrs)
Parameters
scope Constructs.Construct
id System.String
attrs ISubnetAttributes
Returns

ISubnet

FromSubnetId(Construct, String, String)

Import existing subnet from id.

public static ISubnet FromSubnetId(Construct scope, string id, string subnetId)
Parameters
scope Constructs.Construct
id System.String
subnetId System.String
Returns

ISubnet

IsVpcSubnet(Object)

public static bool IsVpcSubnet(object x)
Parameters
x System.Object
Returns

System.Boolean

Implements

ISubnet
IResource
IConstruct
Constructs.IConstruct
IDependable
Back to top Generated by DocFX