Skip to content

CLI Usage

ServerlessSam edited this page Jan 31, 2023 · 1 revision

The CLI has following main commands.

Init

Summary

Initialises an instance of BetterCF in the configured AWS account. The IAM role/user must have permissions to create S3 buckets, CloudFormation stacks and SSM parameters. A least-privilege policy will be provided in the future.

Example

bettercf init [-h] [--mode {standard,compliance,governance}]

options:
  -h, --help            show this help message and exit
  --mode {standard,compliance,governance}, -m {standard,compliance,governance}
                        Initialises BetterCF in standard, compliance or governance mode.

Additional Notes

  • The standard mode is selected by default if a --mode isn't provided.

Teardown

Summary

Deletes all BetterCF's AWS resources in the configured account.

Example

bettercf teardown [-h] [--force]

options:
  -h, --help   show this help message and exit
  --force, -f  Will attempt to empty S3 buckets before teardown. Note this will still fail if BetterCF was initialized in "compliance"
               or "governance" mode. You must delete all S3 objects manually.

Additional Notes

  • It will be sad to see you go!

Template Build

Summary

Combines the contents of multiple files to produce a single template file, using dfm

Example

bettercf template build [-h] --name NAME --dfm-config-path DFM_CONFIG_PATH --dfm-root-path DFM_ROOT_PATH

options:
  -h, --help            show this help message and exit
  --name NAME, -n NAME  name of the template
  --dfm-config-path DFM_CONFIG_PATH, -c DFM_CONFIG_PATH
                        complete local path to a dfm config file defining the file merge.
  --dfm-root-path DFM_ROOT_PATH, -r DFM_ROOT_PATH
                        complete local path to the root path the dfm merge should start from.

Additional Notes

If you are using the recommended directory structure for your project, and including this optional build step, the dfm config file found at /.dfm/template_builder.json should be fine. Your dfm root path should be to the directory that contains a directory per template.

Template Push

Summary

Pushes your single CloudFormation template file into BetterCF's Template Repository within your AWS account.

Example

bettercf template push [-h] --name NAME --template-path TEMPLATE_PATH [--template-version TEMPLATE_VERSION]

options:
  -h, --help            show this help message and exit
  --name NAME, -n NAME  name of the template
  --template-path TEMPLATE_PATH, -t TEMPLATE_PATH
                        complete local path to the CloudFormation template to push.
  --template-version TEMPLATE_VERSION, -v TEMPLATE_VERSION
                        The version tag that this template should be pushed with. E.g "1.0.0".

Additional Notes

Remember pushing to a BetterCF instance in compliance mode will mean these templates are immutable and cannot be deleted for 10 years.

Template Deploy

Summary

Deploys a new, or updates an existing AWS CloudFormation stack in the configured AWS account.

Example

bettercf template push [-h] --name NAME --template-path TEMPLATE_PATH [--template-version TEMPLATE_VERSION]

options:
  -h, --help            show this help message and exit
  --name NAME, -n NAME  name of the template
  --template-path TEMPLATE_PATH, -t TEMPLATE_PATH
                        complete local path to the CloudFormation template to push.
  --template-version TEMPLATE_VERSION, -v TEMPLATE_VERSION
                        The version tag that this template should be pushed with. E.g "1.0.0".
(cloudformation-state-management-py3.11) bash-3.2$ python src/cli.py stack deploy --help
usage: cli.py stack deploy [-h] --stack-config-path STACK_CONFIG_PATH

options:
  -h, --help            show this help message and exit
  --stack-config-path STACK_CONFIG_PATH, -c STACK_CONFIG_PATH
                        complete path to the stack config file.

Additional Notes

To understand what is required inside a stack configuration file, see here

Clone this wiki locally