Tooling to help manage CloudFormation stacks
Project description
Stackedup
stackedup provides tools to launch and manage micro-service based applications in AWS using CloudFormation.
stackedup relies on three core abstractions:
- account: An AWS account used by the application
- cluster: A collection of AWS resources where applications run, such as compute capacity, database, networking configuration, etc that allows running one more instances
- instance: An instance of an application, such as testing or production
- service: An application service, such as an API or a web UI
As much as possible, stackedup aims to get out of the way between you and your CloudFormation Stacks. Clusters, instances and services are plain CloudFormation stacks. stackedup helps you launch and update them, recording state and current parameters in an instance manifest, a YAML file usually named `config.yaml. A common instance manifest, may look like this:
---
project_name: my-project
# The types of stacks supported in this project
stack_types:
- pipeline
- application
# The AWS accounts involved
accounts:
my-aws-account:
cloudformation_bucket: <my-bucket> # A bucket name used for building and deploying stacks
id: my-aws-account
provisioner_role_arn: arn:aws:iam::123...:role/my-role # The ARN of the IAM role stacked
# should assume to run AWS API call
# commands on this account
# The clusters
clusters:
dev:
stack_name: my-project-cluster-dev-2005251008 # Once launched, this key stores the
# stack name for future updates
account: my-aws-account
region: us-west-2
parameters: # These are the CloudFormation parameters
KeyName: my-ssh-key # sent to the stack
instances:
# One instance of the application, called testing
testing:
account: ombu
cluster: dev
application:
stack_name: my-project-testing-2005251108
parameters:
ClusterStack: my-project-cluster-dev-2005251008
DatabaseHost: ...rds.amazonaws.com
DatabaseName: my-project-testing
DatabaseUser: my-project-testing
Domain: my-project.com
ECRRepository: ....dkr.ecr.us-east-1.amazonaws.com
EnvironmentType: testing
ImageTag: '0.1.10'
SentryDsn: "https://...@....ingest.sentry.io/..."
# Another instance of the application, called staging
staging:
account: ombu
cluster: dev
application:
stack_name: my-project-stagomg-2005251208
parameters:
...
Installation
Stacked up is distributed in the Python Package Index (PyPI). To install it:
pip install stackedup
This will install the current version of stackedup. Older projects may depend on
specific versions, so stacked up is usually installed as part of the project
Python requirements. In a project with a requirements.txt
file:
pip install -r requirements.txt
Usage
To run any stackedup command, your AWS CLI environment must be configured such that you are able to assume the roles included in the accounts section of the instance manifest. When running commands, stacked up will attempt to assume these roles.
Launching stacks
For a cluster:
stack-launch cluster <cluster-name>
For an instance service:
stack-launch <service> <instance>
Obtaining details on a running stack
For a cluster:
stack-details cluster <cluster-name>
stack-details <service> <instance>
Updating stacks
After updating the parameters for an existing stack in the instance manifest (often _config.yaml`), update the instance:
stack-update <service> <instance>
Opening a shell session in a service container (==experimental==)
For service stacks that run ECS Services stacked up includes an experimental command to start a shell session in one of the service containers:
$ container-shell <instance> <service> <service-name> <container>
ssh -t -i <ssh-key> ec2-user@ec2-54-218-12-133... docker exec -it 380f02d109d9a038e1e1909e0f31e85a6491312d3c29726b269bde8621ce1212 sh
The command returns an SSH command, so it's often ran in backticks as command substitution:
$ `container-shell <instance> <service> <service-name> <container>`
# (← you are in container bash session)
AWS accounts
stackedup can manage instances across AWS accounts, through IAM roles. The AWS
accounts their IAM roles for a project are defined in the accounts:
section of
the instance manifest (usually a file named config.yaml
). stackedup commands
automatically switch roles into the right account when performing stack
operations. One can also use the information in the instance manifest to assume
a role for a desired account in the AWS console:
-
Log into the AWS console for the master AWS account and open the Switch Role view (screenshot)
-
Obtain the desired AWS account ID and role name for the target role from the instance manifest and enter it into the Switch Role view: (screenshot)
Developing stacked up
Install dependencies in development mode
pip install setuptools
python setup.py develop
Running tests
python -m unittest discover
Packaged and distribute
Edit setup.py
with the desired target version. Then:
pip install wheel twine
python setup.py sdist bdist_wheel
python -m twine upload dist/stackedup-<tag>*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stackedup-0.0.14.tar.gz
.
File metadata
- Download URL: stackedup-0.0.14.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17f1e6ef358cb52e3dc58613630ab8f466e1d69dd6354dcea8614cc017cd2580 |
|
MD5 | eafbfe1c5c20389c79f41c16fa749b6b |
|
BLAKE2b-256 | f5fc8d526729869049b1ea8b5cece96c2f71c8ecb6ce2326ea017d207c754e68 |
File details
Details for the file stackedup-0.0.14-py3-none-any.whl
.
File metadata
- Download URL: stackedup-0.0.14-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a9b5f4352f2a8f9b852f35d8ae63257743643c47c095ed0c16fdb4f1583e8fa |
|
MD5 | b65b27ae942eb5a6079a8f22ca7d56b2 |
|
BLAKE2b-256 | ef0d988678643b8bd84f67c4132a2479b4a45b077231b25d1ae742d3dd096065 |