-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from brandoconnor/develop
Initial release; variables now act as conditional switches
- Loading branch information
Showing
10 changed files
with
209 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
*.tfvars* | ||
*.tfstate* | ||
.terraform | ||
**/Gemfile.lock | ||
**/inspec.lock | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org/' do | ||
gem 'kitchen-terraform', '~> 0.6' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
### ALB resources with a switch - logging enabled/disabled | ||
|
||
resource "aws_alb" "alb_loging" { | ||
name = "${var.alb_name}" | ||
subnets = ["${split(",", var.subnets)}"] | ||
security_groups = ["${split(",", var.alb_security_groups)}"] | ||
internal = "${var.alb_is_internal}" | ||
|
||
access_logs { | ||
bucket = "${var.log_bucket}" | ||
prefix = "${var.log_prefix}" | ||
} | ||
|
||
count = "${var.log_bucket != "" && var.log_prefix != "" ? 1 : 0}" | ||
} | ||
|
||
resource "aws_alb" "alb_nologing" { | ||
name = "${var.alb_name}" | ||
subnets = ["${split(",", var.subnets)}"] | ||
security_groups = ["${split(",", var.alb_security_groups)}"] | ||
internal = "${var.alb_is_internal}" | ||
|
||
count = "${(var.log_bucket == "" || var.log_prefix == "") ? 1 : 0}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# this approach is not working just yet | ||
output "arn" { | ||
value = "${coalesce(aws_alb.alb_loging.arn, aws_alb.alb_nologing.arn) }" | ||
|
||
/*value = "${aws_alb.alb_loging.arn}"*/ | ||
} | ||
|
||
output "dns_name" { | ||
value = "${aws_alb.alb_loging.dns_name}" | ||
|
||
/*value = "${coalesce(list("aws_alb.alb_loging.dns_name", "aws_alb.alb_nologing.dns_name")) }"*/ | ||
} | ||
|
||
output "id" { | ||
value = "${aws_alb.alb_loging.id}" | ||
|
||
/*value = "${coalesce(list("aws_alb.alb_loging.dns_name", "aws_alb.alb_nologing.dns_name")) }"*/ | ||
} | ||
|
||
output "zone_id" { | ||
value = "${aws_alb.alb_loging.zone_id}" | ||
|
||
/*value = "${coalesce(list("aws_alb.alb_loging.dns_name", "aws_alb.alb_nologing.dns_name")) }"*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Module variables | ||
*/ | ||
|
||
variable "alb_is_internal" { | ||
description = "Determines if the ALB is internal. Default: false" | ||
default = false | ||
} | ||
|
||
variable "alb_name" { | ||
description = "The name of the ALB as will show in the AWS EC2 ELB console." | ||
} | ||
|
||
variable "alb_security_groups" { | ||
description = "A comma separated string of security groups with which we associate the ALB. e.g. 'sg-edcd9784,sg-edcd9785'" | ||
} | ||
|
||
variable "log_bucket" { | ||
description = "S3 bucket for storing ALB access logs." | ||
} | ||
|
||
variable "log_prefix" { | ||
description = "S3 prefix within the log_bucket under which logs are stored." | ||
} | ||
|
||
variable "subnets" { | ||
description = "A comma delimited list of subnets to associate with the ALB. e.g. 'subnet-1a2b3c4d,subnet-1a2b3c4e,subnet-1a2b3c4f'" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
module "external_alb" { | ||
provider "aws" { | ||
allowed_account_ids = ["${var.aws_account_id}"] | ||
region = "${var.aws_region}" | ||
access_key = "${var.aws_access_key}" | ||
secret_key = "${var.aws_secret_key}" | ||
region = "${var.aws_region}" | ||
} | ||
|
||
module "alb" { | ||
source = "github.com/brandoconnor/tf_aws_alb" | ||
alb_name = "${var.alb_name}" | ||
backend_port = "${var.instance_port}" | ||
backend_protocol = "${var.instance_protocol}" | ||
health_check_target = "${var.health_check_target}" | ||
alb_security_groups = "${join(",", var.security_group_id_list)}" | ||
log_bucket = "${var.log_bucket_name}-${var.aws_region}" | ||
log_prefix = "${var.log_prefix}" | ||
certificate_arn = "${var.certificate_arn}" | ||
subnets = "${join(",", var.public_subnet_ids)}" | ||
alb_security_groups = "${var.security_group_id_list}" | ||
log_bucket = "${var.log_bucket}" | ||
subnets = "${var.subnet_id_list}" | ||
vpc_id = "${var.vpc_id}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,39 @@ | ||
variable "aws_access_key" {} | ||
|
||
variable "aws_secret_key" {} | ||
|
||
variable "aws_region" { | ||
default = "us-west-2" | ||
variable "aws_account_id" { | ||
default = "123456789012" | ||
} | ||
|
||
variable "alb_name" { | ||
default = "example_alb" | ||
variable "aws_access_key" { | ||
default = "access_key_id_here" | ||
} | ||
|
||
variable "alb_security_groups" { | ||
default = ["sg-edcd9784", "sg-edcd9785"] | ||
variable "aws_secret_key" { | ||
default = "secret_access_key_here" | ||
} | ||
|
||
variable "certificate_arn" { | ||
default = "arn:aws:iam::123456789012:server-certificate/ProdServerCert" | ||
variable "aws_region" { | ||
default = "us-west-2" | ||
} | ||
|
||
variable "subnets" { | ||
default = ["subnet-1a2b3c4d", "subnet-1a2b3c4e", "subnet-1a2b3c4f"] | ||
variable "security_group_id_list" { | ||
default = ["sg-edcd9784", "sg-edcd9785"] | ||
} | ||
|
||
variable "backend_port" { | ||
default = "8080" | ||
variable "security_group_id_list" { | ||
default = ["sg-edcd9784", "sg-edcd9785"] | ||
} | ||
|
||
variable "backend_protocol" { | ||
default = "http" | ||
variable "security_group_id_list" { | ||
default = ["sg-edcd9784", "sg-edcd9785"] | ||
} | ||
|
||
variable "health_check_target" { | ||
default = "HTTPS:443/health" | ||
variable "subnet_id_list" { | ||
default = ["subnet-1a2b3c4d", "subnet-1a2b3c4e", "subnet-1a2b3c4f"] | ||
} | ||
|
||
variable "log_bucket" { | ||
variable "log_bucket_name" { | ||
default = "my_log_bucket" | ||
} | ||
|
||
variable "log_prefix" { | ||
default = "example_alb" | ||
variable "vpc_id" { | ||
default = "vpc-12345678" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.