aws-cloudformation / cloudformation-cli

The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Apache License 2.0
318 stars 161 forks source link

Support for extending cfn cli with custom commands #1020

Closed TheChouzanOne closed 1 year ago

TheChouzanOne commented 1 year ago

Issue #, if available: NA

Description of changes:

This change enables custom plugins to be developed under the rpdk.v1.extensions entrypoint to extend cfn functionality. E.g. developing a new hello command:

cfn hello --name Adrian

Hello, Adrian!

In this change, I introduce the ExtensionPlugin abstract base class, which has 2 methods. command_name determines what the command will be (e.g. hello in the above example). This registers a subparser under cfn. The second method is setup_parser which should be implemented in the child class to setup any arguments and behaviors required (e.g. --name parameter and printing Hello, Adrian! in examble above)

The way a new extension can be setup is the same way as other plugins already developed, where you simply pip install the package in your environment.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.