Skip to main content

Cloud Provisioning Tool

Project description

https://circleci.com/gh/cloudreach/sceptre.png?style=shield

About

Sceptre is a tool to drive AWS CloudFormation. It automates away some of the more mundane, repetitive and error-prone tasks, allowing you to concentrate on building better infrastructure.

Features:

  • Code reusability by separating a stack’s template and its configuration

  • Support for templates written in JSON, YAML, Jinja2 or Python DSLs such as Troposphere

  • Dependency resolution by passing of stack outputs to parameters of dependent stacks

  • Environment support by bundling related stacks into logical groups (e.g. dev and prod)

  • Environment-level commands, such as creating multiple stacks with a single command

  • Fast, highly parallelised builds

  • Built in support for working with stacks in multiple AWS accounts

  • Infrastructure visibility with meta-operations such as stack querying protection

  • Support for inserting dynamic values in templates via customisable resolvers

  • Support for running arbitrary code as hooks before/after stack builds

Example

Sceptre organises stacks into environments. Each stack is represented by a YAML configuration file stored in a directory which represents the environment. Here, we have two stacks, vpc and subnets, in an environment named dev:

$ tree
.
├── config
│   └── dev
│       ├── config.yaml
│       ├── subnets.yaml
│       └── vpc.yaml
└── templates
    ├── subnets.py
    └── vpc.py

We can create a stack with the create-stack command. This vpc stack contains a VPC:

$ sceptre create-stack dev vpc
dev/vpc - Creating stack
dev/vpc VirtualPrivateCloud AWS::EC2::VPC CREATE_IN_PROGRESS
dev/vpc VirtualPrivateCloud AWS::EC2::VPC CREATE_COMPLETE
dev/vpc sceptre-demo-dev-vpc AWS::CloudFormation::Stack CREATE_COMPLETE

The subnets stack contains a subnet which must be created in the VPC. To do this, we need to pass the VPC ID, which is exposed as a stack output of the vpc stack, to a parameter of the subnets stack. Sceptre automatically resolves this dependency for us:

$ sceptre create-stack dev subnets
dev/subnets - Creating stack
dev/subnets Subnet AWS::EC2::Subnet CREATE_IN_PROGRESS
dev/subnets Subnet AWS::EC2::Subnet CREATE_COMPLETE
dev/subnets sceptre-demo-dev-subnets AWS::CloudFormation::Stack CREATE_COMPLETE

Sceptre implements meta-operations, which allow us to find out information about our stacks:

$ sceptre describe-env-resources dev
dev/subnets:
- LogicalResourceId: Subnet
  PhysicalResourceId: subnet-445e6e32
dev/vpc:
- LogicalResourceId: VirtualPrivateCloud
  PhysicalResourceId: vpc-c4715da0

Sceptre provides environment-level commands. This one deletes the whole dev environment. The subnet exists within the vpc, so it must be deleted first. Sceptre handles this automatically:

$ sceptre delete-env dev
dev/subnets - Deleting stack
dev/subnets Subnet AWS::EC2::Subnet DELETE_IN_PROGRESS
dev/subnets - Stack deleted
dev/vpc - Deleting stack
dev/vpc VirtualPrivateCloud AWS::EC2::VPC DELETE_IN_PROGRESS
dev/vpc - Stack deleted

Usage

Sceptre can be used from the CLI, or imported as a Python package.

CLI:

Usage: sceptre [OPTIONS] COMMAND [ARGS]...

Options:
--version             Show the version and exit.
--debug               Turn on debug logging.
--dir TEXT            Specify sceptre directory.
--output [yaml|json]  The formatting style for command output.
--no-colour           Turn off output colouring.
--var TEXT            A variable to template into config files.
--var-file FILENAME   A YAML file of variables to template into config
                      files.
--help                Show this message and exit.

Commands:
continue-update-rollback  Roll stack back to working state.
create-change-set         Creates a change set.
create-stack              Creates the stack.
delete-change-set         Delete the change set.
delete-env                Delete all stacks.
delete-stack              Delete the stack.
describe-change-set       Describe the change set.
describe-env              Describe the stack statuses.
describe-env-resources    Describe the env's resources.
describe-stack-outputs    Describe stack outputs.
describe-stack-resources  Describe the stack's resources.
execute-change-set        Execute the change set.
generate-template         Display the template used.
get-stack-policy          Display the stack policy used.
launch-env                Creates or updates all stacks.
launch-stack              Create or launch the stack.
list-change-sets          List change sets.
lock-stack                Prevent stack updates.
set-stack-policy          Set stack policy.
unlock-stack              Allow stack updates.
update-stack              Update the stack.
update-stack-cs           Update the stack via change set.
validate-template         Validate the template.

Python:

from sceptre.environment import Environment

env = Environment("/path/to/sceptre_dir", "environment_name")
stack = env.stacks["stack_name"]
stack.create()

A full API description of the sceptre package can be found in the Documentation.

Install

$ pip install sceptre

More information on installing sceptre can be found in our Installation Guide.

Tutorial and Documentation

Contributions

See our Contributing Guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sceptre-1.4.1.tar.gz (76.4 kB view details)

Uploaded Source

Built Distribution

sceptre-1.4.1-py2.py3-none-any.whl (48.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sceptre-1.4.1.tar.gz.

File metadata

  • Download URL: sceptre-1.4.1.tar.gz
  • Upload date:
  • Size: 76.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/37.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.13

File hashes

Hashes for sceptre-1.4.1.tar.gz
Algorithm Hash digest
SHA256 9de4506b4f079601fc5dd7ecf5e45a36d119a9e44a6fd361a7064799a7ab68b8
MD5 5db3615efd705444d3df14acf113c914
BLAKE2b-256 311f52d09b4e0e0e9b80e4ce2efcf1f48c4baa32069b7d18b8ec6a5edb8070a0

See more details on using hashes here.

File details

Details for the file sceptre-1.4.1-py2.py3-none-any.whl.

File metadata

  • Download URL: sceptre-1.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 48.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/37.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.13

File hashes

Hashes for sceptre-1.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a6c9a92f34507ec2aaef8a221483ee7d08bec2d1db571656d860c4318992efeb
MD5 0cd16aed2959a24cd5deb14b50cc95a4
BLAKE2b-256 7c59b98f6d72d5e2ea7b2e22c0e3cb406d688d6cfc7ea6a1885cd3d95847d00b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page