Skip to content

Commit

Permalink
add testing, update README and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
teancom committed Feb 3, 2015
1 parent dda1550 commit 4919faf
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: c
before_install:
- wget https://dl.dropboxusercontent.com/u/1917556/terraform.tgz -O /tmp/terraform.tgz
- sudo tar -C /usr/local -zxf /tmp/terraform.tgz
script: make test
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 0.1.0
Change Log
==========

v0.1.0
-----

- Initial release.
- Setup a VPC with public and private subnets.
- Add NAT and bastion instances with appropriate security groups.
- Add testing [v0.1.1]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all: plan apply

plan:
terraform get -update
terraform plan -var-file terraform.tfvars -out terraform.tfplan
terraform plan -module-depth=-1 -var-file terraform.tfvars -out terraform.tfplan

apply:
terraform apply -var-file terraform.tfvars
Expand All @@ -16,3 +16,7 @@ destroy:
clean:
rm -f terraform.tfplan
rm -f terraform.tfstate
rm -fR .terraform/

test:
./scripts/testPlan
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NOTE: **If you are looking to deploy Cloud Foundry into AWS VPC, visit https://g

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.

This terraform module creates a VPC, a set of public/private subnets and a NAT for outbound traffic.
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).

Architecture
------------
Expand Down
42 changes: 42 additions & 0 deletions scripts/testPlan
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

exitcode=0
TFILE=`mktemp`
GREEN="\e[1;34m"
RED="\e[0;31m"
RESET="\e[0m"

# $1 = exit code (will exit testing if non-zero)
# $2 = description of the test
# $3 = output of the test
CLEANUP () {
rm -f $TFILE
if [ $1 -ne 0 ]; then
echo -e "$RED test '$2' failed: $RESET\n $3"
exit $1
fi
}

# Pre-testing cleanup
rm -fR .terraform/modules/

desc="Can we find the terraform binary?"
OUTPUT=$(which terraform)
CLEANUP "$?" "$desc" "Couldn't find terraform. Is it in your PATH?"

desc="Can we fetch the dependencies?"
OUTPUT=$(terraform get -update)
CLEANUP "$?" "$desc" "Unable to fetch the modules we depend on"

desc="Does the plan compile?"
OUTPUT=$(terraform plan -var-file terraform.tfvars.example)
CLEANUP "$?" "$desc" "$OUTPUT"

desc="Did the baseline terraform plan change?"
terraform plan -var-file terraform.tfvars.example &> $TFILE
OUTPUT=$(diff test-fixtures/terraform.testplan $TFILE)
CLEANUP "$?" "$desc" "$OUTPUT"

# If we got here, all the tests passed
echo -e "$GREEN All tests passed $RESET"
exit 0
7 changes: 7 additions & 0 deletions terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ aws_key_path = "~/.ssh/bosh.pem"
aws_key_name = "bosh"
aws_region = "us-east-1"
network = "10.10"

# These most often come from terraform-aws-vpc, but can be manually set
# if you don't want to or can't use that module.
aws_route_table_private_id = "X"
aws_internet_gateway_id = "X"
aws_route_table_public_id = "X"
aws_vpc_id = "X"
136 changes: 136 additions & 0 deletions test-fixtures/terraform.testplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
Refreshing Terraform state prior to plan...


The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_eip.cf
 allocation_id: "" => "<computed>"
association_id: "" => "<computed>"
domain: "" => "<computed>"
private_ip: "" => "<computed>"
public_ip: "" => "<computed>"
vpc: "" => "1"

+ aws_route_table.public
 route.#: "" => "1"
route.3901018052.cidr_block: "" => "0.0.0.0/0"
route.3901018052.gateway_id: "" => "X"
route.3901018052.instance_id: "" => ""
tags.#: "" => "<computed>"
vpc_id: "" => "X"

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

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

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

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

+ aws_security_group.cf
 description: "" => "CF security groups"
