I did create a sns topic. However I wanna deploy it in multiple environments staging and prod. Like the code below for each environment.
MySNSTopic:
MySNSTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: mytopic
Subscription:
- Protocol:
Endpoint:
- Protocal:
Endpoint:
Parameters:
Mappings:
snsProtocol:
qa: Email
stg: Email
prd: https
snsEndpoint:
qa: Email
stg: Email
prd: https
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
Parameters: Mappings: snsProtocol: qa: Email stg: Email prd: https snsEndpoint: qa: Email stg: Email prd: https
CodePudding user response:
You need to provide Conditions in CloudFormation template. That will get used while creating resource. Something like below.
Parameters:
EnvType:
Description: Environment type.
Default: test
Type: String
AllowedValues:
- prod
- test
ConstraintDescription: must specify prod or test.
Conditions:
CreateProdResources: !Equals
- !Ref EnvType
- prod
CodePudding user response:
Consider using Fn::FindInMap:
Parameters:
EnvType:
Default: qa
Type: String
AllowedValues:
- qa
- stg
- prd
Mappings:
SettingsMap:
qa:
Protocol: Email
Endpoint: Email
stg:
Protocol: Email
Endpoint: Email
prd:
Protocol: https
Endpoint: https
and then:
Subscription:
Protocol: !FindInMap
- SettingsMap
- !Ref EnvType
- Protocol