github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/aws/d/vpc.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_vpc" 4 sidebar_current: "docs-aws-datasource-vpc-x" 5 description: |- 6 Provides details about a specific VPC 7 --- 8 9 # aws\_vpc 10 11 `aws_vpc` provides details about a specific VPC. 12 13 This resource can prove useful when a module accepts a vpc id as 14 an input variable and needs to, for example, determine the CIDR block of that 15 VPC. 16 17 ## Example Usage 18 19 The following example shows how one might accept a VPC id as a variable 20 and use this data source to obtain the data necessary to create a subnet 21 within it. 22 23 ```hcl 24 variable "vpc_id" {} 25 26 data "aws_vpc" "selected" { 27 id = "${var.vpc_id}" 28 } 29 30 resource "aws_subnet" "example" { 31 vpc_id = "${data.aws_vpc.selected.id}" 32 availability_zone = "us-west-2a" 33 cidr_block = "${cidrsubnet(data.aws_vpc.selected.cidr_block, 4, 1)}" 34 } 35 ``` 36 37 ## Argument Reference 38 39 The arguments of this data source act as filters for querying the available 40 VPCs in the current region. The given filters must match exactly one 41 VPC whose data will be exported as attributes. 42 43 * `cidr_block` - (Optional) The cidr block of the desired VPC. 44 45 * `dhcp_options_id` - (Optional) The DHCP options id of the desired VPC. 46 47 * `default` - (Optional) Boolean constraint on whether the desired VPC is 48 the default VPC for the region. 49 50 * `filter` - (Optional) Custom filter block as described below. 51 52 * `id` - (Optional) The id of the specific VPC to retrieve. 53 54 * `state` - (Optional) The current state of the desired VPC. 55 Can be either `"pending"` or `"available"`. 56 57 * `tags` - (Optional) A mapping of tags, each pair of which must exactly match 58 a pair on the desired VPC. 59 60 More complex filters can be expressed using one or more `filter` sub-blocks, 61 which take the following arguments: 62 63 * `name` - (Required) The name of the field to filter by, as defined by 64 [the underlying AWS API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html). 65 66 * `values` - (Required) Set of values that are accepted for the given field. 67 A VPC will be selected if any one of the given values matches. 68 69 ## Attributes Reference 70 71 All of the argument attributes except `filter` blocks are also exported as 72 result attributes. This data source will complete the data by populating 73 any fields that are not included in the configuration with the data for 74 the selected VPC. 75 76 The following attribute is additionally exported: 77 78 * `instance_tenancy` - The allowed tenancy of instances launched into the 79 selected VPC. May be any of `"default"`, `"dedicated"`, or `"host"`. 80 81 * `ipv6_association_id` - The association ID for the IPv6 CIDR block. 82 83 * `ipv6_cidr_block` - The IPv6 CIDR block.