Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

amazon web services - Adding more than one security group to AWS lambda Function in template

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.

question from:https://stackoverflow.com/questions/65844768/adding-more-than-one-security-group-to-aws-lambda-function-in-template

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...