Skip to main content

Hook extension for the CloudFormation CLI

Project description

AWS CloudFormation CLI Hooks Extension

The CloudFormation CLI (cfn) allows you to author your own CFN extension providers that can be used by CloudFormation.

This extension library provides more commands for managing and configuring your Resource Hooks.

Documentation

Primary documentation for the CloudFormation CLI can be found at the AWS Documentation site.

Installation

If you are using this package to build hook providers for CloudFormation, install the CloudFormation CLI Hooks Extension - this will automatically install the the CloudFormation CLI! A Python virtual environment is recommended.

pip3 install cloudformation-cli-hooks-extension

Usage

All of these commands are meant to be run from inside your pre-initialized Hooks project directory. You can initialize a new project by using the cfn init command from the CloudFormation CLI. All of the commands use the cfn hook prefix, ex. cfn hook describe.

Command: describe

To get more details about hook versions registered in your account, use the describe command. This will return the following properties:

  • Description
  • Created at
  • Last updated at
  • Default version
  • Failure mode
  • Target stacks
  • Stack filters (if any)
  • Configured properties
  • Target types
  • Testing status

The details for the default version will be returned by deafult. Optionally, the --version-id can be passed to describe a specific version.

cfn hook describe

Sample output:

No version specified, using default version

Selected AWS::CloudFormation::SampleHook version 00000001

Description: Example hook
Version 00000001 Created at: 2023-09-28 04:44:14.402000+00:00
Version 00000001 Last updated at: 2023-09-28 04:44:14.402000+00:00

Current configuration (only applies to default version):
  Default version: 00000001
  Configured behavior:
    Failure mode: WARN
    Target stacks: ALL
    Stack Filters:
      Filtering Criteria: ANY
      StackNames:
        Include: ['stack-name-0', 'stack-name-1', 'stack-name-2']
        Exclude: ['stack-name-3', 'stack-name-4', 'stack-name-5']
      StackRoles:
        Exclude: ['arn:aws:iam::000000000000:role/stack-role-0', 'arn:aws:iam::000000000000:role/stack-role-1', 'arn:aws:iam::000000000000:role/stack-role-2']

  No configured properties.

This Hook is configured to target:
  preCreate:
    AWS::S3::Bucket

Testing status: NOT_TESTED
 Warning: This Type version hasn't been tested yet. Run TestType to test it.

Command: set-default-version

To set a specific version of your hooks as the default version, use the set-default-version command.

cfn hook set-default-version --version-id 1

This command return nothings, but you can then use cfn hook describe to check the default version set in your account.

Command: configure

To set the type configuration of your hook, use the configure command.

You will first need to save your type configuration as a json file and then specify the file path in the command.

cfn hook configure --configuration-path ./myHookTypeConfig.json

Sample output:

ConfigurationArn: arn:aws:cloudformation:us-east-1:000000000000:type-configuration/hook/AWS-CloudFormation-SampleHook/default

Development

For developing, it's strongly suggested to install the development dependencies inside a virtual environment. (This isn't required if you just want to use this tool.)

python3 -m venv env
source env/bin/activate
pip3 install -e /path/to/cloudformation-cli-hooks-extension

Install pytest-cov, used when running unit tests for this plugin:

pip3 install pytest-cov

You may also want to check out the CloudFormation CLI if you wish to make edits to that. In this case, installing them in one operation works well:

pip3 install \
  -e /path/to/cloudformation-cli \
  -e /path/to/cloudformation-cli-hooks-extension

That ensures neither is accidentally installed from PyPI.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Project details


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 cloudformation-cli-hooks-extension-0.1.2.tar.gz.

File metadata

File hashes

Hashes for cloudformation-cli-hooks-extension-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f15d467a74fbdbaa2148e14a8f03617777798c6e8bca8c1742f8dafa85791330
MD5 b4bbc80370342699f4006e0debf7d245
BLAKE2b-256 fec5501b979956595f0616311cf01269a21f0b140f7c69e966b45c7f9713fe47

See more details on using hashes here.

File details

Details for the file cloudformation_cli_hooks_extension-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudformation_cli_hooks_extension-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e9100fe09cb0c9ebd3f6119782c17f96b8796cf31c4f9a049167f0d93a024e2f
MD5 252ffd40a5da39c9ef5e1b390412c709
BLAKE2b-256 2f341ae22c98b47b315f9c8699b23dc0bb55b416bc94d2ac070232962016b1fa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page