Deployment is driven by Packer, Troposphere, the AWS Command Line Interface and Boto, the AWS SDK for Python. It requires some setup in your Amazon account, editing a configuration file, creating AMIs, and launching a stack.
To install the Python deployment dependencies, use pip
:
$ cd deployment
$ pip install -r requirements.txt
Next, install Packer using the steps detailed on Packer's website.
See Create an IAM Instance Profile for Your Amazon EC2 Instances.
Using the AWS CLI, create an AWS profile:
$ aws configure --profile mmw-stg
You will be prompted to enter your AWS credentials, along with a default region. These credentials will be used to authenticate calls to the AWS API when using Boto, Packer, and the AWS CLI.
A configuration file is required to launch the stack. An example file (default.yml.example
) is available in the current directory.
Stack launching is managed with mmw_stack.py
. This command provides an interface for automatically generating AMIs and launching Model My Watershed stacks.
Before launching the Model My Watershed stack, AMIs for each service need to be generated:
$ ./mmw_stack.py create-ami --aws-profile mmw-stg --mmw-profile staging \
--machine-type mmw-{app,monitoring,tiler,worker}
After creating several AMIs, older ones become stale and are no longer needed. To prune them use:
$ ./mmw_stack.py prune-ami --aws-profile mmw-stg --mmw-profile staging \
--keep 5 --machine-type mmw-{app,monitoring,tiler,worker}
After successfully creating AMIs, you can launch a Model My Watershed stack with the launch-stacks
subcommand. To view all options for the launch-stacks
subcommand, you can use the --help
option.
Using the parameters set in default.yml
, you can launch a full stack with the following command:
$ ./mmw_stack.py launch-stacks --aws-profile mmw-stg --mmw-profile staging \
--mmw-config-path default.yml