Skip to content

Commit

Permalink
docs/data-source/aws_subnet: Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Feb 18, 2021
1 parent e7fa342 commit d20246e
Showing 1 changed file with 32 additions and 50 deletions.
82 changes: 32 additions & 50 deletions website/docs/d/subnet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ description: |-

`aws_subnet` provides details about a specific VPC subnet.

This resource can prove useful when a module accepts a subnet id as
an input variable and needs to, for example, determine the id of the
VPC that the subnet belongs to.
This resource can prove useful when a module accepts a subnet ID as an input variable and needs to, for example, determine the ID of the VPC that the subnet belongs to.

## Example Usage

The following example shows how one might accept a subnet id as a variable
and use this data source to obtain the data necessary to create a security
group that allows connections from hosts in that subnet.
The following example shows how one might accept a subnet id as a variable and use this data source to obtain the data necessary to create a security group that allows connections from hosts in that subnet.

```hcl
variable "subnet_id" {}
Expand All @@ -39,67 +35,53 @@ resource "aws_security_group" "subnet" {
}
```

## Argument Reference

The arguments of this data source act as filters for querying the available
subnets in the current region. The given filters must match exactly one
subnet whose data will be exported as attributes.
### Filter Example

* `availability_zone` - (Optional) The availability zone where the
subnet must reside.

* `availability_zone_id` - (Optional) The ID of the Availability Zone for the subnet.
If you want to match against tag `Name`, use:

* `cidr_block` - (Optional) The cidr block of the desired subnet.
```hcl
data "aws_subnet" "selected" {
filter {
name = "tag:Name"
values = ["yakdriver"]
}
}
```

* `ipv6_cidr_block` - (Optional) The Ipv6 cidr block of the desired subnet
## Argument Reference

* `default_for_az` - (Optional) Boolean constraint for whether the desired
subnet must be the default subnet for its associated availability zone.
The arguments of this data source act as filters for querying the available subnets in the current region. The given filters must match exactly one subnet whose data will be exported as attributes.

* `filter` - (Optional) Custom filter block as described below.
The following arguments are optional:

* `availability_zone` - (Optional) The availability zone where the subnet must reside.
* `availability_zone_id` - (Optional) The ID of the Availability Zone for the subnet.
* `cidr_block` - (Optional) The cidr block of the desired subnet.
* `default_for_az` - (Optional) Boolean constraint for whether the desired subnet must be the default subnet for its associated availability zone.
* `filter` - (Optional) Configuration block. Detailed below.
* `id` - (Optional) The id of the specific subnet to retrieve.

* `ipv6_cidr_block` - (Optional) The Ipv6 cidr block of the desired subnet
* `state` - (Optional) The state that the desired subnet must have.

* `tags` - (Optional) A map of tags, each pair of which must exactly match
a pair on the desired subnet.

* `tags` - (Optional) A map of tags, each pair of which must exactly match a pair on the desired subnet.
* `vpc_id` - (Optional) The id of the VPC that the desired subnet belongs to.

More complex filters can be expressed using one or more `filter` sub-blocks,
which take the following arguments:
### filter

* `name` - (Required) The name of the field to filter by, as defined by
[the underlying AWS API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html).
For example, if matching against tag `Name`, use:
This block allows for complex filters. You can use one or more `filter` blocks.

```hcl
data "aws_subnet" "selected" {
filter {
name = "tag:Name"
values = [""] # insert value here
}
}
```
The following arguments are required:

* `values` - (Required) Set of values that are accepted for the given field.
A subnet will be selected if any one of the given values matches.
* `name` - (Required) The name of the field to filter by, as defined by [the underlying AWS API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html).
* `values` - (Required) Set of values that are accepted for the given field. A subnet will be selected if any one of the given values matches.

## Attributes Reference

All of the argument attributes except `filter` blocks are also exported as
result attributes. This data source will complete the data by populating
any fields that are not included in the configuration with the data for
the selected subnet.

In addition the following attributes are exported:
In addition to the attributes above, the following attributes are exported:

* `arn` - The ARN of the subnet.
* `arn` - ARN of the subnet.
* `available_ip_address_count` - Available IP addresses of the subnet.
* `customer_owned_ipv4_pool` - Identifier of customer owned IPv4 address pool.
* `map_customer_owned_ip_on_launch` - Whether customer owned IP addresses are assigned on network interface creation.
* `map_public_ip_on_launch` - Whether public IP addresses are assigned on instance launch.
* `available_ip_address_count` - The available IP addresses of the subnet.
* `owner_id` - The ID of the AWS account that owns the subnet.
* `outpost_arn` - The Amazon Resource Name (ARN) of the Outpost.
* `outpost_arn` - ARN of the Outpost.
* `owner_id` - ID of the AWS account that owns the subnet.

0 comments on commit d20246e

Please sign in to comment.