Package: nn-cfnctl
CloudFormation ControlAbout The ProjectCloud Formation Control (cfnctl) is a commandline utility based of the AWS CLI Deploy features.
On top of existing deployment capabilities it adds the ability to specify a configuration file to easily supply the following parameters to your CloudFormation deployment:StackNameAwsRegionStackParametersStackTagsSupplying your CloudFormation template with a config containing the above parameters, and a set of commandline arguments or environment variables, it makes it easier to deploy CloudFormation templates both from your local development machine as well as a pipeline using the same pipelines and configurations.Built WithThis project is build using the following tools and frameworks:PythonBoto3TyperPoetryGetting StartedIn order to get started with developing and contributing to this project, follow the steps below.Prerequisitespipx (Optional)This project is build and managed by poetry, the easiest way to install poetry in an isolated environment is usingpipx.python-mpipinstall--userpipx
python-mpipxensurepathPoetryIf you installed pipx, you can simply install poetry using the command below:pipxinstallpoetryIf you did not install pipx, seePoetry documentationfor installation method for your system.InstallationClone the repositorygitclonehttps://novonordiskit@dev.azure.com/novonordiskit/GITO-HS/_git/aws-cfnctlChange directory into the cloned repositorycdaws-cfnctlInstall dependencies into a virtual environment with poetrypoetryinstallActivate virtual environment with poetrypoetryshellUsageWhen installed somewhere on the system included in the systems PATH, the application can be called withcfnctl.To see all available options for the CLI run:cfnctl--helpThecfnctlcommand has two primary subcommands:cfnctl plancfnctl applycfnctl plancfnctl plancreates a new stack plan, or if the stack already exists, a change set plan for AWS CloudFormation.
The resulting plan can then be used withcfnctl applyto execute the stack / change set and provision it in AWS.If you wish to execute the plan immediately, set the--auto-applycommandline flag or use theCFNCTL_AUTO_APPLY = $TRUE.Thecfnctl plancommand requires the following options:--name "CloudFormation change set name."--description "CloudFormation change set description."--template "Relative or absolute filepath pointing to CloudFormation template file."--config "Relative or absolute filepath pointing to CloudFormation template config file."--output "Relative or absolute filepath for resulting change set file."The following settings can be set optionally:--export-stack "Export the Stack ID as an Azure DevOps pipeline variable with this name."--export-changeset "Export the change set ID as an Azure DevOps pipeline variable with this name."--export-outputs "Exports the stack output as Azure DevOps pipeline variables."--auto-apply "If set to true, changeset will be created then executed"cfnctl applycfnctl applyexecutes a stack plan, or if the stack already exists, executes a change set with AWS CloudFormation.
The command requires a plan file created with thecfnctl plancommand.Thecfnctl plancommand requires the following options:--name "CloudFormation change set name."--description "CloudFormation change set description."--template "Relative or absolute filepath pointing to CloudFormation template file."--config "Relative or absolute filepath pointing to CloudFormation template config file."--output "Relative or absolute filepath for incoming change set file."The following settings can be set optionally:--export-stack "Export the Stack ID as an Azure DevOps pipeline variable with this name."--export-changeset "Export the change set ID as an Azure DevOps pipeline variable with this name."--export-outputs "Exports the stack output as Azure DevOps pipeline variables."Environment variablesInstead of using commandline parameters, it is possible to configure thecfnctl planandcfnctl applycommands using environment variables.PowerShell environment variablesSetting environment variables in PowerShell:$env:CFNCTL_CHANGESET_NAME="MyChangeSet"$env:CFNCTL_CHANGESET_DESCRIPTION="Change Set for my stack"$env:CFNCTL_TEMPLATE_PATH="my-cfn-template-file.yml"$env:CFNCTL_STACK_CONFIG_PATH="my-cfnctl-config-file.yml"$env:CFNCTL_PLAN_OUTPUT_PATH="cfn-output-file.yml"# Optional$env:CFNCTL_STACK_ID_EXPORT_VAR="CFNCTL_STACK_ID"$env:CFNCTL_CHANGESET_ID_EXPORT_VAR="CFNCTL_CHANGESET_ID"$env:CFNCTL_EXPORT_STACK_OUTPUT=$TRUE$env:CFNCTL_AUTO_APPLY=$TRUEYou can validate the values is set correctly in your shell with:Get-Item-PathEnv:*|Where-Object{$_.name-like"CFNCTL_*"}Bash environment variablesSetting Environment variables in Bash:exportCFNCTL_CHANGESET_NAME="MyChangeSet"exportCFNCTL_CHANGESET_DESCRIPTION="Change Set for my stack"exportCFNCTL_TEMPLATE_PATH="my-cfn-template-file.yml"exportCFNCTL_STACK_CONFIG_PATH="my-cfnctl-config-file.yml"exportCFNCTL_PLAN_OUTPUT_PATH="cfn-output-file.yml"# OptionalexportCFNCTL_STACK_ID_EXPORT_VAR="CFNCTL_STACK_ID"exportCFNCTL_CHANGESET_ID_EXPORT_VAR="CFNCTL_CHANGESET_ID"exportCFNCTL_EXPORT_STACK_OUTPUT=trueexportCFNCTL_AUTO_APPLY=trueYou can validate the values is set correctly in your shell with:env|grep'CFNCTL_'