Class SubnetType
The type of Subnet.
Inheritance
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public sealed class SubnetType : Enum
Syntax (vb)
Public NotInheritable Class SubnetType
Inherits
Enum
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
var cluster = new DatabaseCluster(this, "Database", new DatabaseClusterProps {
MasterUser = new Login {
Username = "myuser", // NOTE: 'admin' is reserved by DocumentDB
ExcludeCharacters = "\"@/:", // optional, defaults to the set "\"@/" and is also used for eventually created rotations
SecretName = "/myapp/mydocdb/masteruser"
},
InstanceType = InstanceType.Of(InstanceClass.MEMORY5, InstanceSize.LARGE),
VpcSubnets = new SubnetSelection {
SubnetType = SubnetType.PUBLIC
},
Vpc = vpc,
CopyTagsToSnapshot = true
});
Synopsis
Fields
PRIVATE_ISOLATED | Isolated Subnets do not route traffic to the Internet (in this VPC), and as such, do not require NAT gateways. |
PRIVATE_WITH_EGRESS | Subnet that routes to the internet, but not vice versa. |
PRIVATE_WITH_NAT | (deprecated) Subnet that routes to the internet (via a NAT gateway), but not vice versa. |
PUBLIC | Subnet connected to the Internet. |
value__ |
Fields
PRIVATE_ISOLATED
Isolated Subnets do not route traffic to the Internet (in this VPC), and as such, do not require NAT gateways.
public const SubnetType PRIVATE_ISOLATED
Field Value
Type | Description |
---|---|
SubnetType |
Remarks
Isolated subnets can only connect to or be connected to from other instances in the same VPC. A default VPC configuration will not include isolated subnets.
This can be good for subnets with RDS or Elasticache instances, or which route Internet traffic through a peer VPC.
PRIVATE_WITH_EGRESS
Subnet that routes to the internet, but not vice versa.
public const SubnetType PRIVATE_WITH_EGRESS
Field Value
Type | Description |
---|---|
SubnetType |
Remarks
Instances in a private subnet can connect to the Internet, but will not
allow connections to be initiated from the Internet. Egress to the internet will
need to be provided.
NAT Gateway(s) are the default solution to providing this subnet type the ability to route Internet traffic.
If a NAT Gateway is not required or desired, set natGateways:0
or use
SubnetType.PRIVATE_ISOLATED
instead.
By default, a NAT gateway is created in every public subnet for maximum availability. Be aware that you will be charged for NAT gateways.
Normally a Private subnet will use a NAT gateway in the same AZ, but
if natGateways
is used to reduce the number of NAT gateways, a NAT
gateway from another AZ will be used instead.
PRIVATE_WITH_NAT
(deprecated) Subnet that routes to the internet (via a NAT gateway), but not vice versa.
public const SubnetType PRIVATE_WITH_NAT
Field Value
Type | Description |
---|---|
SubnetType |
Remarks
Instances in a private subnet can connect to the Internet, but will not
allow connections to be initiated from the Internet. NAT Gateway(s) are
required with this subnet type to route the Internet traffic through.
If a NAT Gateway is not required or desired, use SubnetType.PRIVATE_ISOLATED
instead.
By default, a NAT gateway is created in every public subnet for maximum availability. Be aware that you will be charged for NAT gateways.
Normally a Private subnet will use a NAT gateway in the same AZ, but
if natGateways
is used to reduce the number of NAT gateways, a NAT
gateway from another AZ will be used instead.
Stability: Deprecated
PUBLIC
Subnet connected to the Internet.
public const SubnetType PUBLIC
Field Value
Type | Description |
---|---|
SubnetType |
Remarks
Instances in a Public subnet can connect to the Internet and can be connected to from the Internet as long as they are launched with public IPs (controlled on the AutoScalingGroup or other constructs that launch instances).
Public subnets route outbound traffic via an Internet Gateway.
value__
public int value__
Field Value
Type | Description |
---|---|
System.Int32 |