This is Wrapper tool for aws cloudformation create stack.
Project description
cfn-exec
This is Wrapper tool for aws cloudformation create stack.
Installation
- Open AWS Cloudshell or any terminal configured with aws cli.
- Install cfn-exec
pip3 install cfnexec
- Create stack with CFn file or url and parameter file or url
cfn-exec -n $your_stack_name -i $your_cfn_url -p $your_cfn_parameter_url
note: If you are using the nested call function of Cloudformation, you need to make the called file accessible in advance.
cli options
usage: cfn-exec [-h] [-i INPUT_PATH] [-n STACK_NAME] [-p PARAM]
[--role-arn ROLE_ARN] [-s3 S3_BUCKET_URL_PARAMETER_KEY_NAME]
[-csf] [-dr] [-del] [-v] [-V]
optional arguments:
-h, --help show this help message and exit
-i INPUT_PATH, --input-path INPUT_PATH
Cloudformation file url path having Cloudformation
files. Supported yaml and json. If this path is a
folder, it will be detected recursively.
-n STACK_NAME, --stack-name STACK_NAME
The name that's associated with the stack. The name
must be unique in the Region in which you are creating
the stack.
-p PARAM, --parameter-file PARAM
Parameter file
--role-arn ROLE_ARN The Amazon Resource Name (ARN) of an Identity and
Access Management (IAM) role that CloudFormation
assumes to create the stack. CloudFormation uses the
role's credentials to make calls on your behalf.
CloudFormation always uses this role for all future
operations on the stack. Provided that users have
permission to operate on the stack, CloudFormation
uses this role even if the users don't have permission
to pass it. Ensure that the role grants least
privilege. If you don't specify a value,
CloudFormation uses the role that was previously
associated with the stack. If no role is available,
CloudFormation uses a temporary session that's
generated from your user credentials.
-s3 S3_BUCKET_URL_PARAMETER_KEY_NAME, --s3-bucket-url-parameter-key-name S3_BUCKET_URL_PARAMETER_KEY_NAME
Set the parameter key name to this, if the input path
is a local file and you want to reflect the S3 bucket
name to be uploaded in the parameter.
-csf, --change-set-force-deploy
When the target Stack already exists and is to be
deployed as a change set, enabling this option will
apply the change set to the stack as is.
-dr, --disable-roleback
Disable rollback on stack creation failure.
-del, --delete-stack After creating a stack, the stack is deleted
regardless of success or failure.
-v, --version Show version information and quit.
-V, --verbose give more detailed output
parameter file format
Support "Cloudformation official format" or "Simple format" Cloudformation official format
[
{
"ParameterKey": "ParameterKeyName1",
"ParameterValue": "ParameterValue1"
},
{
"ParameterKey": "ParameterKeyName2",
"ParameterValue": "ParameterValue2"
},
...
],
---
- ParameterKey: ParameterKeyName1
ParameterValue: ParameterValue1
- ParameterKey: ParameterKeyName2
ParameterValue: ParameterValue2
...
Simple format
{
"ParameterKeyName1": "ParameterValue1",
"ParameterKeyName2": "ParameterValue2",
...
}
---
ParameterKeyName1: ParameterValue1
ParameterKeyName2: ParameterValue2
...
Nested Template
If the --input-path Cloudformation template has a nested structure that references another template, note the following
- If --input-path is set by URL, all referenced templates must have been placed at the referenced URL in advance.
- If --input-path is set as a local file, the referenced template must be located under the folder where the target local file is located. Also, the referenced URL must be able to be changed via parameters.
Reference to local files with nested structure
This is a reference example of a Cloudformation file with a nested structure set by --input-path.
AWSTemplateFormatVersion: "2010-09-09"
Description: main.yml
Parameters:
TemplateS3BucketURL:
Description: Referenced S3 bucket URL
Type: String
Default: TemplateS3BucketURL
BucketName:
Type: String
Default: BucketName
Resources:
# Create S3 Bucket
S3:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub ${TemplateS3BucketURL}/components/s3.yml
Parameters:
BucketName: !Ref BucketName
This is a reference example of a Cloudformation file with a nested structure set by --input-path.
AWSTemplateFormatVersion: "2010-09-09"
Description: s3.yml
Parameters:
BucketName:
Type: String
Default: "BucketName"
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
This is an example of a parameter file.
TemplateS3BucketURL: TemplateS3BucketURL
BucketName: cfnexec-example-test-01234567890123456789
This is the folder tree of the local file.
.
└── example
├── param.yml
└── input
├── main.yml
└── components
└── s3.yml
This is an example of execution.
cfn-exec -n example-stack -i ./example/input/main.yml -p ./example/param.yml -s3 TemplateS3BucketURL
Usage
Supported Cloudformation and parameter files are written in json or yaml format, and can be located at local, S3, or public URLs.
local file
cfn-exec -n example-stack -i ./example/input/main.yml -p ./example/param.yml
s3 file
cfn-exec -n example-stack -i https://yourbucket.s3.us-east-1.amazonaws.com/main.yml -p https://yourbucket.s3.us-east-1.amazonaws.com/param.yml
public file
cfn-exec -n example-stack -i https://raw.githubusercontent.com/youraccount/yourrepo/main/input/main.yml -p https://raw.githubusercontent.com/youraccount/yourrepo/main/param.yml
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 cfnexec-0.8.8.tar.gz
.
File metadata
- Download URL: cfnexec-0.8.8.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce6897eddfe18f2cc110335ab813171bda698bc97ec60cfec0e27f7c87ebcf9e |
|
MD5 | c9344bc1f8f3632daf32d06200822cf0 |
|
BLAKE2b-256 | 4d0230bd6687bf85e6e4acc76a4231537c2fabc959c0b565d38eba8dbfb30414 |
File details
Details for the file cfnexec-0.8.8-py3-none-any.whl
.
File metadata
- Download URL: cfnexec-0.8.8-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8be2b25cccdd497cf42c0e881ea3ea9c76784a8c393790b9c1e01fdb4b19a32f |
|
MD5 | d77b868b73487e9a53405b568ee76eae |
|
BLAKE2b-256 | 3a04bc9f512cac75fbaf724aaf52adc5e728fdc5f2f94b67bdc8e0480a49829c |