Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gene1wood/1ad3dedf60b1b394f92e6817b20a10d8 to your computer and use it in GitHub Desktop.
Save gene1wood/1ad3dedf60b1b394f92e6817b20a10d8 to your computer and use it in GitHub Desktop.
AWS CloudFormation template that checks if a mapping value is still set to the default/example value, and if so, forces stack creation to fail
AWSTemplateFormatVersion: 2010-09-09
Description: Example ensuring mapping isn't set to it's default
Mappings:
Variables:
AnExampleKey:
# Make sure to set AnExampleVariable before launching this stack
AnExampleVariable: arn:aws:iam::123456789012:root
Conditions:
VariablesNotSet: !Equals [ !FindInMap [ Variables, AnExampleKey, AnExampleVariable ] , 'arn:aws:iam::123456789012:root' ]
Resources:
# If the Mapping variables haven't been set and are still the example values
# fail the creation of the stack by timing out this WaitCondition
VariablesAreNotConfiguredWaitConditionHandle:
Type: AWS::CloudFormation::WaitConditionHandle
Condition: VariablesNotSet
VariablesAreNotConfiguredWaitCondition:
Type: AWS::CloudFormation::WaitCondition
Condition: VariablesNotSet
Properties:
Handle: !Ref VariablesAreNotConfiguredWaitConditionHandle
Timeout: "1"
TestTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: A test sns topic
TopicName: TestSNSTopic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment