Skip to content

Commit

Permalink
ISSUE-3: use manage-cfn; use US regions;
Browse files Browse the repository at this point in the history
  • Loading branch information
amosshapira committed Jan 2, 2017
1 parent c001926 commit 3504f70
Show file tree
Hide file tree
Showing 25 changed files with 982 additions and 122 deletions.
61 changes: 57 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,71 @@ $ vim configuration/templates/wan/config.yaml
# edit to update the AMI's ID's as printed by Packer.
# also add your ssh key name to "key_name"
```
Now bring up the entire setup:

```
$ ./bin/demo-up-all-examples
```
This should bring up the entire WAN and connect between all VPC's.
This should bring up the VPC's in multiple AWS regions and the Wide Area Network (WAN) connecting all the VPC's.

It takes a couple of minutes for each VPN connection to be fully up and routes propagted. Have patience.
It takes a couple of minutes for each VPN connection to be fully up and routes propagated. Have patience my young Padawan.

The output of the above command "tails" the CloudFormation events for each stack as it is being created. Normal output is in Green. If there is a failed event then it will appear in Red then all following events will switch to Purple.

When the script is done you can check the status of the stacks by executing `./bin/manage-cfn list`:

```
$ ./bin/manage-cfn list
8 stacks: ........
Name Profile Region State Status Created Last Updated Description
---------------- --------- --------- ------- --------------- ------------------- -------------- -------------
ohio default us-east-2 up CREATE_COMPLETE 2017-01-02 01:41:03 Ohio VPC
ohio-wan default us-east-2 up CREATE_COMPLETE 2017-01-02 01:42:21 Ohio WAN
oregon default us-west-2 up CREATE_COMPLETE 2017-01-02 01:45:56 Oregon VPC
oregon-wan default us-west-2 up CREATE_COMPLETE 2017-01-02 01:47:09 Oregon WAN
virginia default us-east-1 up CREATE_COMPLETE 2017-01-02 01:36:09 Virginia
virginia-hub default us-east-1 up CREATE_COMPLETE 2017-01-02 01:26:17 Virginia Hub
virginia-hub-wan default us-east-1 up CREATE_COMPLETE 2017-01-02 01:27:33 Virginia Hub WAN
virginia-wan default us-east-1 up CREATE_COMPLETE 2017-01-02 01:37:27 Virginia WAN
```

There are more useful sub-command, execute `manage-cfn --help` for details:

```
$ ./bin/manage-cfn --help
Usage:
manage-cfn up --stack stack [--tail] [--debug] [--force] [--color]
manage-cfn provision --stack stack [--tail] [--debug] [--force] [--color]
manage-cfn diff --stack stack [--debug]
manage-cfn down --stack stack [--tail] [--debug] [--force] [--no-color]
manage-cfn show --stack stack [--debug]
manage-cfn status --stack stack [--debug]
manage-cfn tail --stack stack [--debug] [--color]
manage-cfn verify --stack stack [--debug] [--color]
manage-cfn print [--stack stack] [--yaml | --json | --raw] [KEY...]
manage-cfn list [--debug]
Arguments:
KEY optional one or more keys to print
Options:
-h --help Show this help text
--color Force color output (default if console output)
-d --debug Turn on debug logging
-f --force Skip prompting for confirmation
(default if no console input)
-j --json Print in JSON format (default)
-r --raw Print raw strings
-s stack --stack=stack Stack to operate on
--tail Force tail stack events (default if console output)
-y --yaml Print in YAML format
```

When the links are up and the routes come through, the routing table of the private network in the hub will look something like this:
![](https://github.com/amosshapira/thermal/raw/master/docs/images/route-tables.png)

You can see that the routes from all remote VPC's are available and were propagted automatically.
You can see that the routes from all remote VPC's are available and were propagated automatically.

When a tunnel is up, you'll see in the VPN Connection "UP" in the hub:
![](https://github.com/amosshapira/thermal/raw/master/docs/images/tunnels-up.png)
Expand All @@ -52,4 +105,4 @@ Once you finished with the test, you can take down the entire setup by typing:
$ ./bin/demo-down-all-examples
```

This will still leave behind the allocated Elastic IP's. You'll have to delete them yourself to avoid paying for them.
This will still leave behind the allocated Elastic IP's. You'll have to delete them yourself to avoid charges by AWS.
38 changes: 18 additions & 20 deletions cloudformation/bin/demo-down-all-examples
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@
# This script will destroy the example configuration as checked out
# from the public repository

# Usage: delete_stack stack-name region
delete_stack() {
aws cloudformation delete-stack \
--debug \
--color on \
--stack-name $1 \
--region $2 && \
aws cloudformation wait stack-delete-complete \
--debug \
--color on \
--stack-name $1 \
--region $2 \
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

DIR=$(realpath $(dirname $0))

cd ${DIR}/.. || exit 1

delete_stack() {
./bin/manage-cfn down --force --stack "$1" || exit 1
}

# First delete the the WAN's
delete_stack tokyo-wan ap-northeast-1
delete_stack singapore-wan ap-southeast-1
delete_stack virginia-wan us-east-1
delete_stack tokyo-hub-wan ap-northeast-1
delete_stack oregon-wan
delete_stack ohio-wan
delete_stack virginia-wan
delete_stack virginia-hub-wan

# Now can delete the VPC's themselves:
delete_stack tokyo ap-northeast-1
delete_stack singapore ap-southeast-1
delete_stack virginia us-east-1
delete_stack tokyo-hub ap-northeast-1
delete_stack oregon
delete_stack ohio
delete_stack virginia
delete_stack virginia-hub

exit 0
43 changes: 19 additions & 24 deletions cloudformation/bin/demo-up-all-examples
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,33 @@
# This script will bring up the example configuration as checked out
# from the public repository

DIR=$(dirname $0)
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

DIR=$(realpath $(dirname $0))

cd ${DIR}/.. || exit 1

# Allocate Elastic IP's, they'll get stored in configuration/eips.yaml
$DIR/manage-eips
./bin/manage-eips || exit 1

# Usage: create_stack stack-name region
create_stack() {
$DIR/compile $1 > $1.json && \
aws cloudformation create-stack \
--debug \
--color on \
--capabilities CAPABILITY_IAM \
--template-body file://$1.json \
--stack-name $1 \
--region $2 && \
aws cloudformation wait stack-create-complete \
--debug \
--color on \
--stack-name $1 \
--region $2 \

echo Bringing up stack \"$1\"
./bin/manage-cfn up --force --stack "$1" || exit 1
}

# Bring up the Hub
create_stack tokyo-hub ap-northeast-1
create_stack tokyo-hub-wan ap-northeast-1
create_stack virginia-hub
create_stack virginia-hub-wan

# Now the "spokes" have all they need to come up
create_stack tokyo ap-northeast-1
create_stack tokyo-wan ap-northeast-1
create_stack singapore ap-southeast-1
create_stack singapore-wan ap-southeast-1
create_stack virginia us-east-1
create_stack virginia-wan us-east-1
create_stack virginia
create_stack virginia-wan
create_stack ohio
create_stack ohio-wan
create_stack oregon
create_stack oregon-wan

exit 0
Loading

0 comments on commit 3504f70

Please sign in to comment.