ingress.#: "" => "8"
ingress.1325011704.cidr_blocks.#: "" => "1"
ingress.1325011704.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.1325011704.from_port: "" => "4443"
ingress.1325011704.protocol: "" => "tcp"
ingress.1325011704.security_groups.#: "" => "0"
ingress.1325011704.self: "" => "0"
ingress.1325011704.to_port: "" => "4443"
ingress.1663094005.cidr_blocks.#: "" => "0"
ingress.1663094005.from_port: "" => "0"
ingress.1663094005.protocol: "" => "udp"
ingress.1663094005.security_groups.#: "" => "0"
ingress.1663094005.self: "" => "1"
ingress.1663094005.to_port: "" => "65535"
ingress.219953956.cidr_blocks.#: "" => "1"
ingress.219953956.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.219953956.from_port: "" => "22"
ingress.219953956.protocol: "" => "tcp"
ingress.219953956.security_groups.#: "" => "0"
ingress.219953956.self: "" => "0"
ingress.219953956.to_port: "" => "22"
ingress.2261450965.cidr_blocks.#: "" => "1"
ingress.2261450965.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.2261450965.from_port: "" => "4222"
ingress.2261450965.protocol: "" => "tcp"
ingress.2261450965.security_groups.#: "" => "0"
ingress.2261450965.self: "" => "0"
ingress.2261450965.to_port: "" => "25777"
ingress.2603706321.cidr_blocks.#: "" => "1"
ingress.2603706321.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.2603706321.from_port: "" => "80"
ingress.2603706321.protocol: "" => "tcp"
ingress.2603706321.security_groups.#: "" => "0"
ingress.2603706321.self: "" => "0"
ingress.2603706321.to_port: "" => "80"
ingress.32090245.cidr_blocks.#: "" => "1"
ingress.32090245.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.32090245.from_port: "" => "-1"
ingress.32090245.protocol: "" => "icmp"
ingress.32090245.security_groups.#: "" => "0"
ingress.32090245.self: "" => "0"
ingress.32090245.to_port: "" => "-1"
ingress.3738418453.cidr_blocks.#: "" => "0"
ingress.3738418453.from_port: "" => "0"
ingress.3738418453.protocol: "" => "tcp"
ingress.3738418453.security_groups.#: "" => "0"
ingress.3738418453.self: "" => "1"
ingress.3738418453.to_port: "" => "65535"
ingress.4089093546.cidr_blocks.#: "" => "1"
ingress.4089093546.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.4089093546.from_port: "" => "443"
ingress.4089093546.protocol: "" => "tcp"
ingress.4089093546.security_groups.#: "" => "0"
ingress.4089093546.self: "" => "0"
ingress.4089093546.to_port: "" => "443"
name: "" => "cf-0-X"
owner_id: "" => "<computed>"
tags.#: "" => "1"
tags.Name: "" => "cf-0-X"
vpc_id: "" => "X"

+ aws_subnet.cfruntime-2a
 availability_zone: "" => "<computed>"
cidr_block: "" => "10.10.03.0/24"
tags.#: "" => "1"
tags.Name: "" => "cf1"
vpc_id: "" => "X"

+ aws_subnet.cfruntime-2b
 availability_zone: "" => "us-west-2a"
cidr_block: "" => "10.10.04.0/24"
tags.#: "" => "1"
tags.Name: "" => "cf2"
vpc_id: "" => "X"

+ aws_subnet.docker
 availability_zone: "" => "us-west-2a"
cidr_block: "" => "10.10.05.0/24"
tags.#: "" => "1"
tags.Name: "" => "docker"
vpc_id: "" => "X"

+ aws_subnet.lb
 availability_zone: "" => "us-west-2a"
cidr_block: "" => "10.10.02.0/24"
tags.#: "" => "1"
tags.Name: "" => "lb"
vpc_id: "" => "X"



0 comments on commit 4919faf

Please sign in to comment.