github.com/nicgrayson/terraform@v0.4.3-0.20150415203910-c4de50829380/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  * `tags` - (Optional) A mapping of tags to assign to the resource.
    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 Group Names if using
    78      EC2-Classic or the default VPC, or Group IDs if using a non-default VPC.
    79      Cannot be used with `cidr_blocks`.
    80  * `self` - (Optional) If true, the security group itself will be added as
    81       a source to this ingress rule.
    82  * `to_port` - (Required) The end range port.
    83  
    84  The `egress` block supports:
    85  
    86  * `cidr_blocks` - (Optional) List of CIDR blocks. Cannot be used with `security_groups`.
    87  * `from_port` - (Required) The start port.
    88  * `protocol` - (Required) The protocol.
    89  * `security_groups` - (Optional) List of security group Group Names if using
    90      EC2-Classic or the default VPC, or Group IDs if using a non-default VPC.
    91      Cannot be used with `cidr_blocks`.
    92  * `self` - (Optional) If true, the security group itself will be added as
    93       a source to this egress rule.
    94  * `to_port` - (Required) The end range port.
    95  
    96  ## Attributes Reference
    97  
    98  The following attributes are exported:
    99  
   100  * `id` - The ID of the security group
   101  * `vpc_id` - The VPC ID.
   102  * `owner_id` - The owner ID.
   103  * `name` - The name of the security group
   104  * `description` - The description of the security group
   105  * `ingress` - The ingress rules. See above for more.
   106  * `egress` - The egress rules. See above for more.