Sceptre is a tool to drive AWS CloudFormation.
1.1K
Running Sceptre via Docker is useful in situations where you can't expect to or don't want to install Python and the required libraries.
The simplest thing of course is to just run it without parameters.
$ docker run cloudreach/sceptre
Usage: sceptre [OPTIONS] COMMAND [ARGS]...
But in practice you'll want Sceptre to do something, so your Sceptre files will need to be accessible from within the container. In particular, they are expected to be in the /sceptre folder, and you need to mount a local directory to that location.
One way of doing this is to run Docker from the local folder containing your files:
$ cd /my/sceptre/folder
$ docker run -t --rm \
-v $(pwd):/sceptre:ro \
cloudreach/sceptre COMMAND...
Another way is to specify the full path to the folder, and then run Docker from wherever you like:
$ docker run -t --rm \
-v /my/sceptre/folder:/sceptre:ro \
cloudreach/sceptre COMMAND...
To make changes in AWS, Sceptre will need credentials. One approach is to mount your local .aws folder to be used by the root user in the container:
$ docker run -t --rm \
-v ${HOME}/.aws:/root/.aws:ro \
-v $(pwd):/sceptre:ro \
cloudreach/sceptre COMMAND...
(Note how the folders are mounted read-only. Sceptre does not need to write anything to the host filesystem for most commands.)
Another approach uses the environment variables which have already somehow been defined in your shell:
$ docker run -t --rm \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-v $(pwd):/sceptre:ro \
cloudreach/sceptre COMMAND...
A tool such as aws-vault can set these variables on the fly each time you run Docker, which is especially useful when you have MFA enabled on your AWS account:
$ aws-vault exec sandbox -- docker run -t --rm -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -v $(pwd):/sceptre:ro cloudreach/sceptre COMMAND...
(Apologies for the long line, aws-vault commands can't be broken into multiple lines like shell commands.)
Finally, to use interactive commands like init you must add the -i option so that Docker can accept input. Then mount your folder as writable by leaving off the :ro suffix.
For example, to create a new project in your current folder:
$ docker run -i -t --rm \
-v $(pwd):/sceptre \
cloudreach/sceptre init project my-new-project
Please enter a project_code [my-new-project]:
Please enter a region []: us-west-2
$ ls my-new-project/
config templates
If this gives you strange behaviour, probably you forgot the -i option.
Content type
Image
Digest
Size
42.8 MB
Last updated
about 8 years ago
docker pull rgitzel/sceptre