# SubnetProps

Specify configuration parameters for a VPC subnet.

Extends: SubnetProps
Used as props by: Subnet

- Source: [`aws-ec2/lib/vpc.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts#L2091)
- Type last changed: v2.121.0 · 12 Jan 2024

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const subnetProps: ec2.SubnetProps = {
  availabilityZone: 'availabilityZone',
  cidrBlock: 'cidrBlock',
  vpcId: 'vpcId',

  // the properties below are optional
  assignIpv6AddressOnCreation: false,
  ipv6CidrBlock: 'ipv6CidrBlock',
  mapPublicIpOnLaunch: false,
};
```

## Properties

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

  If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

- `availabilityZone`: string (required) — The availability zone for the subnet.

- `cidrBlock`: string (required) — The CIDR notation for this subnet.

- `ipv6CidrBlock`: string — The IPv6 CIDR block.

  **Default:** no IPv6 CIDR block.

  If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.

- `mapPublicIpOnLaunch`: boolean — Controls if a public IP is associated to an instance at launch.

  **Default:** true in Subnet.Public, false in Subnet.Private or Subnet.Isolated.

- `vpcId`: string (required) — The VPC which this subnet is part of.
