Skip to content

Commit 4919faf

Browse files
committed
add testing, update README and CHANGELOG
1 parent dda1550 commit 4919faf

File tree

7 files changed

+202
-3
lines changed

7 files changed

+202
-3
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: c
2+
before_install:
3+
- wget https://dl.dropboxusercontent.com/u/1917556/terraform.tgz -O /tmp/terraform.tgz
4+
- sudo tar -C /usr/local -zxf /tmp/terraform.tgz
5+
script: make test

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
## 0.1.0
1+
Change Log
2+
==========
3+
4+
v0.1.0
5+
-----
26

37
- Initial release.
48
- Setup a VPC with public and private subnets.
59
- Add NAT and bastion instances with appropriate security groups.
10+
- Add testing [v0.1.1]

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ all: plan apply
44

55
plan:
66
terraform get -update
7-
terraform plan -var-file terraform.tfvars -out terraform.tfplan
7+
terraform plan -module-depth=-1 -var-file terraform.tfvars -out terraform.tfplan
88

99
apply:
1010
terraform apply -var-file terraform.tfvars
@@ -16,3 +16,7 @@ destroy:
1616
clean:
1717
rm -f terraform.tfplan
1818
rm -f terraform.tfstate
19+
rm -fR .terraform/
20+
21+
test:
22+
./scripts/testPlan

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NOTE: **If you are looking to deploy Cloud Foundry into AWS VPC, visit https://g
55

66
This repository is a submodule of the project above that aims to create one click deploy for Cloud Foundry on AWS VPC. You *probably* don't want to use this repo directly.
77

