github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/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 ``` 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 * `access_logs` - (Optional) An Access Logs block. Access Logs documented below. 77 * `availability_zones` - (Required for an EC2-classic ELB) The AZ's to serve traffic in. 78 * `security_groups` - (Optional) A list of security group IDs to assign to the ELB. 79 Only valid if creating an ELB within a VPC 80 * `subnets` - (Required for a VPC ELB) A list of subnet IDs to attach to the ELB. 81 * `instances` - (Optional) A list of instance ids to place in the ELB pool. 82 * `internal` - (Optional) If true, ELB will be an internal ELB. 83 * `listener` - (Required) A list of listener blocks. Listeners documented below. 84 * `health_check` - (Optional) A health_check block. Health Check documented below. 85 * `cross_zone_load_balancing` - (Optional) Enable cross-zone load balancing. Default: `true` 86 * `idle_timeout` - (Optional) The time in seconds that the connection is allowed to be idle. Default: `60` 87 * `connection_draining` - (Optional) Boolean to enable connection draining. Default: `false` 88 * `connection_draining_timeout` - (Optional) The time in seconds to allow for connections to drain. Default: `300` 89 * `tags` - (Optional) A mapping of tags to assign to the resource. 90 91 Exactly one of `availability_zones` or `subnets` must be specified: this 92 determines if the ELB exists in a VPC or in EC2-classic. 93 94 Access Logs (`access_logs`) support the following: 95 96 * `bucket` - (Required) The S3 bucket name to store the logs in. 97 * `bucket_prefix` - (Optional) The S3 bucket prefix. Logs are stored in the root if not configured. 98 * `interval` - (Optional) The publishing interval in minutes. Default: 60 minutes. 99 * `enabled` - (Optional) Boolean to enable / disable `access_logs`. Default is `true` 100 101 Listeners (`listener`) support the following: 102 103 * `instance_port` - (Required) The port on the instance to route to 104 * `instance_protocol` - (Required) The protocol to use to the instance. Valid 105 values are `HTTP`, `HTTPS`, `TCP`, or `SSL` 106 * `lb_port` - (Required) The port to listen on for the load balancer 107 * `lb_protocol` - (Required) The protocol to listen on. Valid values are `HTTP`, 108 `HTTPS`, `TCP`, or `SSL` 109 * `ssl_certificate_id` - (Optional) The ARN of an SSL certificate you have 110 uploaded to AWS IAM. **Note ECDSA-specific restrictions below. Only valid when `lb_protocol` is either HTTPS or SSL** 111 112 Health Check (`health_check`) supports the following: 113 114 * `healthy_threshold` - (Required) The number of checks before the instance is declared healthy. 115 * `unhealthy_threshold` - (Required) The number of checks before the instance is declared unhealthy. 116 * `target` - (Required) The target of the check. Valid pattern is "${PROTOCOL}:${PORT}${PATH}", where PROTOCOL 117 values are: 118 * `HTTP`, `HTTPS` - PORT and PATH are required 119 * `TCP`, `SSL` - PORT is required, PATH is not supported 120 * `interval` - (Required) The interval between checks. 121 * `timeout` - (Required) The length of time before the check times out. 122 123 ## Note on ECDSA Key Algorithm 124 125 If the ARN of the `ssl_certificate_id` that is pointed to references a 126 certificate that was signed by an ECDSA key, note that ELB only supports the 127 P256 and P384 curves. Using a certificate signed by a key using a different 128 curve could produce the error `ERR_SSL_VERSION_OR_CIPHER_MISMATCH` in your 129 browser. 130 131 ## Attributes Reference 132 133 The following attributes are exported: 134 135 * `id` - The name of the ELB 136 * `name` - The name of the ELB 137 * `dns_name` - The DNS name of the ELB 138 * `instances` - The list of instances in the ELB 139 * `source_security_group` - The name of the security group that you can use as 140 part of your inbound rules for your load balancer's back-end application 141 instances. Use this for Classic or Default VPC only. 142 * `source_security_group_id` - The ID of the security group that you can use as 143 part of your inbound rules for your load balancer's back-end application 144 instances. Only available on ELBs launched in a VPC. 145 * `zone_id` - The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record) 146 147 ## Import 148 149 ELBs can be imported using the `name`, e.g. 150 151 ``` 152 $ terraform import aws_elb.bar elb-production-12345 153 ```