From 7c67cc9e4036a0082971ca1296dedd67b20dadbb Mon Sep 17 00:00:00 2001 From: Sarkis Varozian Date: Fri, 15 Jun 2018 12:49:52 -0700 Subject: [PATCH] fix typo (#3) * fix typo in variable block * fix booleans in count * fix listener_arns output * excplicitly add types to variables --- main.tf | 17 ++++++++--------- outputs.tf | 2 +- variables.tf | 28 ++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/main.tf b/main.tf index 085be72..53c09c7 100644 --- a/main.tf +++ b/main.tf @@ -10,10 +10,9 @@ module "default_label" { resource "aws_security_group" "default" { description = "Controls access to the ALB (HTTP/HTTPS)" - - vpc_id = "${var.vpc_id}" - name = "${module.default_label.id}" - tags = "${module.default_label.tags}" + vpc_id = "${var.vpc_id}" + name = "${module.default_label.id}" + tags = "${module.default_label.tags}" } resource "aws_security_group_rule" "egress" { @@ -26,7 +25,7 @@ resource "aws_security_group_rule" "egress" { } resource "aws_security_group_rule" "http_ingress" { - count = "${var.http_enabled}" + count = "${var.http_enabled == "true" ? 1 : 0}" type = "ingress" from_port = "${var.http_port}" to_port = "${var.http_port}" @@ -37,7 +36,7 @@ resource "aws_security_group_rule" "http_ingress" { } resource "aws_security_group_rule" "https_ingress" { - count = "${var.https_enabled}" + count = "${var.https_enabled == "true" ? 1 : 0}" type = "ingress" from_port = "${var.https_port}" to_port = "${var.https_port}" @@ -48,7 +47,7 @@ resource "aws_security_group_rule" "https_ingress" { } module "access_logs" { - source = "git::https://github.com/cloudposse/terraform-aws-lb-s3-bucket.git?ref=init" + source = "git::https://github.com/cloudposse/terraform-aws-lb-s3-bucket.git?ref=tags/0.1.0" attributes = "${var.attributes}" delimiter = "${var.delimiter}" name = "${var.name}" @@ -111,7 +110,7 @@ resource "aws_lb_target_group" "default" { } resource "aws_lb_listener" "http" { - count = "${var.http_enabled}" + count = "${var.http_enabled == "true" ? 1 : 0}" load_balancer_arn = "${aws_lb.default.arn}" port = "${var.http_port}" protocol = "HTTP" @@ -123,7 +122,7 @@ resource "aws_lb_listener" "http" { } resource "aws_lb_listener" "https" { - count = "${var.https_enabled}" + count = "${var.https_enabled == "true" ? 1 : 0}" load_balancer_arn = "${aws_lb.default.arn}" port = "${var.https_port}" diff --git a/outputs.tf b/outputs.tf index 0ce90f7..abf4275 100644 --- a/outputs.tf +++ b/outputs.tf @@ -40,7 +40,7 @@ output "https_listener_arn" { output "listener_arns" { description = "A list of all the listener ARNs" - value = ["${aws_lb_listener.http.arn}"] + value = ["${compact(concat(aws_lb_listener.http.*.arn, aws_lb_listener.https.*.arn))}"] } output "access_logs_bucket_id" { diff --git a/variables.tf b/variables.tf index fece82c..cf6944a 100644 --- a/variables.tf +++ b/variables.tf @@ -1,12 +1,15 @@ variable "namespace" { + type = "string" description = "Namespace, which could be your organization name, e.g. `cp` or `cloudposse`" } variable "stage" { + type = "string" description = "Stage, e.g. `prod`, `staging`, `dev`, or `test`" } variable "name" { + type = "string" description = "Solution name, e.g. `app`" } @@ -34,8 +37,8 @@ variable "vpc_id" { } variable "subnet_ids" { - type = "list" - desciption = "A list of subnet IDs to associate with ALB" + type = "list" + description = "A list of subnet IDs to associate with ALB" } variable "security_group_ids" { @@ -45,16 +48,19 @@ variable "security_group_ids" { } variable "internal" { + type = "string" default = "false" description = "A boolean flag to determine whether the ALB should be internal" } variable "http_port" { + type = "string" default = "80" description = "The port for the HTTP listener" } variable "http_enabled" { + type = "string" default = "true" description = "A boolean flag to enable/disable HTTP listener" } @@ -72,16 +78,19 @@ variable "http_ingress_prefix_list_ids" { } variable "certificate_arn" { + type = "string" default = "" description = "The ARN of the default SSL certificate for HTTPS listener" } variable "https_port" { + type = "string" default = "443" description = "The port for the HTTPS listener" } variable "https_enabled" { + type = "string" default = "false" description = "A boolean flag to enable/disable HTTPS listener" } @@ -99,76 +108,91 @@ variable "https_ingress_prefix_list_ids" { } variable "access_logs_prefix" { + type = "string" default = "" description = "The S3 bucket prefix" } variable "access_logs_enabled" { + type = "string" default = "true" description = "A boolean flag to enable/disable access_logs" } variable "access_logs_region" { + type = "string" default = "us-east-1" description = "The region for the access_logs S3 bucket" } variable "cross_zone_load_balancing_enabled" { + type = "string" default = "true" description = "A boolean flag to enable/disable cross zone load balancing" } variable "http2_enabled" { + type = "string" default = "true" description = "A boolean flag to enable/disable HTTP/2" } variable "idle_timeout" { + type = "string" default = "60" description = "The time in seconds that the connection is allowed to be idle" } variable "ip_address_type" { + type = "string" default = "ipv4" description = "The type of IP addresses used by the subnets for your load balancer. The possible values are `ipv4` and `dualstack`." } variable "deletion_protection_enabled" { + type = "string" default = "false" description = "A boolean flag to enable/disable deletion protection for ALB" } variable "deregistration_delay" { + type = "string" default = "15" description = "The amount of time to wait in seconds before changing the state of a deregistering target to unused" } variable "health_check_path" { + type = "string" default = "/" description = "The destination for the health check request" } variable "health_check_timeout" { + type = "string" default = "10" description = "The amount of time to wait in seconds before failing a health check request" } variable "health_check_healthy_threshold" { + type = "string" default = "2" description = "The number of consecutive health checks successes required before considering an unhealthy target healthy" } variable "health_check_unhealthy_threshold" { + type = "string" default = "2" description = "The number of consecutive health check failures required before considering the target unhealthy" } variable "health_check_interval" { + type = "string" default = "15" description = "The duration in seconds in between health checks" } variable "health_check_matcher" { + type = "string" default = "200-399" description = "The HTTP response codes to indicate a healthy check" }