8-
This terraform module creates a VPC, a set of public/private subnets and a NAT for outbound traffic.
8+
This terraform module creates the networks and security groups that are needed to deploy CloudFoundry within an existing VPC (specifically, a VPC that was created using [https://github.com/cloudfoundry-community/terraform-aws-vpc], but any VPC will do).
99

1010
Architecture
1111
------------

scripts/testPlan

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
exitcode=0
4+
TFILE=`mktemp`
5+
GREEN="\e[1;34m"
6+
RED="\e[0;31m"
7+
RESET="\e[0m"
8+
9+
# $1 = exit code (will exit testing if non-zero)
10+
# $2 = description of the test
11+
# $3 = output of the test
12+
CLEANUP () {
13+
rm -f $TFILE
14+
if [ $1 -ne 0 ]; then
15+
echo -e "$RED test '$2' failed: $RESET\n $3"
16+
exit $1
17+
fi
18+
}
19+
20+
# Pre-testing cleanup
21+
rm -fR .terraform/modules/
22+
23+
desc="Can we find the terraform binary?"
24+
OUTPUT=$(which terraform)
25+
CLEANUP "$?" "$desc" "Couldn't find terraform. Is it in your PATH?"
26+
27+
desc="Can we fetch the dependencies?"
28+
OUTPUT=$(terraform get -update)
29+
CLEANUP "$?" "$desc" "Unable to fetch the modules we depend on"
30+
31+
desc="Does the plan compile?"
32+
OUTPUT=$(terraform plan -var-file terraform.tfvars.example)
33+
CLEANUP "$?" "$desc" "$OUTPUT"
34+
35+
desc="Did the baseline terraform plan change?"
36+
terraform plan -var-file terraform.tfvars.example &> $TFILE
37+
OUTPUT=$(diff test-fixtures/terraform.testplan $TFILE)
38+
CLEANUP "$?" "$desc" "$OUTPUT"
39+
40+
# If we got here, all the tests passed
41+
echo -e "$GREEN All tests passed $RESET"
42+
exit 0

terraform.tfvars.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ aws_key_path = "~/.ssh/bosh.pem"
44
aws_key_name = "bosh"
55
aws_region = "us-east-1"
66
network = "10.10"
7+
8+
# These most often come from terraform-aws-vpc, but can be manually set
9+
# if you don't want to or can't use that module.
10+
aws_route_table_private_id = "X"
11+
aws_internet_gateway_id = "X"
12+
aws_route_table_public_id = "X"
13+
aws_vpc_id = "X"

test-fixtures/terraform.testplan

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
Refreshing Terraform state prior to plan...
2+
3+
4+
The Terraform execution plan has been generated and is shown below.
5+
Resources are shown in alphabetical order for quick scanning. Green resources
6+
will be created (or destroyed and then created if an existing resource
7+
exists), yellow resources are being changed in-place, and red resources
8+
will be destroyed.
9+
10+
Note: You didn't specify an "-out" parameter to save this plan, so when
11+
"apply" is called, Terraform can't guarantee this is what will execute.
12+
13+
+ aws_eip.cf
14+
 allocation_id: "" => "<computed>"
15+
association_id: "" => "<computed>"
16+
domain: "" => "<computed>"
17+
private_ip: "" => "<computed>"
18+
public_ip: "" => "<computed>"
19+
vpc: "" => "1"
20+

21+
+ aws_route_table.public
22+
 route.#: "" => "1"
23+
route.3901018052.cidr_block: "" => "0.0.0.0/0"
24+
route.3901018052.gateway_id: "" => "X"
25+
route.3901018052.instance_id: "" => ""
26+
tags.#: "" => "<computed>"
27+
vpc_id: "" => "X"
28+

29+
+ aws_route_table_association.cfruntime-2a-private
30+
 route_table_id: "" => "X"
31+
subnet_id: "" => "${aws_subnet.cfruntime-2a.id}"
32+

33+
+ aws_route_table_association.cfruntime-2b-private
34+
 route_table_id: "" => "X"
35+
subnet_id: "" => "${aws_subnet.cfruntime-2b.id}"
36+

37+
+ aws_route_table_association.docker
38+
 route_table_id: "" => "X"
39+
subnet_id: "" => "${aws_subnet.docker.id}"
40+

41+
+ aws_route_table_association.lb-public
42+
 route_table_id: "" => "X"
43+
subnet_id: "" => "${aws_subnet.lb.id}"
44+

45+
+ aws_security_group.cf
46+
 description: "" => "CF security groups"
47+
ingress.#: "" => "8"
48+
ingress.1325011704.cidr_blocks.#: "" => "1"
49+
ingress.1325011704.cidr_blocks.0: "" => "0.0.0.0/0"
50+
ingress.1325011704.from_port: "" => "4443"
51+
ingress.1325011704.protocol: "" => "tcp"
52+
ingress.1325011704.security_groups.#: "" => "0"
53+
ingress.1325011704.self: "" => "0"
54+
ingress.1325011704.to_port: "" => "4443"
55+
ingress.1663094005.cidr_blocks.#: "" => "0"
56+
ingress.1663094005.from_port: "" => "0"
57+
ingress.1663094005.protocol: "" => "udp"
58+
ingress.1663094005.security_groups.#: "" => "0"
59+
ingress.1663094005.self: "" => "1"
60+
ingress.1663094005.to_port: "" => "65535"
61+
ingress.219953956.cidr_blocks.#: "" => "1"
62+
ingress.219953956.cidr_blocks.0: "" => "0.0.0.0/0"
63+
ingress.219953956.from_port: "" => "22"
64+
ingress.219953956.protocol: "" => "tcp"
65+
ingress.219953956.security_groups.#: "" => "0"
66+
ingress.219953956.self: "" => "0"
67+
ingress.219953956.to_port: "" => "22"
68+
ingress.2261450965.cidr_blocks.#: "" => "1"
69+
ingress.2261450965.cidr_blocks.0: "" => "0.0.0.0/0"
70+
ingress.2261450965.from_port: "" => "4222"
71+
ingress.2261450965.protocol: "" => "tcp"
72+
ingress.2261450965.security_groups.#: "" => "0"
73+
ingress.2261450965.self: "" => "0"
74+
ingress.2261450965.to_port: "" => "25777"
75+
ingress.2603706321.cidr_blocks.#: "" => "1"
76+
ingress.2603706321.cidr_blocks.0: "" => "0.0.0.0/0"
77+
ingress.2603706321.from_port: "" => "80"
78+
ingress.2603706321.protocol: "" => "tcp"
79+
ingress.2603706321.security_groups.#: "" => "0"
80+
ingress.2603706321.self: "" => "0"
81+
ingress.2603706321.to_port: "" => "80"
82+
ingress.32090245.cidr_blocks.#: "" => "1"
83+
ingress.32090245.cidr_blocks.0: "" => "0.0.0.0/0"
84+
ingress.32090245.from_port: "" => "-1"
85+
ingress.32090245.protocol: "" => "icmp"
86+
ingress.32090245.security_groups.#: "" => "0"
87+
ingress.32090245.self: "" => "0"
88+
ingress.32090245.to_port: "" => "-1"
89+
ingress.3738418453.cidr_blocks.#: "" => "0"
90+
ingress.3738418453.from_port: "" => "0"
91+
ingress.3738418453.protocol: "" => "tcp"
92+
ingress.3738418453.security_groups.#: "" => "0"
93+
ingress.3738418453.self: "" => "1"
94+
ingress.3738418453.to_port: "" => "65535"
95+
ingress.4089093546.cidr_blocks.#: "" => "1"
96+
ingress.4089093546.cidr_blocks.0: "" => "0.0.0.0/0"
97+
ingress.4089093546.from_port: "" => "443"
98+
ingress.4089093546.protocol: "" => "tcp"
99+
ingress.4089093546.security_groups.#: "" => "0"
100+
ingress.4089093546.self: "" => "0"
101+
ingress.4089093546.to_port: "" => "443"
102+
name: "" => "cf-0-X"
103+
owner_id: "" => "<computed>"
104+
tags.#: "" => "1"
105+
tags.Name: "" => "cf-0-X"
106+
vpc_id: "" => "X"
107+

108+
+ aws_subnet.cfruntime-2a
109+
 availability_zone: "" => "<computed>"
110+
cidr_block: "" => "10.10.03.0/24"
111+
tags.#: "" => "1"
112+
tags.Name: "" => "cf1"
113+
vpc_id: "" => "X"
114+

115+
+ aws_subnet.cfruntime-2b
116+
 availability_zone: "" => "us-west-2a"
117+
cidr_block: "" => "10.10.04.0/24"
118+
tags.#: "" => "1"
119+
tags.Name: "" => "cf2"
120+
vpc_id: "" => "X"
121+

122+
+ aws_subnet.docker
123+
 availability_zone: "" => "us-west-2a"
124+
cidr_block: "" => "10.10.05.0/24"
125+
tags.#: "" => "1"
126+
tags.Name: "" => "docker"
127+
vpc_id: "" => "X"
128+

129+
+ aws_subnet.lb
130+
 availability_zone: "" => "us-west-2a"
131+
cidr_block: "" => "10.10.02.0/24"
132+
tags.#: "" => "1"
133+
tags.Name: "" => "lb"
134+
vpc_id: "" => "X"
135+

136+


0 commit comments

Comments
 (0)