2014-07-23 22:32:33 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_subnet"
|
|
|
|
sidebar_current: "docs-aws-resource-subnet"
|
2014-10-22 05:21:56 +02:00
|
|
|
description: |-
|
|
|
|
Provides an VPC subnet resource.
|
2014-07-23 22:32:33 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# aws\_subnet
|
|
|
|
|
|
|
|
Provides an VPC subnet resource.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-17 12:17:54 +02:00
|
|
|
```hcl
|
2014-07-23 22:38:12 +02:00
|
|
|
resource "aws_subnet" "main" {
|
2017-02-18 23:48:50 +01:00
|
|
|
vpc_id = "${aws_vpc.main.id}"
|
|
|
|
cidr_block = "10.0.1.0/24"
|
2014-11-02 21:30:33 +01:00
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
tags {
|
|
|
|
Name = "Main"
|
|
|
|
}
|
2014-07-23 22:32:33 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `availability_zone`- (Optional) The AZ for the subnet.
|
|
|
|
* `cidr_block` - (Required) The CIDR block for the subnet.
|
2017-03-01 17:16:59 +01:00
|
|
|
* `ipv6_cidr_block` - (Optional) The IPv6 network range for the subnet,
|
|
|
|
in CIDR notation. The subnet size must use a /64 prefix length.
|
2014-09-16 16:37:22 +02:00
|
|
|
* `map_public_ip_on_launch` - (Optional) Specify true to indicate
|
|
|
|
that instances launched into the subnet should be assigned
|
2017-03-01 17:16:59 +01:00
|
|
|
a public IP address. Default is `false`.
|
|
|
|
* `assign_ipv6_address_on_creation` - (Optional) Specify true to indicate
|
|
|
|
that network interfaces created in the specified subnet should be
|
|
|
|
assigned an IPv6 address. Default is `false`
|
2014-07-23 22:32:33 +02:00
|
|
|
* `vpc_id` - (Required) The VPC ID.
|
2014-11-02 21:30:33 +01:00
|
|
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
2014-07-23 22:32:33 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `id` - The ID of the subnet
|
|
|
|
* `availability_zone`- The AZ for the subnet.
|
|
|
|
* `cidr_block` - The CIDR block for the subnet.
|
|
|
|
* `vpc_id` - The VPC ID.
|
2017-04-21 15:54:55 +02:00
|
|
|
* `ipv6_association_id` - The association ID for the IPv6 CIDR block.
|
|
|
|
* `ipv6_cidr_block` - The IPv6 CIDR block.
|
2014-07-23 22:32:33 +02:00
|
|
|
|
2016-07-19 18:22:30 +02:00
|
|
|
## Import
|
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
Subnets can be imported using the `subnet id`, e.g.
|
2016-07-19 18:22:30 +02:00
|
|
|
|
|
|
|
```
|
2016-07-21 00:28:59 +02:00
|
|
|
$ terraform import aws_subnet.public_subnet subnet-9d4a7b6c
|
2016-07-19 18:22:30 +02:00
|
|
|
```
|