github.com/cbroglie/terraform@v0.7.0-rc3.0.20170410193827-735dfc416d46/website/source/docs/providers/aws/d/subnet_ids.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_subnet_ids"
     4  sidebar_current: "docs-aws-datasource-subnet-ids"
     5  description: |-
     6      Provides a list of subnet Ids for a VPC
     7  ---
     8  
     9  # aws\_subnet\_ids
    10  
    11  `aws_subnet_ids` provides a list of ids for a vpc_id
    12  
    13  This resource can be useful for getting back a list of subnet ids for a vpc.
    14  
    15  ## Example Usage
    16  
    17  The following shows outputing all cidr blocks for every subnet id in a vpc.
    18  
    19  ```hcl
    20  data "aws_subnet_ids" "example" {
    21    vpc_id = "${var.vpc_id}"
    22  }
    23  
    24  data "aws_subnet" "example" {
    25    count = "${length(data.aws_subnet_ids.example.ids)}"
    26    id = "${aws_subnet_ids.example.ids[count.index]}"
    27  }
    28  
    29  output "subnet_cidr_blocks" {
    30    value = ["${data.aws_subnet.example.*.cidr_block}"]
    31  }
    32  ```
    33  
    34  ## Argument Reference
    35  
    36  * `vpc_id` - (Required) The VPC ID that you want to filter from.
    37  
    38  ## Attributes Reference
    39  
    40  * `ids` - Is a list of all the subnet ids found. If none found. This data source will fail out.