A CLI tool written in rust to allow a quick and easy way to update your existing Cloudformation Stacks. It allows you to target the stack which you want to modify, perform the modifications of the template/parameters locally and then launch the update and provide feedback its success/failure. Finally it also provides the ability to save the modified artifacts for future use.
Notes:
- This is NOT a full replacement of the AWS CLI nor the AWS SDKs, this is a wrapper on top of it to speed up minor changes on the existing deployed stacks.
- This is NOT the recommended approach on working with production AWS Cloudformation Stacks. This tool is primarily targeted on minor updated of dev/concept Cloudformation stacks that are not yet integrated on a full git repository with a CICD in place.
Currently the tool provides binaries for the following platforms:
- Linux
- MacOS (Not Tested)
Windows is not supported as there is not an out of the box cli text editor to use. On Windows it is recommended to install WSL and use cfnupd
as a Linux binary.
Download the appropriate version for your OS for the Github Releases Page and run the following command
chmod 775 cfnupd-<version>-<os-architecture>
sudo mv cfnupd-<version>-<os-architecture> /usr/local/bin/cfnupd
In case you face issues with the prebuilt binaries it is recommended to build from source.
- Download and install rust on your system.
- Clone the repository
- Run
make install
The cli requires connectivity to your AWS accounts which means either configuring the aws cli and providing the aws credentials file or populating the required environment variables for connectivity to AWS. You can find more information here: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
The tool requires the modification of local files (template & parameter file) this is implemented by utilizing a cli file editor that exists currently on your system. The decision of which editor to use is performed accordingly:
- First the environment variable
EDITOR
is checked. - If the environment variable does not exists, the tool check that the file in the location
/.config/cfnupd/config.toml
exists and has a value populated forEDITOR
- If the above true are not correct then the file
/.config/cfnupd/config.toml
is created and sets theEDITOR
parameter equal tonano
(as it is ubiquitous on all systems). The user can then further modify that file to provide the preferred editor.
$ cfnupd -h
Usage: cfnupd [OPTIONS] --stack-name <STACK_NAME>
Options:
-s, --stack-name <STACK_NAME>
The name of the stack you want to update
-r, --region <REGION>
The region in which the AWS Cloudformation stack you want to update exists. If not provided value is retrieved from the AWS Config. (eg eu-west-1)
-e, --editor <EDITOR>
Whether or not to print verbose logs on the stdout. To be used only for debug purposes
-c, --capabilities
Provide the necessary Cloudformation capabilities required for the update to be performed (CapabilityIam/CapabilityNamedIam/CapabilityAutoExpand). If not provided and the update requires any of this capabilities then the update will fail
-a, --artifacts-to-current-dir <ARTIFACTS_TO_CURRENT_DIR>
Whether or not to save the updated artifacts to the current directory. If not specified the used gets a prompt after the modification and the update occurs [possible values: true, false]
-v, --verbose
Whether to display additional information
-h, --help
Print help
example command:
cfnupd -s my-stack-name -r eu-west-1 -c -e vim
When the command gets triggered it downloads the Cloudformation template file (yaml) and the Cloudformation parameters file (json) in a precreated tmp directory. It then prompts the user to modify those files by opening the configured text editor on the terminal for each file respectively. After the user performs the modifications and saves the files it then performs a cloudformation update on the stack. After the update is successful it prompts the user on whether or not to save the modified artifacts on the current directory.
When the files are not modified by the user then the cli will fail as there are not updates to be performed.
- add tests
Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.