Skip to content

rackspace-infrastructure-automation/aws-terraform-clb

Repository files navigation

aws-terraform-clb

This module creates a Classic Load Balancer also called ELB. Not to be confused with NLB or ALB which are preferred.

Basic Usage

module "clb" {
  source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb//?ref=v0.12.0"

  name            = "<name>"
  instances       = ["i-01", "i-02"]
  instances_count = 2
  security_groups = ["sg-01", "sg-02"]
  subnets         = ["subnet-01", "subnet-02"]

  tags = {
    Right = "Said"
  }

  listeners = [
    {
      instance_port     = 8000
      instance_protocol = "HTTP"
      lb_port           = 80
      lb_protocol       = "HTTP"
    },
  ]
}

Full working references are available at examples

Other TF Modules Used

Using aws-terraform-cloudwatch_alarm to create the following CloudWatch Alarms:

  • unhealthy_host_count_alarm

Requirements

Name Version
terraform >= 0.12
aws >= 2.7.0

Providers

Name Version
aws >= 2.7.0

Modules

Name Source Version
unhealthy_host_count_alarm git@github.com:rackspace-infrastructure-automation/aws-terraform-cloudwatch_alarm//?ref=v0.12.6

Resources

Name
aws_app_cookie_stickiness_policy
aws_autoscaling_attachment
aws_caller_identity
aws_elb
aws_elb_attachment
aws_elb_service_account
aws_iam_policy_document
aws_lb_cookie_stickiness_policy
aws_region
aws_route53_record
aws_s3_bucket
aws_s3_bucket_policy

Inputs

Name Description Type Default Required
app_cookie_name The application cookie whose lifetime the ELB's cookie should follow. Only used if stickiness is set to application. string "" no
app_cookie_stickiness_policy_name Name for App Cookie Stickiness policy. Only alphanumeric characters and hyphens allowed. Only used if stickiness is set to application. string "" no
app_cookie_stickiness_port The load balancer port to which the policy should be applied. This must be an active listener on the load balancer. Only used if stickiness is set to application. string "" no
asg_target Name of ASG to associate with the ELB. Leave blank if you are using this in combination with the EC2_ASG module, passing the output of this module to the EC2_ASG module. Leave blank if attached instances are not in an ASG. string "" no
connection_draining Boolean to enable connection draining. i.e. true | false bool false no
connection_draining_timeout Set the timeout value for elastic loadbalancer draining policy if desired. number 300 no
cookie_expiration_period The time period after which the session cookie should be considered stale, expressed in seconds. Only used for load_balancer stickiness. string "" no
create_internal_record Create Route53 Internal Record. i.e. true | false bool false no
create_logging_bucket Create a new S3 logging bucket. i.e. true | false bool true no
cross_zone Whether cross-zone load balancing is enabled for the load balancer. i.e. true | false bool true no
environment Application environment for which this network is being created from string "Development" no
health_check_interval Seconds between health checks. number 30 no
health_check_target Protocol & port check on instance. Valid pattern is :, where PROTOCOL values areTCP:5000 | SSL:5000 || HTTP(S) = HTTP:80/path/to/my/file. string "HTTP:80/" no
health_check_threshold Consecutive successful checks before marking instance healthy. number 3 no
health_check_timeout Number of seconds during which no response means a failed health probe. number 5 no
health_check_unhealthy_threshold Consecutive failed checks before marking instance unhealthy. number 3 no
idle_timeout The time (in seconds) that a connection to the load balancer can remain idle, which means no data is sent over the connection. After the specified time, the load balancer closes the connection. Value from 1 - 4000 number 60 no
instances A list of EC2 instance IDs for the load balancer. Use when not assigned to auto scale group. i.e. ['i-0806906515f952316', 'i-0806906515f952316', 'i-0806906515f952316'] list(string) [] no
instances_count Total number of individual instances to attach to this CLB. Must match actual count of the instances parameter. number 0 no
internal_loadbalancer If true, CLB will be an internal CLB. bool false no
internal_record_name Record Name for the new Resource Record in the Internal Hosted Zone string "" no
internal_zone_id The Route53 Internal Hosted Zone ID string "" no
internal_zone_name TLD for Internal Hosted Zone string "" no
lb_cookie_stickiness_policy_name Name for LB Cookie Stickiness policy. Only alphanumeric characters and hyphens allowed. Only used if stickiness is set to load_balancer. string "" no
lb_cookie_stickiness_port The load balancer port to which the policy should be applied. This must be an active listener on the load balancer. Only used if stickiness is set to load_balancer. string "" no
listeners List of Maps describing the LB options including instance_port (The port on the instance to route to), instance_protocol (The protocol to use to the instance: HTTP, HTTPS, TCP, SSL), lb_port (The port to listen on for the load balancer), lb_protocol (The protocol to listen on. Valid values are HTTP, HTTPS, TCP, or SSL), ssl_certificate_id (The ARN of an SSL certificate you have uploaded to AWS IAM. Only valid when lb_protocol is either HTTPS or SSL) list(map(string)) [] no
logging_bucket_access_control Define ACL for Bucket from one of the canned ACL: private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, bucket-owner-full-control, log-delivery-write string "private" no
logging_bucket_encryption Enable default bucket encryption. i.e. disabled | AES256 | aws:kms string "AES256" no
logging_bucket_force_destroy Whether all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. ie. true bool false no
logging_bucket_kms_key_id The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. string "" no
logging_bucket_log_interval The publishing interval in minutes. number 60 no
logging_bucket_name The number of days to retain load balancer logs. Parameter is ignored if not creating a new S3 bucket. string "" no
logging_bucket_prefix The prefix for the location in the S3 bucket. If you don't specify a prefix, the access logs are stored in the root of the bucket. string "FrontendCLBLogs" no
logging_bucket_retention The number of days to retain load balancer logs. Parameter is ignored if not creating a new S3 bucket. number 14 no
name This name must be unique within your set of load balancers for the region. string n/a yes
notification_topic List of SNS Topic ARNs to use for customer notifications. list(string) [] no
rackspace_alarms_enabled Specifies whether alarms will create a Rackspace ticket. Ignored if rackspace_managed is set to false. bool false no
rackspace_managed Boolean parameter controlling if instance will be fully managed by Rackspace support teams, created CloudWatch alarms that generate tickets, and utilize Rackspace managed SSM documents. bool true no
security_groups A list of EC2 security groups to assign to this resource. list(string) n/a yes
stickiness_type Disable stickiness by using none or use load_balancer for enabling Enable load balancer generated cookie stickiness or use application for enabling application generated cookie stickiness. i.e. none | load_balancer | application string "none" no
subnets A list of subnet IDs to attach to the ELB. list(string) n/a yes
tags Map of tags you would like to add to the instance. i.e. {Key='Value'} map(string) {} no

Outputs

Name Description
clb_arn ARN of the ELB.
clb_dns_name The DNS name of the ELB.
clb_instances The list of instances in the ELB.
clb_source_security_group The name of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances. Use this for Classic or Default VPC only.
clb_source_security_group_id The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances. Only available on ELBs launched in a VPC.
clb_zone_id The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record)
name The name of the ELB.