> **Experimental**
>
> `@aws-cdk/aws-ec2-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# SubnetV2Props

Properties to define subnet for VPC.

Extends: SubnetV2Props
Used as props by: SubnetV2

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/subnet-v2.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0-alpha.0/packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts#L59)

## Example

```ts
const myVpc = new VpcV2(this, 'Vpc');
const routeTable = new RouteTable(this, 'RouteTable', {
  vpc: myVpc,
});
const subnet = new SubnetV2(this, 'Subnet', {
  vpc: myVpc,
  availabilityZone: 'eu-west-2a',
  ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
  subnetType: SubnetType.PRIVATE_ISOLATED });

const natgw = new NatGateway(this, 'NatGW', {
  subnet: subnet,
  vpc: myVpc,
  connectivityType: NatConnectivityType.PRIVATE,
  privateIpAddress: '10.0.0.42',
});
new Route(this, 'NatGwRoute', {
  routeTable,
  destination: '0.0.0.0/0',
  target: { gateway: natgw },
});
```

## Properties

- `assignIpv6AddressOnCreation`: boolean — Indicates whether a network interface created in this subnet receives an IPv6 address.

  **Default:** undefined in case not provided as an input

  If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

- `availabilityZone`: string (required) — Custom AZ for the subnet.

- `defaultRouteTableName`: string — Name of the default RouteTable created by CDK to be used for tagging.

  **Default:** default route table name created by CDK as 'DefaultCDKRouteTable'

- `ipv4CidrBlock`: [IpCidr](/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.IpCidr.html) (required) — ipv4 cidr to assign to this subnet.

  See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-cidrblock

- `ipv6CidrBlock`: [IpCidr](/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.IpCidr.html) — Ipv6 CIDR Range for subnet.

  **Default:** No Ipv6 address

- `mapPublicIpOnLaunch`: boolean — Controls if instances launched into the subnet should be assigned a public IP address.

  **Default:** undefined in case not provided as an input

  This property can only be set for public subnets.

- `routeTable`: [IRouteTable](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IRouteTable.html) — Custom Route for subnet.

  **Default:** a default route table created

- `subnetName`: string — Subnet name.

  **Default:** provisioned with an autogenerated name by CDK

- `subnetType`: [SubnetType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetType.html) (required) — The type of Subnet to configure.

  The Subnet type will control the ability to route and connect to the
  Internet.

  TODO: Add validation check `subnetType` when adding resources (e.g. cannot add NatGateway to private)

- `vpc`: [IVpcV2](/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.IVpcV2.html) (required) — VPC Prop.
