github.com/tarrant/terraform@v0.3.8-0.20150402012457-f68c9eee638e/website/source/docs/providers/aws/r/security_group.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_security_group" 4 sidebar_current: "docs-aws-resource-security-group" 5 description: |- 6 Provides an security group resource. 7 --- 8 9 # aws\_security\_group 10 11 Provides an security group resource. 12 13 ## Example Usage 14 15 Basic usage 16 17 ``` 18 resource "aws_security_group" "allow_all" { 19 name = "allow_all" 20 description = "Allow all inbound traffic" 21 22 ingress { 23 from_port = 0 24 to_port = 65535 25 protocol = "-1" 26 cidr_blocks = ["0.0.0.0/0"] 27 } 28 29 egress { 30 from_port = 0 31 to_port = 65535 32 protocol = "-1" 33 cidr_blocks = ["0.0.0.0/0"] 34 } 35 } 36 ``` 37 38 Basic usage with tags: 39 40 ``` 41 resource "aws_security_group" "allow_all" { 42 name = "allow_all" 43 description = "Allow all inbound traffic" 44 45 ingress { 46 from_port = 0 47 to_port = 65535 48 protocol = "tcp" 49 cidr_blocks = ["0.0.0.0/0"] 50 } 51 52 tags { 53 Name = "allow_all" 54 } 55 } 56 ``` 57 58 ## Argument Reference 59 60 The following arguments are supported: 61 62 * `name` - (Required) The name of the security group 63 * `description` - (Required) The security group description. 64 * `ingress` - (Optional) Can be specified multiple times for each 65 ingress rule. Each ingress block supports fields documented below. 66 * `egress` - (Optional) Can be specified multiple times for each 67 egress rule. Each egress block supports fields documented below. 68 VPC only. 69 * `vpc_id` - (Optional) The VPC ID. 70 * `owner_id` - (Optional) The AWS Owner ID. 71 72 The `ingress` block supports: 73 74 * `cidr_blocks` - (Optional) List of CIDR blocks. Cannot be used with `security_groups`. 75 * `from_port` - (Required) The start port. 76 * `protocol` - (Required) The protocol. 77 * `security_groups` - (Optional) List of security group IDs. Cannot be used with `cidr_blocks`. 78 * `self` - (Optional) If true, the security group itself will be added as 79 a source to this ingress rule. 80 * `to_port` - (Required) The end range port. 81 * `tags` - (Optional) A mapping of tags to assign to the resource. 82 83 The `egress` block supports: 84 85 * `cidr_blocks` - (Optional) List of CIDR blocks. Cannot be used with `security_groups`. 86 * `from_port` - (Required) The start port. 87 * `protocol` - (Required) The protocol. 88 * `security_groups` - (Optional) List of security group IDs. Cannot be used with `cidr_blocks`. 89 * `self` - (Optional) If true, the security group itself will be added as 90 a source to this egress rule. 91 * `to_port` - (Required) The end range port. 92 * `tags` - (Optional) A mapping of tags to assign to the resource. 93 94 ## Attributes Reference 95 96 The following attributes are exported: 97 98 * `id` - The ID of the security group 99 * `vpc_id` - The VPC ID. 100 * `owner_id` - The owner ID. 101 * `name` - The name of the security group 102 * `description` - The description of the security group 103 * `ingress` - The ingress rules. See above for more. 104 * `egress` - The egress rules. See above for more.