Class CfnSubnet
Specifies a subnet for the specified VPC.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnSubnet : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnSubnet
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
For an IPv4 only subnet, specify an IPv4 CIDR block. If the VPC has an IPv6 CIDR block, you can create an IPv6 only subnet or a dual stack subnet instead. For an IPv6 only subnet, specify an IPv6 CIDR block. For a dual stack subnet, specify both an IPv4 CIDR block and an IPv6 CIDR block.
For more information, see Subnets for your VPC in the Amazon VPC User Guide .
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html
CloudformationResource: AWS::EC2::Subnet
ExampleMetadata: infused
Examples
Vpc vpc;
public void AssociateSubnetWithV6Cidr(Vpc vpc, int count, ISubnet subnet)
{
var cfnSubnet = (CfnSubnet)subnet.Node.DefaultChild;
cfnSubnet.Ipv6CidrBlock = Fn.Select(count, Fn.Cidr(Fn.Select(0, vpc.VpcIpv6CidrBlocks), 256, (128 - 64).ToString()));
cfnSubnet.AssignIpv6AddressOnCreation = true;
}
// make an ipv6 cidr
var ipv6cidr = new CfnVPCCidrBlock(this, "CIDR6", new CfnVPCCidrBlockProps {
VpcId = vpc.VpcId,
AmazonProvidedIpv6CidrBlock = true
});
// connect the ipv6 cidr to all vpc subnets
var subnetcount = 0;
var subnets = vpc.PublicSubnets.Concat(vpc.PrivateSubnets);
for (var subnet in subnets)
{
// Wait for the ipv6 cidr to complete
subnet.Node.AddDependency(ipv6cidr);
AssociateSubnetWithV6Cidr(vpc, subnetcount, subnet);
subnetcount = subnetcount + 1;
}
var cluster = new Cluster(this, "hello-eks", new ClusterProps {
Version = KubernetesVersion.V1_29,
Vpc = vpc,
IpFamily = IpFamily.IP_V6,
VpcSubnets = new [] { new SubnetSelection { Subnets = vpc.PublicSubnets } }
});
Synopsis
Constructors
CfnSubnet(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnSubnet(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CfnSubnet(Construct, String, ICfnSubnetProps) |
Properties
AssignIpv6AddressOnCreation | Indicates whether a network interface created in this subnet receives an IPv6 address. |
AttrAvailabilityZone | The Availability Zone of this subnet. |
AttrAvailabilityZoneId | The Availability Zone ID of this subnet. |
AttrCidrBlock | The IPv4 CIDR blocks that are associated with the subnet. |
AttrIpv6CidrBlocks | |
AttrNetworkAclAssociationId | The ID of the network ACL that is associated with the subnet's VPC, such as |
AttrOutpostArn | The Amazon Resource Name (ARN) of the Outpost. |
AttrSubnetId | The ID of the subnet. |
AttrVpcId | The ID of the subnet's VPC, such as |
AvailabilityZone | The Availability Zone of the subnet. |
AvailabilityZoneId | The AZ ID of the subnet. |
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
CidrBlock | The IPv4 CIDR block assigned to the subnet. |
EnableDns64 | Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. |
Ipv4IpamPoolId | An IPv4 IPAM pool ID for the subnet. |
Ipv4NetmaskLength | An IPv4 netmask length for the subnet. |
Ipv6CidrBlock | The IPv6 CIDR block. |
Ipv6CidrBlocks | The IPv6 network ranges for the subnet, in CIDR notation. |
Ipv6IpamPoolId | An IPv6 IPAM pool ID for the subnet. |
Ipv6Native | Indicates whether this is an IPv6 only subnet. |
Ipv6NetmaskLength | An IPv6 netmask length for the subnet. |
MapPublicIpOnLaunch | Indicates whether instances launched in this subnet receive a public IPv4 address. |
OutpostArn | The Amazon Resource Name (ARN) of the Outpost. |
PrivateDnsNameOptionsOnLaunch | The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled. |
Tags | Tag Manager which manages the tags for this resource. |
TagsRaw | Any tags assigned to the subnet. |
VpcId | The ID of the VPC the subnet is in. |
Methods
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
Constructors
CfnSubnet(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnSubnet(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnSubnet(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnSubnet(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CfnSubnet(Construct, String, ICfnSubnetProps)
public CfnSubnet(Construct scope, string id, ICfnSubnetProps props)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnSubnetProps
Resource properties.
Properties
AssignIpv6AddressOnCreation
Indicates whether a network interface created in this subnet receives an IPv6 address.
public virtual object AssignIpv6AddressOnCreation { get; set; }
Property Value
System.Object
Remarks
The default value is false
.
AttrAvailabilityZone
The Availability Zone of this subnet.
public virtual string AttrAvailabilityZone { get; }
Property Value
System.String
Remarks
For example, us-east-1a
.
CloudformationAttribute: AvailabilityZone
AttrAvailabilityZoneId
The Availability Zone ID of this subnet.
public virtual string AttrAvailabilityZoneId { get; }
Property Value
System.String
Remarks
For example, use1-az1
.
CloudformationAttribute: AvailabilityZoneId
AttrCidrBlock
The IPv4 CIDR blocks that are associated with the subnet.
public virtual string AttrCidrBlock { get; }
Property Value
System.String
Remarks
CloudformationAttribute: CidrBlock
AttrIpv6CidrBlocks
public virtual string[] AttrIpv6CidrBlocks { get; }
Property Value
System.String[]
Remarks
CloudformationAttribute: Ipv6CidrBlocks
AttrNetworkAclAssociationId
The ID of the network ACL that is associated with the subnet's VPC, such as acl-5fb85d36
.
public virtual string AttrNetworkAclAssociationId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: NetworkAclAssociationId
AttrOutpostArn
The Amazon Resource Name (ARN) of the Outpost.
public virtual string AttrOutpostArn { get; }
Property Value
System.String
Remarks
CloudformationAttribute: OutpostArn
AttrSubnetId
The ID of the subnet.
public virtual string AttrSubnetId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: SubnetId
AttrVpcId
The ID of the subnet's VPC, such as vpc-11ad4878
.
public virtual string AttrVpcId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: VpcId
AvailabilityZone
The Availability Zone of the subnet.
public virtual string AvailabilityZone { get; set; }
Property Value
System.String
AvailabilityZoneId
The AZ ID of the subnet.
public virtual string AvailabilityZoneId { get; set; }
Property Value
System.String
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
CidrBlock
The IPv4 CIDR block assigned to the subnet.
public virtual string CidrBlock { get; set; }
Property Value
System.String
EnableDns64
Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.
public virtual object EnableDns64 { get; set; }
Property Value
System.Object
Ipv4IpamPoolId
An IPv4 IPAM pool ID for the subnet.
public virtual string Ipv4IpamPoolId { get; set; }
Property Value
System.String
Ipv4NetmaskLength
An IPv4 netmask length for the subnet.
public virtual Nullable<double> Ipv4NetmaskLength { get; set; }
Property Value
System.Nullable<System.Double>
Ipv6CidrBlock
The IPv6 CIDR block.
public virtual string Ipv6CidrBlock { get; set; }
Property Value
System.String
Ipv6CidrBlocks
The IPv6 network ranges for the subnet, in CIDR notation.
public virtual string[] Ipv6CidrBlocks { get; set; }
Property Value
System.String[]
Ipv6IpamPoolId
An IPv6 IPAM pool ID for the subnet.
public virtual string Ipv6IpamPoolId { get; set; }
Property Value
System.String
Ipv6Native
Indicates whether this is an IPv6 only subnet.
public virtual object Ipv6Native { get; set; }
Property Value
System.Object
Ipv6NetmaskLength
An IPv6 netmask length for the subnet.
public virtual Nullable<double> Ipv6NetmaskLength { get; set; }
Property Value
System.Nullable<System.Double>
MapPublicIpOnLaunch
Indicates whether instances launched in this subnet receive a public IPv4 address.
public virtual object MapPublicIpOnLaunch { get; set; }
Property Value
System.Object
Remarks
The default value is false
.
OutpostArn
The Amazon Resource Name (ARN) of the Outpost.
public virtual string OutpostArn { get; set; }
Property Value
System.String
PrivateDnsNameOptionsOnLaunch
The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled.
public virtual object PrivateDnsNameOptionsOnLaunch { get; set; }
Property Value
System.Object
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
Any tags assigned to the subnet.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
VpcId
The ID of the VPC the subnet is in.
public virtual string VpcId { get; set; }
Property Value
System.String
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
- inspector TreeInspector
tree inspector to collect and process attributes.
RenderProperties(IDictionary<String, Object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
- props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>