github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/aws/r/alb.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_alb" 4 sidebar_current: "docs-aws-resource-alb" 5 description: |- 6 Provides an Application Load Balancer resource. 7 --- 8 9 # aws\_alb 10 11 Provides an Application Load Balancer resource. 12 13 The official AWS CLI calls this "elbv2" while their documentation calls it 14 an Application Load Balancer. Terraform uses "ALB" but they mean the same 15 thing. 16 17 ## Example Usage 18 19 ```hcl 20 # Create a new load balancer 21 resource "aws_alb" "test" { 22 name = "test-alb-tf" 23 internal = false 24 security_groups = ["${aws_security_group.alb_sg.id}"] 25 subnets = ["${aws_subnet.public.*.id}"] 26 27 enable_deletion_protection = true 28 29 access_logs { 30 bucket = "${aws_s3_bucket.alb_logs.bucket}" 31 prefix = "test-alb" 32 } 33 34 tags { 35 Environment = "production" 36 } 37 } 38 ``` 39 40 ## Argument Reference 41 42 The following arguments are supported: 43 44 * `name` - (Optional) The name of the ALB. This name must be unique within your AWS account, can have a maximum of 32 characters, 45 must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen. If not specified, 46 Terraform will autogenerate a name beginning with `tf-lb`. 47 * `name_prefix` - (Optional) Creates a unique name beginning with the specified prefix. Conflicts with `name`. 48 * `internal` - (Optional) If true, the ALB will be internal. 49 * `security_groups` - (Optional) A list of security group IDs to assign to the ALB. 50 * `access_logs` - (Optional) An Access Logs block. Access Logs documented below. 51 * `subnets` - (Required) A list of subnet IDs to attach to the ALB. 52 * `idle_timeout` - (Optional) The time in seconds that the connection is allowed to be idle. Default: 60. 53 * `enable_deletion_protection` - (Optional) If true, deletion of the load balancer will be disabled via 54 the AWS API. This will prevent Terraform from deleting the load balancer. Defaults to `false`. 55 * `ip_address_type` - (Optional) The type of IP addresses used by the subnets for your load balancer. The possible values are `ipv4` and `dualstack` 56 * `tags` - (Optional) A mapping of tags to assign to the resource. 57 58 ~> **NOTE::** Please note that internal ALBs can only use `ipv4` as the ip_address_type. You can only change to `dualstack` ip_address_type if the selected subnets are IPv6 enabled. 59 60 Access Logs (`access_logs`) support the following: 61 62 * `bucket` - (Required) The S3 bucket name to store the logs in. 63 * `prefix` - (Optional) The S3 bucket prefix. Logs are stored in the root if not configured. 64 * `enabled` = (Optional) Boolean to enable / disable `access_logs`. Default is `true` 65 66 ## Attributes Reference 67 68 The following attributes are exported in addition to the arguments listed above: 69 70 * `id` - The ARN of the load balancer (matches `arn`). 71 * `arn` - The ARN of the load balancer (matches `id`). 72 * `arn_suffix` - The ARN suffix for use with CloudWatch Metrics. 73 * `dns_name` - The DNS name of the load balancer. 74 * `canonical_hosted_zone_id` - The canonical hosted zone ID of the load balancer. 75 * `zone_id` - The canonical hosted zone ID of the load balancer (to be used in a Route 53 Alias record). 76 77 ## Import 78 79 ALBs can be imported using their ARN, e.g. 80 81 ``` 82 $ terraform import aws_alb.bar arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 83 ```