我正在通過 cloudformation 創建一些 IAM 角色和策略,但我想根據我擁有的條件添加策略,如果它是 dev,那么我想添加某些策略宣告。有什么建議 ?
Parameters:
environment:
Type: String
Default: dev
AllowedValues:
- dev
- prd
Condition:
isDev: !Equals [ !Ref environment, dev]
Resources:
StandAlonePolicy:
Type: AWS::IAM::Policy
Properties:
#How to add a condition - isDev
PolicyName: "s3-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Resource: "*"
Action:
- "s3:Get*"
uj5u.com熱心網友回復:
您可以使用If執行此操作:
Parameters:
environment:
Type: String
Default: dev
AllowedValues:
- dev
- prd
Conditions:
isDev: !Equals [ !Ref environment, dev]
Resources:
StandAlonePolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: "s3-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Resource: "*"
Action:
- "s3:Get*"
- !If
- isDev
- Sid: new-statement-for-dev-only
Effect: Allow
Resource: "*"
Action:
- "s3:Put*"
- !Ref "AWS::NoValue"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/344652.html
上一篇:處理-根據jpg尺寸調整畫布大小
下一篇:我在標簽編輯器中有很多AWS資源
