github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/aws/d/security_group.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_security_group" 4 sidebar_current: "docs-aws-datasource-security-group" 5 description: |- 6 Provides details about a specific Security Group 7 --- 8 9 # aws\_security\_group 10 11 `aws_security_group` provides details about a specific Security Group. 12 13 This resource can prove useful when a module accepts a Security Group id as 14 an input variable and needs to, for example, determine the id of the 15 VPC that the security group belongs to. 16 17 ## Example Usage 18 19 The following example shows how one might accept a Security Group id as a variable 20 and use this data source to obtain the data necessary to create a subnet. 21 22 ``` 23 variable "security_group_id" {} 24 25 data "aws_security_group" "selected" { 26 id = "${var.security_group}" 27 } 28 29 resource "aws_subnet" "subnet" { 30 vpc_id = "${data.aws_security_group.selected.vpc_id}" 31 cidr_block = "10.0.1.0/24" 32 } 33 ``` 34 35 ## Argument Reference 36 37 The arguments of this data source act as filters for querying the available 38 security group in the current region. The given filters must match exactly one 39 security group whose data will be exported as attributes. 40 41 42 * `filter` - (Optional) Custom filter block as described below. 43 44 * `id` - (Optional) The id of the specific security group to retrieve. 45 46 * `name` - (Optional) The name that the desired security group must have. 47 48 * `tags` - (Optional) A mapping of tags, each pair of which must exactly match 49 a pair on the desired security group. 50 51 * `vpc_id` - (Optional) The id of the VPC that the desired security group belongs to. 52 53 More complex filters can be expressed using one or more `filter` sub-blocks, 54 which take the following arguments: 55 56 * `name` - (Required) The name of the field to filter by, as defined by 57 [the underlying AWS API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSecurityGroups.html). 58 59 * `values` - (Required) Set of values that are accepted for the given field. 60 A Security Group will be selected if any one of the given values matches. 61 62 ## Attributes Reference 63 64 All of the argument attributes except `filter` blocks are also exported as 65 result attributes. This data source will complete the data by populating 66 any fields that are not included in the configuration with the data for 67 the selected Security Group. 68 Additionally, the `description` attribute is exported. 69 70 ~> **Note:** The [default security group for a VPC](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_SecurityGroups.html#DefaultSecurityGroup) has the name `default`.