Skip to content

Commit

Permalink
Merge pull request #14 from terraform-aws-modules/simplify_region_var…
Browse files Browse the repository at this point in the history
…_in_tests

Simplifying tests (region) and defaulting to HTTP. Resolves #2
  • Loading branch information
brandonjbjelland authored Nov 17, 2017
2 parents 76bb17b + e5e1959 commit 7212e53
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ before_script:
- terraform -v

script:
- echo 'before_script'
- echo 'script'
# no terraform through docker until kitchen-terraform supports it
# - docker run -i -t -v $(pwd):/app/ -w /app/ hashicorp/terraform:light init
# - docker run -i -t -v $(pwd):/app/ -w /app/ hashicorp/terraform:light fmt -check=true
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.1.0] - 2017-11-16
#### Added
* outputs added for listeners - these can be useful for ECR integration (🍰 @mbolek).
* Moved default `alb_protocols` to HTTP to lower barier of entry in getting started.

## [2.0.0] - 2017-11-06
#### Added
* added `create_log_bucket` and `enable_logging` to help control logging more granularly.
Expand Down
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
ruby '2.4.2'

source 'https://rubygems.org/' do
gem 'test-kitchen'
gem 'kitchen-terraform'
gem 'awspec'
gem 'kitchen-terraform', '~> 2.0'
gem 'kitchen-verifier-awspec'
gem 'awspec'
gem 'rhcl'
end
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module "alb" {
alb_security_groups = ["sg-edcd9784", "sg-edcd9785"]
vpc_id = "vpc-abcde012"
subnets = ["subnet-abcde012", "subnet-bcde012a"]
alb_protocols = ["HTTPS"]
certificate_arn = "arn:aws:iam::123456789012:server-certificate/test_cert-123456789012"
create_log_bucket = true
enable_logging = true
Expand Down Expand Up @@ -88,6 +89,7 @@ The [changelog](https://github.com/terraform-aws-modules/terraform-aws-alb/tree/

## Authors
Created and maintained by [Brandon O'Connor](https://github.com/brandoconnor) - brandon@atscale.run.
Many thanks to [the contributers listed here](https://github.com/terraform-aws-modules/terraform-aws-alb/graphs/contributors)!

## License
MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-alb/tree/master/LICENSE) for full details.
1 change: 1 addition & 0 deletions examples/test_fixtures/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module "alb" {
vpc_id = "${module.vpc.vpc_id}"
subnets = "${module.vpc.public_subnets}"
certificate_arn = "${aws_iam_server_certificate.fixture_cert.arn}"
alb_protocols = ["HTTPS"]
health_check_path = "/"
create_log_bucket = true
enable_logging = true
Expand Down
4 changes: 4 additions & 0 deletions examples/test_fixtures/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ output "sg_id" {
output "account_id" {
value = "${data.aws_caller_identity.fixtures.account_id}"
}

output "region" {
value = "${var.region}"
}
4 changes: 3 additions & 1 deletion examples/test_fixtures/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ variable "log_location_prefix" {
default = "my-alb-logs"
}

variable "region" {}
variable "region" {
default = "us-west-2"
}
5 changes: 4 additions & 1 deletion test/integration/default/local_alb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@

module_vars = Rhcl.parse(File.open('examples/test_fixtures/variables.tf'))
log_location_prefix = module_vars['variable']['log_location_prefix']['default']

tf_state = JSON.parse(File.open('.kitchen/kitchen-terraform/default-aws/terraform.tfstate').read)
principal_account_id = tf_state['modules'][0]['outputs']['principal_account_id']['value']
account_id = tf_state['modules'][0]['outputs']['account_id']['value']
vpc_id = tf_state['modules'][0]['outputs']['vpc_id']['value']
security_group_id = tf_state['modules'][0]['outputs']['sg_id']['value']
account_id = tf_state['modules'][0]['outputs']['account_id']['value']
region = tf_state['modules'][0]['outputs']['region']['value']
ENV['AWS_REGION'] = region
# this must match the format in examples/test_fixtures/locals.tf
log_bucket_name = 'logs-' + ENV['AWS_REGION'] + '-' + account_id
log_bucket_name = 'logs-' + region + '-' + account_id
# subnet_ids = tf_state['modules'][0]['outputs']['subnet_ids']['value']

describe alb('my-alb') do
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ variable "alb_name" {
}

variable "alb_protocols" {
description = "The protocols the ALB accepts. e.g.: [\"HTTPS\"]"
description = "The protocols the ALB accepts. e.g.: [\"HTTP\"]"
type = "list"
default = ["HTTPS"]
default = ["HTTP"]
}

variable "alb_security_groups" {
Expand Down

0 comments on commit 7212e53

Please sign in to comment.