This repository stores CloudFormation templates created as examples for the article Use Conditions to create reusable CloudFormation templates posted on www.thenindiecoder.cloud.
You need to have the AWS CLI installed and properly configured.
Template file: cf-conditions-resource-level.yml.
To create a cloudFormation stack from this template, one for each environment, run the following commands:
aws cloudformation create-stack --stack-name cf-conditions-resource-test --template-body file://cf-conditions-resource-level.yml --parameters ParameterKey=Environment,ParameterValue=test
aws cloudformation create-stack --stack-name cf-conditions-resource-prod --template-body file://cf-conditions-resource-level.yml --parameters ParameterKey=Environment,ParameterValue=prod
Template file: cf-conditions-property-level.yml.
To create a cloudFormation stack from this template, one for each environment, run the following commands:
aws cloudformation create-stack --stack-name cf-conditions-property-test --template-body file://cf-conditions-property-level.yml --parameters ParameterKey=Environment,ParameterValue=test
aws cloudformation create-stack --stack-name cf-conditions-property-prod --template-body file://cf-conditions-property-level.yml --parameters ParameterKey=Environment,ParameterValue=prod
Template file: cf-conditions-property-level-noValue.yml.
To create a cloudFormation stack from this template, one for each environment, run the following commands:
aws cloudformation create-stack --stack-name cf-conditions-property-noValue-test --template-body file://cf-conditions-property-level-noValue.yml --parameters ParameterKey=Environment,ParameterValue=test
aws cloudformation create-stack --stack-name cf-conditions-property-noValue-prod --template-body file://cf-conditions-property-level-noValue.yml --parameters ParameterKey=Environment,ParameterValue=prod
Template file: cf-conditions-nested-conditions.yml.
To create a cloudFormation stack from this template, one for each environment, run the following commands:
aws cloudformation create-stack --stack-name cf-conditions-nested-conditions-dev --template-body file://cf-conditions-nested-conditions.yml --parameters ParameterKey=Environment,ParameterValue=dev
aws cloudformation create-stack --stack-name cf-conditions-nested-conditions-test --template-body file://cf-conditions-nested-conditions.yml --parameters ParameterKey=Environment,ParameterValue=test
aws cloudformation create-stack --stack-name cf-conditions-nested-conditions-prod --template-body file://cf-conditions-nested-conditions.yml --parameters ParameterKey=Environment,ParameterValue=prod
๐จ Stacks CLEAN UP: Remember to delete all your stacks to avoid unwanted costs ๐จ
Run the following command for each of the stacks you created. Replace myteststack with the actual name of the stack you want to delete.
aws cloudformation delete-stack --stack-name myteststack