云生成不会像模板中描述的那样生成我的策略。
我想在我的角色中创建/重新创建这个精确的策略。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudWatch:ListDashboards"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "cloudwatch:GetDashboard",
"Resource": "arn:aws:cloudwatch::xxxx:dashboard/test"
}
]
}这是我的云形成模板(请参阅策略):
CustomResourceRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName:
!Sub
- Cloudwatch${PolicyCustomName}DashboardAccessPolicy
- { PolicyCustomName: !Ref Tenant }
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: [
"cloudWatch:ListDashboards"
]
Resource: '*'
Action: 'cloudwatch:GetDashboard'
Resource: 'arn:aws:cloudwatch::xxxx:dashboard/Test'
RootInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref CustomResourceRole但是,这并不会生成所需的策略。我失去了我想要的政策的第一部分,为什么呢?
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "cloudwatch:GetDashboard",
"Resource": "arn:aws:cloudwatch::xxxx:dashboard/Test",
"Effect": "Allow"
}
]
}发布于 2020-08-24 13:37:02
您为相同的Action提供了两个Statement,云形成引擎使用了后者,覆盖了cloudWatch:ListDashboards。
由于Statement是一个列表,所以可以编写以下两条语句:
CustomResourceRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName:
!Sub
- Cloudwatch${PolicyCustomName}DashboardAccessPolicy
- { PolicyCustomName: !Ref Tenant }
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: "cloudWatch:ListDashboards"
Resource: '*'
- Effect: Allow
Action: 'cloudwatch:GetDashboard'
Resource: 'arn:aws:cloudwatch::xxxx:dashboard/Test'
RootInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref CustomResourceRolehttps://stackoverflow.com/questions/63561976
复制相似问题