# SubnetAttributes

Used as argument in: [Subnet.fromSubnetAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Subnet.html#fromsubnetattributes)

- Source: [`aws-ec2/lib/vpc.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts#L919)

## Example

TypeScript:

```ts
// Supply all properties
const subnet1 = ec2.Subnet.fromSubnetAttributes(this, 'SubnetFromAttributes', {
  subnetId: 's-1234',
  availabilityZone: 'pub-az-4465',
  routeTableId: 'rt-145'
});

// Supply only subnet id
const subnet2 = ec2.Subnet.fromSubnetId(this, 'SubnetFromId', 's-1234');
```

Python:

```python
# Supply all properties
subnet1 = ec2.Subnet.from_subnet_attributes(self, "SubnetFromAttributes",
    subnet_id="s-1234",
    availability_zone="pub-az-4465",
    route_table_id="rt-145"
)

# Supply only subnet id
subnet2 = ec2.Subnet.from_subnet_id(self, "SubnetFromId", "s-1234")
```

Java:

```java
// Supply all properties
ISubnet subnet1 = Subnet.fromSubnetAttributes(this, "SubnetFromAttributes", SubnetAttributes.builder()
        .subnetId("s-1234")
        .availabilityZone("pub-az-4465")
        .routeTableId("rt-145")
        .build());

// Supply only subnet id
ISubnet subnet2 = Subnet.fromSubnetId(this, "SubnetFromId", "s-1234");
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Supply all properties
var subnet1 = Subnet.FromSubnetAttributes(this, "SubnetFromAttributes", new SubnetAttributes {
    SubnetId = "s-1234",
    AvailabilityZone = "pub-az-4465",
    RouteTableId = "rt-145"
});

// Supply only subnet id
var subnet2 = Subnet.FromSubnetId(this, "SubnetFromId", "s-1234");
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Supply all properties
subnet1 := ec2.Subnet_FromSubnetAttributes(this, jsii.String("SubnetFromAttributes"), &SubnetAttributes{
	SubnetId: jsii.String("s-1234"),
	AvailabilityZone: jsii.String("pub-az-4465"),
	RouteTableId: jsii.String("rt-145"),
})

// Supply only subnet id
subnet2 := ec2.Subnet_FromSubnetId(this, jsii.String("SubnetFromId"), jsii.String("s-1234"))
```

## Properties

- `availabilityZone`: string — The Availability Zone the subnet is located in.

  **Default:** No AZ information, cannot use AZ selection features

- `ipv4CidrBlock`: string — The IPv4 CIDR block associated with the subnet.

  **Default:** No CIDR information, cannot use CIDR filter features

- `routeTableId`: string — The ID of the route table for this particular subnet.

  **Default:** No route table information, cannot create VPC endpoints

- `subnetId`: string (required) — The subnetId for this particular subnet.
