Skip to content

Environment Variable Overrides

FORCE_COLOR: set this to true to force color output. This is needed for CI pipelines which will not pass Clicks "is this a valid tty" test.

CLI Options

cfn-cli

AWS CloudFormation CLI - The missing CLI for CloudFormation.

Quickstart: use cfn-cli generate to generate a new project.

cfn-cli operates on a single YAML based config file and can manages stacks across regions & accounts. By default, cfn-cli will try to locate config file cfn-cli.yml in current directory, override this using -f option:

cfn-cli -f some-other-config-file.yaml <command>

If the config contains multiple stacks, they can be can be selected using full qualified stack name:

cfn-cli -s StageName.StackName <command>

Unix style globs is also supported when selecting stacks to operate on: cfn-cli -s Backend.*

By default, command operates on all stacks in every stages, with order specified in the config file.

Options can also be specified using environment variables:

CFN_STACK=StageName.StackName cfn-cli <command>

Usage:

cfn-cli [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
--version boolean Show the version and exit. False
--install-completion boolean Install completion script for the current shell. False
-f, --file path Specify an alternate stack configuration file, default is cfn-cli.yml. None
-s, --stack stack Select stacks to operate on, defined by STAGE_NAME.STACK_NAME, nix glob is supported to select multiple stacks. Default value is "*", which means all stacks in all stages. *
-p, --profile profile Override AWS profile specified in the config file. Warning: Don't use this option on stacks in different accounts. None
-r, --region text Override AWS region specified in the config. Warning: Don't use this option on stacks in different regions. None
-a, --artifact-store text Override artifact store specified in the config. Artifact store isthe s3 bucket used to store packaged template resource. Warning: Don't use this option on stacks in different accounts & regions. ``
-v, --verbose integer range (0 and above) Be more verbose, can be specified multiple times. 0
--help boolean Show this message and exit. False

Subcommands

  • drift: Drift detection sub-commands.
  • export: Exports cfn-cli stack configuration.
  • generate: Generate sample configuration file.
  • stack: Stack operation sub-commands.
  • status: Print stack status and resources.
  • validate: Validate template file.

cfn-cli drift

Drift detection sub-commands.

Usage:

cfn-cli drift [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
--help boolean Show this message and exit. False

Subcommands

  • detect: Detect stack drifts.
  • diff: Show stack resource drifts.

cfn-cli drift detect

Detect stack drifts.

Usage:

cfn-cli drift detect [OPTIONS]

Options:

Name Type Description Default
--no-wait, -w boolean Exit immediately after operation is started. False
--no-show-resources, -nr boolean Dont show resources that had drifted. False
--help boolean Show this message and exit. False

cfn-cli drift diff

Show stack resource drifts.

Usage:

cfn-cli drift diff [OPTIONS]

Options:

Name Type Description Default
--help boolean Show this message and exit. False

cfn-cli export

Exports cfn-cli stack configuration.

Exports cfn-cli stack configuration to native AWS CloudFormation CLI JSON files (Parameters, Tags JSON files).

Usage:

cfn-cli export [OPTIONS]

Options:

Name Type Description Default
--output-dir text output export directory to save CloudFormation JSON files for stacks cfn-cli-export
--help boolean Show this message and exit. False

cfn-cli generate

Generate sample configuration file.

Generate a annotated configuration file as cfn-cli.yaml in working directory.

Usage:

cfn-cli generate [OPTIONS]

Options:

Name Type Description Default
--help boolean Show this message and exit. False

cfn-cli stack

Stack operation sub-commands.

Usage:

cfn-cli stack [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
--help boolean Show this message and exit. False

Subcommands

  • cancel: Cancel current stack update.
  • changeset: Changeset operation sub-commands.
  • delete: Delete stacks.
  • deploy: Deploy new stacks.
  • describe: Deprecated, use "status" command instead.
  • sync: Create and execute ChangeSets (SAM)
  • tail: Tailing stack events.
  • update: Update existing stacks.

cfn-cli stack cancel

Cancel current stack update.

Only works if stack being canceled is in "UPDATING" status.

Usage:

cfn-cli stack cancel [OPTIONS]

Options:

Name Type Description Default
--no-wait, -w boolean Exit immediately after operation is started. False
--help boolean Show this message and exit. False

cfn-cli stack changeset

Changeset operation sub-commands.

Usage:

cfn-cli stack changeset [OPTIONS] COMMAND [ARGS]...

Options:

Name Type Description Default
--help boolean Show this message and exit. False

Subcommands

  • create: Create a ChangeSet
  • exec: Execute a existing ChangeSet
cfn-cli stack changeset create

Create a ChangeSet

Combines "aws cloudformation package" and "aws cloudformation create-change-set" command into one.If stack is not created yet, a CREATE type ChangeSet is created, otherwise UPDATE ChangeSet is created.

Usage:

cfn-cli stack changeset create [OPTIONS]

Options:

Name Type Description Default
--use-previous-template boolean Reuse the existing template that is associated with the stack that you are updating. False
--ignore-no-update, -i boolean Ignore error when there are no updates to be performed. False
--disable-nested boolean Disable creation of nested changesets False
--show-physical-ids boolean Shows physical ID of changeset produced False
--store boolean Store changeset ARNS for execution in subsequent command False
--output text file path of changeset file store (Default .cfn-cli-changesets) .cfn-cli-changesets
--help boolean Show this message and exit. False
cfn-cli stack changeset exec

Execute a existing ChangeSet

Combines "aws cloudformation package" and "aws cloudformation create-change-set" command into one.If stack is not created yet, a CREATE type ChangeSet is created, otherwise UPDATE ChangeSet is created.

Usage:

cfn-cli stack changeset exec [OPTIONS]

Options:

Name Type Description Default
--disable-tail-events boolean Disable tailing of cloudformation events False
--show-physical-ids boolean Shows physical IDs in tail events False
--ignore-no-exists, -i boolean Ignore error when there are no changeset for selected stack. False
--disable-rollback boolean Disable rollback if stack update fails. You can specify either DisableRollback or OnFailure, but not both. Setting this option overwrites "DisableRollback" in the stack configuration file. False
--input text file path of changeset file store (Default .cfn-cli-changesets) .cfn-cli-changesets
--help boolean Show this message and exit. False

cfn-cli stack delete

Delete stacks.

By default this command will abort if the stack being deleted does not exist, ignore this using --ignore-missing option.

Usage:

cfn-cli stack delete [OPTIONS]

Options:

Name Type Description Default
--quiet, -q boolean Suppress warning if more than one stack is being deleted. False
--no-wait, -w boolean Exit immediately after delete is started. False
--show-physical-ids boolean Shows physical IDs in tail events False
--ignore-missing, -i boolean Don't exit with error if the stack is missing. False
--help boolean Show this message and exit. False

cfn-cli stack deploy

Deploy new stacks.

Usage:

cfn-cli stack deploy [OPTIONS]

Options:

Name Type Description Default
--no-wait, -w boolean Exit immediately after deploy is started. False
--show-physical-ids boolean Shows physical IDs in tail events False
--on-failure choice (DO_NOTHING | ROLLBACK | DELETE) Determines what action will be taken if stack creation fails. This must be one of: DO_NOTHING, ROLLBACK, or DELETE. Setting this option overwrites "OnFailure" in the stack configuration file. None
--disable-rollback boolean Disable rollback if stack creation failed. You can specify either DisableRollback or OnFailure, but not both. Setting this option overwrites "DisableRollback" in the stack configuration file. False
--timeout-in-minutes integer range (between 0 and 180) The amount of time in minutes that can pass before the stack status becomes CREATE_FAILED; if DisableRollback is not set or is set to false , the stack will be rolled back. Sentinel.UNSET
--ignore-existing, -i boolean Don't exit with error if the stack already exists. False
--help boolean Show this message and exit. False

cfn-cli stack describe

Deprecated, use "status" command instead.

Usage:

cfn-cli stack describe [OPTIONS]

Options:

Name Type Description Default
--stack-resources, -r boolean Display stack resources. True
--stack-exports, -e boolean Display stack exports. True
--help boolean Show this message and exit. False

cfn-cli stack sync

Create and execute ChangeSets (SAM)

Combines "aws cloudformation package" and "aws cloudformation deploy" command into one. If stack is not created yet, a CREATE type ChangeSet is created, otherwise UPDATE ChangeSet is created.

Usage:

cfn-cli stack sync [OPTIONS]

Options:

Name Type Description Default
--no-wait, -w boolean Exit immediately after ChangeSet is created. False
--confirm boolean Review changes before execute the ChangeSet False
--ignore-no-update, -i boolean Ignore error when there are no updates to be performed. False
--use-previous-template boolean Reuse the existing template that is associated with the stack that you are updating. False
--disable-rollback boolean Disable rollback if stack update fails. You can specify either DisableRollback or OnFailure, but not both. Setting this option overwrites "DisableRollback" in the stack configuration file. False
--disable-tail-events boolean Disable tailing of cloudformation events False
--show-physical-ids boolean Shows physical IDs in tail events False
--disable-nested boolean Disable creation of nested changesets False
--help boolean Show this message and exit. False

cfn-cli stack tail

Tailing stack events.

This command will only select first one if mutable stacks matches stack selector.

Usage:

cfn-cli stack tail [OPTIONS]

Options:

Name Type Description Default
--timeout, -t integer range (between 0 and 3600) wait time in seconds before exit 300
--events, -n integer range (between 0 and 100) number of latest stack events, 0 means fetch allstack events 0
--help boolean Show this message and exit. False

cfn-cli stack update

Update existing stacks.

Any stack configuration changes are also applied as well.

Usage:

cfn-cli stack update [OPTIONS]

Options:

Name Type Description Default
--no-wait, -w boolean Exit immediately after update is started. False
--show-physical-ids boolean Shows physical IDs in tail events False
--use-previous-template boolean Reuse the existing template that is associated with the stack that you are updating. False
--disable-rollback boolean Disable rollback if stack update fails. You can specify either DisableRollback or OnFailure, but not both. Setting this option overwrites "DisableRollback" in the stack configuration file. False
--ignore-no-update, -i boolean Ignore error when there are no updates to be performed. False
--override-policy choice (ALLOW_ALL | ALLOW_MODIFY | DENY_DELETE | DENY_ALL) Temporary overriding stack policy during this update.Valid canned policy are: 
ALLOW_ALL: Allows all updates
DENY_DELETE: Allows modify and replace, denys delete
ALLOW_MODIFY: Allows modify, denys replace and delete None
--help boolean Show this message and exit. False

cfn-cli status

Print stack status and resources.

Also includes parameters, resources, outputs & exports.

Usage:

cfn-cli status [OPTIONS]

Options:

Name Type Description Default
--dry-run, -d boolean Don't retrieve stack deployment status (faster). False
--stack-resources, -r boolean Display stack resources. False
--stack-exports, -e boolean Display stack exports. False
--help boolean Show this message and exit. False

cfn-cli validate

Validate template file.

Usage:

cfn-cli validate [OPTIONS]

Options:

Name Type Description Default
--help boolean Show this message and exit. False