Show / Hide Table of Contents

Class Subnet

Represents a new VPC subnet resource.

Inheritance
object
Resource
Subnet
PrivateSubnet
PublicSubnet
Implements
ISubnet
IResource
ISubnetRef
IConstruct
IDependable
IEnvironmentAware
Inherited Members
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Subnet : Resource, ISubnet, IResource, ISubnetRef, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class Subnet Inherits Resource Implements ISubnet, IResource, ISubnetRef, IConstruct, IDependable, IEnvironmentAware
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")
                 },
                 MinHealthyPercent = 100,
                 TaskSubnets = new SubnetSelection {
                     Subnets = new [] { Subnet.FromSubnetId(this, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0") }
                 }
             });

Synopsis

Constructors

Subnet(Construct, string, ISubnetProps)

Represents a new VPC subnet resource.

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.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

RouteTable

The routeTableId attached to this subnet.

SubnetAvailabilityZone

Represents a new VPC subnet resource.

SubnetId

The subnetId for this particular subnet.

SubnetIpv6CidrBlocks

Represents a new VPC subnet resource.

SubnetNetworkAclAssociationId

Represents a new VPC subnet resource.

SubnetOutpostArn

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

SubnetRef

A reference to a Subnet resource.

SubnetVpcId

Represents a new VPC subnet resource.

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.

AddIpv6DefaultEgressOnlyInternetRoute(string)

Create a default IPv6 route that points to a passed EIGW.

AddIpv6DefaultInternetRoute(string)

Create a default IPv6 route that points to a passed IGW.

AddIpv6Nat64Route(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)

Represents a new VPC subnet resource.

FromSubnetId(Construct, string, string)

Import existing subnet from id.

IsVpcSubnet(object)

Represents a new VPC subnet resource.

Constructors

Subnet(Construct, string, ISubnetProps)

Represents a new VPC subnet resource.

public Subnet(Construct scope, string id, ISubnetProps props)
Parameters
scope Construct
id string
props ISubnetProps
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")
                 },
                 MinHealthyPercent = 100,
                 TaskSubnets = new SubnetSelection {
                     Subnets = new [] { Subnet.FromSubnetId(this, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0") }
                 }
             });

Properties

AvailabilityZone

The Availability Zone the subnet is located in.

public virtual string AvailabilityZone { get; }
Property Value

string

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

DependencyElements

Parts of this VPC subnet.

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

IDependable[]

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

InternetConnectivityEstablished

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

public virtual IDependable InternetConnectivityEstablished { get; }
Property Value

IDependable

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

Ipv4CidrBlock

The IPv4 CIDR block for this subnet.

public virtual string Ipv4CidrBlock { get; }
Property Value

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().

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

RouteTable

The routeTableId attached to this subnet.

public virtual IRouteTable RouteTable { get; }
Property Value

IRouteTable

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

SubnetAvailabilityZone

Represents a new VPC subnet resource.

public virtual string SubnetAvailabilityZone { get; }
Property Value

string

Remarks

Attribute: true

SubnetId

The subnetId for this particular subnet.

public virtual string SubnetId { get; }
Property Value

string

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

SubnetIpv6CidrBlocks

Represents a new VPC subnet resource.

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

string[]

Remarks

Attribute: true

SubnetNetworkAclAssociationId

Represents a new VPC subnet resource.

public virtual string SubnetNetworkAclAssociationId { get; }
Property Value

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

string

Remarks

Attribute: true

SubnetRef

A reference to a Subnet resource.

public virtual ISubnetReference SubnetRef { get; }
Property Value

ISubnetReference

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

SubnetVpcId

Represents a new VPC subnet resource.

public virtual string SubnetVpcId { get; }
Property Value

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 string

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

gatewayAttachment IDependable

the gateway attachment construct to be added as a dependency.

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

AddDefaultNatRoute(string)

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

public virtual void AddDefaultNatRoute(string natGatewayId)
Parameters
natGatewayId string

The ID of the NAT gateway.

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

AddIpv6DefaultEgressOnlyInternetRoute(string)

Create a default IPv6 route that points to a passed EIGW.

public virtual void AddIpv6DefaultEgressOnlyInternetRoute(string gatewayId)
Parameters
gatewayId string

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

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

AddIpv6DefaultInternetRoute(string)

Create a default IPv6 route that points to a passed IGW.

public virtual void AddIpv6DefaultInternetRoute(string gatewayId)
Parameters
gatewayId string

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

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

AddIpv6Nat64Route(string)

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

public virtual void AddIpv6Nat64Route(string natGatewayId)
Parameters
natGatewayId string

The ID of the NAT gateway.

Remarks

Uses the known 64:ff9b::/96 prefix.

AddRoute(string, IAddRouteOptions)

Adds an entry to this subnets route table.

public virtual void AddRoute(string id, IAddRouteOptions options)
Parameters
id string
options IAddRouteOptions
Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

AssociateNetworkAcl(string, INetworkAcl)

Associate a Network ACL with this subnet.

public virtual void AssociateNetworkAcl(string id, INetworkAcl networkAcl)
Parameters
id string
networkAcl INetworkAcl
Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

FromSubnetAttributes(Construct, string, ISubnetAttributes)

Represents a new VPC subnet resource.

public static ISubnet FromSubnetAttributes(Construct scope, string id, ISubnetAttributes attrs)
Parameters
scope Construct
id string
attrs ISubnetAttributes
Returns

ISubnet

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")
                 },
                 MinHealthyPercent = 100,
                 TaskSubnets = new SubnetSelection {
                     Subnets = new [] { Subnet.FromSubnetId(this, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0") }
                 }
             });

FromSubnetId(Construct, string, string)

Import existing subnet from id.

public static ISubnet FromSubnetId(Construct scope, string id, string subnetId)
Parameters
scope Construct
id string
subnetId string
Returns

ISubnet

Remarks

Resource: AWS::EC2::Subnet

ExampleMetadata: infused

IsVpcSubnet(object)

Represents a new VPC subnet resource.

public static bool IsVpcSubnet(object x)
Parameters
x object
Returns

bool

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")
                 },
                 MinHealthyPercent = 100,
                 TaskSubnets = new SubnetSelection {
                     Subnets = new [] { Subnet.FromSubnetId(this, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0") }
                 }
             });

Implements

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