CLI Tool for deploying CloudFormation using a YAML based config file for stack and parameter settings.
Project description
CloudFormation Control
About The Project
Cloud Formation Control (cfnctl) is a commandline utility based of the AWS CLI Deploy features. On top of existing deployment capabilities it adds the ability to specify a configuration file to easily supply the following parameters to your CloudFormation deployment:
- StackName
- AwsRegion
- StackParameters
- StackTags
Supplying your CloudFormation template with a config containing the above parameters, and a set of commandline arguments or environment variables, it makes it easier to deploy CloudFormation templates both from your local development machine as well as a pipeline using the same pipelines and configurations.
Built With
This project is build using the following tools and frameworks:
Getting Started
In order to get started with developing and contributing to this project, follow the steps below.
Prerequisites
pipx (Optional)
This project is build and managed by poetry, the easiest way to install poetry in an isolated environment is using pipx.
python -m pip install --user pipx
python -m pipx ensurepath
Poetry
If you installed pipx, you can simply install poetry using the command below:
pipx install poetry
If you did not install pipx, see Poetry documentation for installation method for your system.
Installation
- Clone the repository
git clone https://novonordiskit@dev.azure.com/novonordiskit/GITO-HS/_git/aws-cfnctl
- Change directory into the cloned repository
cd aws-cfnctl
- Install dependencies into a virtual environment with poetry
poetry install - Activate virtual environment with poetry
poetry shell
Usage
When installed somewhere on the system included in the systems PATH, the application can be called with cfnctl.
To see all available options for the CLI run:
cfnctl --help
The cfnctl command has two primary subcommands:
cfnctl plancfnctl apply
cfnctl plan
cfnctl plan creates a new stack plan, or if the stack already exists, a change set plan for AWS CloudFormation.
The resulting plan can then be used with cfnctl apply to execute the stack / change set and provision it in AWS.
If you wish to execute the plan immediately, set the --auto-apply commandline flag or use the CFNCTL_AUTO_APPLY = $TRUE.
The cfnctl plan command requires the following options:
- --name "CloudFormation change set name."
- --description "CloudFormation change set description."
- --template "Relative or absolute filepath pointing to CloudFormation template file."
- --config "Relative or absolute filepath pointing to CloudFormation template config file."
- --output "Relative or absolute filepath for resulting change set file."
The following settings can be set optionally:
- --export-stack "Export the Stack ID as an Azure DevOps pipeline variable with this name."
- --export-changeset "Export the change set ID as an Azure DevOps pipeline variable with this name."
- --export-outputs "Exports the stack output as Azure DevOps pipeline variables."
- --auto-apply "If set to true, changeset will be created then executed"
cfnctl apply
cfnctl apply executes a stack plan, or if the stack already exists, executes a change set with AWS CloudFormation.
The command requires a plan file created with the cfnctl plan command.
The cfnctl plan command requires the following options:
- --name "CloudFormation change set name."
- --description "CloudFormation change set description."
- --template "Relative or absolute filepath pointing to CloudFormation template file."
- --config "Relative or absolute filepath pointing to CloudFormation template config file."
- --output "Relative or absolute filepath for incoming change set file."
The following settings can be set optionally:
- --export-stack "Export the Stack ID as an Azure DevOps pipeline variable with this name."
- --export-changeset "Export the change set ID as an Azure DevOps pipeline variable with this name."
- --export-outputs "Exports the stack output as Azure DevOps pipeline variables."
Environment variables
Instead of using commandline parameters, it is possible to configure the cfnctl plan and cfnctl apply commands using environment variables.
PowerShell environment variables
Setting environment variables in PowerShell:
$env:CFNCTL_CHANGESET_NAME = "MyChangeSet"
$env:CFNCTL_CHANGESET_DESCRIPTION = "Change Set for my stack"
$env:CFNCTL_TEMPLATE_PATH = "my-cfn-template-file.yml"
$env:CFNCTL_STACK_CONFIG_PATH = "my-cfnctl-config-file.yml"
$env:CFNCTL_PLAN_OUTPUT_PATH = "cfn-output-file.yml"
# Optional
$env:CFNCTL_STACK_ID_EXPORT_VAR = "CFNCTL_STACK_ID"
$env:CFNCTL_CHANGESET_ID_EXPORT_VAR = "CFNCTL_CHANGESET_ID"
$env:CFNCTL_EXPORT_STACK_OUTPUT = $TRUE
$env:CFNCTL_AUTO_APPLY = $TRUE
You can validate the values is set correctly in your shell with:
Get-Item -Path Env:* | Where-Object {$_.name -like "CFNCTL_*"}
Bash environment variables
Setting Environment variables in Bash:
export CFNCTL_CHANGESET_NAME = "MyChangeSet"
export CFNCTL_CHANGESET_DESCRIPTION = "Change Set for my stack"
export CFNCTL_TEMPLATE_PATH = "my-cfn-template-file.yml"
export CFNCTL_STACK_CONFIG_PATH = "my-cfnctl-config-file.yml"
export CFNCTL_PLAN_OUTPUT_PATH = "cfn-output-file.yml"
# Optional
export CFNCTL_STACK_ID_EXPORT_VAR = "CFNCTL_STACK_ID"
export CFNCTL_CHANGESET_ID_EXPORT_VAR = "CFNCTL_CHANGESET_ID"
export CFNCTL_EXPORT_STACK_OUTPUT = true
export CFNCTL_AUTO_APPLY = true
You can validate the values is set correctly in your shell with:
env | grep 'CFNCTL_'
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nn-cfnctl-0.2.0.tar.gz.
File metadata
- Download URL: nn-cfnctl-0.2.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1abd09ad7d7e1119a9f4155a3d74dd38764f9be6d7b740fb27a603900abdf60c
|
|
| MD5 |
8051569d6c995e8113d273ccad502869
|
|
| BLAKE2b-256 |
2e901080bc6980b511650eaaa311e8cbe02712187d660544dae6b2ead99e7783
|
File details
Details for the file nn_cfnctl-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nn_cfnctl-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdf9db453e7ee247bc005118f962c008088f93410facc03acab6a4cfa6dce784
|
|
| MD5 |
a089d15ba3d7f6fb50e0cf252c6eee79
|
|
| BLAKE2b-256 |
2926595cdf9f166ed156ed352eb72a79cfb6e9bbd24a769793ed04017dbe6e02
|