![](/img/trans.png)
[英]Is there a way to reference a security group from a previous Cloudformation stack in a new CF stack?
[英]Why this Security Group is not being created in CloudFormation Stack?
我正在嘗試創建一個安全組並根據 Fn::If 固有 function 命名它。
Parameters:
Environment:
Type: String
Description: Select Environment, Default is DEMO
Default: DEMO
AllowedValues: [ PROD, DEMO, QA, PERF, STAGING, INTEGRATION ]
Conditions:
SGEnvironment: !Equals [!Ref Environment, PROD]
Resources:
SG:
Type: AWS::EC2::SecurityGroup
Condition: SGEnvironment
Properties:
GroupName: !If [ SGEnvironment,"PROD-SG","NON-PROD-SG"]
安全組在條件為真時創建,但在條件為假時不會創建。
除了選擇產品以外的其他環境參數時,不會創建安全組。
如果您想一直創建 SG,請刪除Condition: SGEnvironment
。 使用Condition: SGEnvironment
,行為與您提到的相同。
請參閱此處了解更多信息。
完美,它按預期工作。 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.