Reputation: 976
I have a template that includes 3 resources. Is there a way to programmatically exclude 1 of the 3 resources by using a Parameter of my template?
(that is having the same result that i would get by commenting out the unwanted resource in my template)
Upvotes: 0
Views: 611
Reputation: 238081
It depends. Since you haven't specified any template, I can only show what I usually do.
Parameters:
SubnetId:
Type: String
Default: ''
Conditions:
HaveSubnetId:
!Not [!Equals [!Ref SubnetId, '']]
Resources:
MyInstance:
Condition: HaveSubnetId
Type: AWS::EC2::Instance
In this example, MyInstance
is going to be created if SubnetId
is given (i.e., not empty). If SubnetId
is provided, HaveSubnetId
will be true.
This is based on Condition section in a resource declaration.
Upvotes: 2