Code Monkey home page Code Monkey logo

cfnupd's Introduction

Cloudformation Updater (cfnupd)

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.

demo

Supported Platforms

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.

How to install

Prebuilt binaries

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.

Build from source

  1. Download and install rust on your system.
  2. Clone the repository
  3. Run make install

Prerequisites

AWS Credentials

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

Editor

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:

  1. First the environment variable EDITOR is checked.
  2. 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 for EDITOR
  3. If the above true are not correct then the file /.config/cfnupd/config.toml is created and sets the EDITOR parameter equal to nano (as it is ubiquitous on all systems). The user can then further modify that file to provide the preferred editor.

Usage

$ 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

How it works

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.

Expected Behavior

When the files are not modified by the user then the cli will fail as there are not updates to be performed.

Todo

  • add tests

License

Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).

Contribution

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.

cfnupd's People

Contributors

konkerama avatar

Stargazers

 avatar Georgios Varvarigos avatar Georgios Konstantopoulos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.