Skip to content

Commit 274329a

Browse files
outputs repaired and tests added to prove counts (#67)
* outputs repaired and tests added to prove counts
1 parent 082ed72 commit 274329a

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
66
project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [[v3.3.1](https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v3.3.0...v3.3.1)] - 2018-05-06]
9+
10+
### Changed
11+
12+
* sliced outputs were appended with a `- 1` in debugging. This introduced a bug which was fixed and verified through test.
13+
814
## [[v3.3.0](https://github.com/terraform-aws-modules/terraform-aws-alb/compare/v3.2.0...v3.3.0)] - 2018-05-04]
915

1016
### Added

examples/alb_test_fixture/outputs.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ output "target_group_arns" {
2929
output "vpc_id" {
3030
value = "${module.vpc.vpc_id}"
3131
}
32+
33+
output "target_groups_count" {
34+
value = "${local.target_groups_count}"
35+
}
36+
37+
output "https_listeners_count" {
38+
value = "${local.https_listeners_count}"
39+
}
40+
41+
output "http_tcp_listeners_count" {
42+
value = "${local.http_tcp_listeners_count}"
43+
}

outputs.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ output "dns_name" {
55

66
output "http_tcp_listener_arns" {
77
description = "The ARN of the TCP and HTTP load balancer listeners created."
8-
value = "${slice(concat(aws_lb_listener.frontend_http_tcp.*.arn, list("")), 0, var.http_tcp_listeners_count - 1)}"
8+
value = "${slice(concat(aws_lb_listener.frontend_http_tcp.*.arn, list("")), 0, var.http_tcp_listeners_count)}"
99
}
1010

1111
output "http_tcp_listener_ids" {
1212
description = "The IDs of the TCP and HTTP load balancer listeners created."
13-
value = "${slice(concat(aws_lb_listener.frontend_http_tcp.*.id, list("")), 0, var.http_tcp_listeners_count - 1)}"
13+
value = "${slice(concat(aws_lb_listener.frontend_http_tcp.*.id, list("")), 0, var.http_tcp_listeners_count)}"
1414
}
1515

1616
output "https_listener_arns" {
1717
description = "The ARNs of the HTTPS load balancer listeners created."
18-
value = "${slice(concat(aws_lb_listener.frontend_https.*.arn, list("")), 0, var.https_listeners_count - 1)}"
18+
value = "${slice(concat(aws_lb_listener.frontend_https.*.arn, list("")), 0, var.https_listeners_count)}"
1919
}
2020

2121
output "https_listener_ids" {
2222
description = "The IDs of the load balancer listeners created."
23-
value = "${slice(concat(aws_lb_listener.frontend_https.*.id, list("")), 0, var.https_listeners_count - 1)}"
23+
value = "${slice(concat(aws_lb_listener.frontend_https.*.id, list("")), 0, var.https_listeners_count)}"
2424
}
2525

2626
output "load_balancer_arn_suffix" {
@@ -40,7 +40,7 @@ output "load_balancer_zone_id" {
4040

4141
output "target_group_arns" {
4242
description = "ARNs of the target groups. Useful for passing to your Auto Scaling group."
43-
value = "${slice(concat(aws_lb_target_group.main.*.arn, list("")), 0, var.target_groups_count - 1)}"
43+
value = "${slice(concat(aws_lb_target_group.main.*.arn, list("")), 0, var.target_groups_count)}"
4444
}
4545

4646
output "target_group_arn_suffixes" {
@@ -50,5 +50,5 @@ output "target_group_arn_suffixes" {
5050

5151
output "target_group_names" {
5252
description = "Name of the target group. Useful for passing to your CodeDeploy Deployment Group."
53-
value = "${slice(concat(aws_lb_target_group.main.*.name, list("")), 0, var.target_groups_count - 1)}"
53+
value = "${slice(concat(aws_lb_target_group.main.*.name, list("")), 0, var.target_groups_count)}"
5454
}

test/integration/default/test_alb.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
http_tcp_listener_arns = tf_state['modules'][0]['outputs']['http_tcp_listener_arns']['value']
99
https_listener_arns = tf_state['modules'][0]['outputs']['https_listener_arns']['value']
1010
target_group_arns = tf_state['modules'][0]['outputs']['target_group_arns']['value']
11+
http_tcp_listeners_count = tf_state['modules'][0]['outputs']['http_tcp_listeners_count']['value']
12+
https_listeners_count = tf_state['modules'][0]['outputs']['https_listeners_count']['value']
13+
target_groups_count = tf_state['modules'][0]['outputs']['target_groups_count']['value']
1114
# rubocop:enable LineLength
1215
alb_arn = tf_state['modules'][0]['outputs']['alb_id']['value']
1316
alb_name = alb_arn.split('/')[-2]
1417
region = tf_state['modules'][0]['outputs']['region']['value']
1518
ENV['AWS_REGION'] = region
1619
vpc_id = tf_state['modules'][0]['outputs']['vpc_id']['value']
1720
security_group_id = tf_state['modules'][0]['outputs']['sg_id']['value']
21+
count_cases = [[target_group_arns, target_groups_count],
22+
[http_tcp_listener_arns, http_tcp_listeners_count],
23+
[https_listener_arns, https_listeners_count]]
1824

1925
describe alb(alb_name) do
2026
it { should exist }
@@ -68,3 +74,11 @@
6874
its(:port) { should eq(80).or(eq(8080).or(eq(8081))) }
6975
end
7076
end
77+
78+
count_cases.each do |test_case|
79+
describe test_case[0] do
80+
it 'should be predetermined length' do
81+
expect(test_case[0].length).to eq(test_case[1].to_i)
82+
end
83+
end
84+
end

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v3.3.0
1+
v3.3.1

0 commit comments

Comments
 (0)