I want to add two security group to a lambda function in template. However, it is a conditional statement and i can't find how i can do it. I'm giving an example below:
VpcConfig: SecurityGroupIds: - !If - isProd - !Ref SecurityIds + securityGroup2 - !Ref SecurityIds
SecurityIds is a security group which is referenced. My aim is that if environment is prod then it should be added two security group to the lambda (SecurityIds + SecurityGroup2) if it is not prod just add one security group (SecurityIds). I don't want to add all lambdas the securityGroup2 because of that i can't add this security group to SecurityIds list.
You were quite close. The way it should be is:
VpcConfig: SecurityGroupIds: !If - isProd - [!Ref SecurityIds, securityGroup2] - [!Ref SecurityIds]
Please note all indentations and lack of - before !If.
-
!If
2.1m questions
2.1m answers
60 comments
57.0k users