github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/aws/r/elb.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_elb" 4 sidebar_current: "docs-aws-resource-elb" 5 description: |- 6 Provides an Elastic Load Balancer resource. 7 --- 8 9 # aws\_elb 10 11 Provides an Elastic Load Balancer resource, also known as a "Classic 12 Load Balancer" after the release of 13 [Application Load Balancers](/docs/providers/aws/r/alb.html). 14 15 ~> **NOTE on ELB Instances and ELB Attachments:** Terraform currently 16 provides both a standalone [ELB Attachment resource](elb_attachment.html) 17 (describing an instance attached to an ELB), and an ELB resource with 18 `instances` defined in-line. At this time you cannot use an ELB with in-line 19 instances in conjunction with a ELB Attachment resources. Doing so will cause a 20 conflict and will overwrite attachments. 21 22 ## Example Usage 23 24 ```hcl 25 # Create a new load balancer 26 resource "aws_elb" "bar" { 27 name = "foobar-terraform-elb" 28 availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] 29 30 access_logs { 31 bucket = "foo" 32 bucket_prefix = "bar" 33 interval = 60 34 } 35 36 listener { 37 instance_port = 8000 38 instance_protocol = "http" 39 lb_port = 80 40 lb_protocol = "http" 41 } 42 43 listener { 44 instance_port = 8000 45 instance_protocol = "http" 46 lb_port = 443 47 lb_protocol = "https" 48 ssl_certificate_id = "arn:aws:iam::123456789012:server-certificate/certName" 49 } 50 51 health_check { 52 healthy_threshold = 2 53 unhealthy_threshold = 2 54 timeout = 3 55 target = "HTTP:8000/" 56 interval = 30 57 } 58 59 instances = ["${aws_instance.foo.id}"] 60 cross_zone_load_balancing = true 61 idle_timeout = 400 62 connection_draining = true 63 connection_draining_timeout = 400 64 65 tags { 66 Name = "foobar-terraform-elb" 67 } 68 } 69 ``` 70 71 ## Argument Reference 72 73 The following arguments are supported: 74 75 * `name` - (Optional) The name of the ELB. By default generated by Terraform. 76 * `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified 77 prefix. Conflicts with `name`. 78 * `access_logs` - (Optional) An Access Logs block. Access Logs documented below. 79 * `availability_zones` - (Required for an EC2-classic ELB) The AZ's to serve traffic in. 80 * `security_groups` - (Optional) A list of security group IDs to assign to the ELB. 81 Only valid if creating an ELB within a VPC 82 * `subnets` - (Required for a VPC ELB) A list of subnet IDs to attach to the ELB. 83 * `instances` - (Optional) A list of instance ids to place in the ELB pool. 84 * `internal` - (Optional) If true, ELB will be an internal ELB. 85 * `listener` - (Required) A list of listener blocks. Listeners documented below. 86 * `health_check` - (Optional) A health_check block. Health Check documented below. 87 * `cross_zone_load_balancing` - (Optional) Enable cross-zone load balancing. Default: `true` 88 * `idle_timeout` - (Optional) The time in seconds that the connection is allowed to be idle. Default: `60` 89 * `connection_draining` - (Optional) Boolean to enable connection draining. Default: `false` 90 * `connection_draining_timeout` - (Optional) The time in seconds to allow for connections to drain. Default: `300` 91 * `tags` - (Optional) A mapping of tags to assign to the resource. 92 93 Exactly one of `availability_zones` or `subnets` must be specified: this 94 determines if the ELB exists in a VPC or in EC2-classic. 95 96 Access Logs (`access_logs`) support the following: 97 98 * `bucket` - (Required) The S3 bucket name to store the logs in. 99 * `bucket_prefix` - (Optional) The S3 bucket prefix. Logs are stored in the root if not configured. 100 * `interval` - (Optional) The publishing interval in minutes. Default: 60 minutes. 101 * `enabled` - (Optional) Boolean to enable / disable `access_logs`. Default is `true` 102 103 Listeners (`listener`) support the following: 104 105 * `instance_port` - (Required) The port on the instance to route to 106 * `instance_protocol` - (Required) The protocol to use to the instance. Valid 107 values are `HTTP`, `HTTPS`, `TCP`, or `SSL` 108 * `lb_port` - (Required) The port to listen on for the load balancer 109 * `lb_protocol` - (Required) The protocol to listen on. Valid values are `HTTP`, 110 `HTTPS`, `TCP`, or `SSL` 111 * `ssl_certificate_id` - (Optional) The ARN of an SSL certificate you have 112 uploaded to AWS IAM. **Note ECDSA-specific restrictions below. Only valid when `lb_protocol` is either HTTPS or SSL** 113 114 Health Check (`health_check`) supports the following: 115 116 * `healthy_threshold` - (Required) The number of checks before the instance is declared healthy. 117 * `unhealthy_threshold` - (Required) The number of checks before the instance is declared unhealthy. 118 * `target` - (Required) The target of the check. Valid pattern is "${PROTOCOL}:${PORT}${PATH}", where PROTOCOL 119 values are: 120 * `HTTP`, `HTTPS` - PORT and PATH are required 121 * `TCP`, `SSL` - PORT is required, PATH is not supported 122 * `interval` - (Required) The interval between checks. 123 * `timeout` - (Required) The length of time before the check times out. 124 125 ## Note on ECDSA Key Algorithm 126 127 If the ARN of the `ssl_certificate_id` that is pointed to references a 128 certificate that was signed by an ECDSA key, note that ELB only supports the 129 P256 and P384 curves. Using a certificate signed by a key using a different 130 curve could produce the error `ERR_SSL_VERSION_OR_CIPHER_MISMATCH` in your 131 browser. 132 133 ## Attributes Reference 134 135 The following attributes are exported: 136 137 * `id` - The name of the ELB 138 * `name` - The name of the ELB 139 * `dns_name` - The DNS name of the ELB 140 * `instances` - The list of instances in the ELB 141 * `source_security_group` - The name of the security group that you can use as 142 part of your inbound rules for your load balancer's back-end application 143 instances. Use this for Classic or Default VPC only. 144 * `source_security_group_id` - The ID of the security group that you can use as 145 part of your inbound rules for your load balancer's back-end application 146 instances. Only available on ELBs launched in a VPC. 147 * `zone_id` - The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record) 148 149 ## Import 150 151 ELBs can be imported using the `name`, e.g. 152 153 ``` 154 $ terraform import aws_elb.bar elb-production-12345 155 ```