Project

cfn-toml

0.0
No release in over a year
Configuration file parsing for CFN Bash scripting
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.1.4

Runtime

>= 2.0.1
 Project Readme

What is Cfn-Toml?

cfn-toml will read a toml file that is designed to be used with CloudFormation CLI commands within a bash script.

How to install

gem install cfn-toml

How to use

Cfn-Toml automatically looks for a file called conf.toml in the working directory.

You can then use the following CLI commands to copy configuration variables into enviroment variables.

Toml file example

[deploy]
profile = 'myprofile'
bucket = 'mybucket'
region = 'us-east-1'
stack_name = 'stack_name'

[parameters]
ArtifactName = 'myartifact'
InstanceType = 't2.micro'

Bash sciprt example

#!/usr/bin/env bash

PROFILE=$(cfn-toml key deploy.profile)
BUCKET=$(cfn-toml key deploy.bucket)
REGION=$(cfn-toml key deploy.region)
STACK_NAME=$(cfn-toml key deploy.stack_name)
PARAMETERS=$(cfn-toml params v2)


# deploying stack
echo "== Deploying stack..."
# -----------------
aws cloudformation deploy \
--profile $PROFILE \
--region $REGION \
--stack-name $STACK_NAME \
--s3-bucket $BUCKET \
--template-file template.yaml" \
--parameter-overrides $PARAMETERS \
--capabilities CAPABILITY_NAMED_IAM

Parameters Versions

There are two versions of parameters based on the AWS CLI syntax

Version1

When you are using commands like aws cloudformation create-stack

cfn-toml parameters v1

It will output as such:

ParameterKey=MyKey,ParameterValue=MyValue ParameterKey=MyKey2,ParameterValue=MyValue2

Version2

When you are using commands like aws cloudformation deploy

cfn-toml parameters v2

It will output as such:

MyKey1=MyValue1 MyKey2=MyValue2

Specify Toml Filepath

You can override the default path for toml cfn-toml parameters v1 --toml /path/to/myconfig.dev.toml