我需要一些与创建 AWS 策略相关的帮助。
我需要一个链接到 EC2 实例的策略,以便能够仅将 a 提供给get-parameters-by-path
AWS SSM 参数存储中的特定参数,而不能更改 、 等任何内容Delete
,Create
并且应该只能获取这些值。
此策略特异性将通过标签给出。
这是我正在尝试使用的政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ssm:*"],
"Resource": ["*"]
},
{
"Effect": "Deny",
"Action": [
"ssm:PutParameter",
"ssm:GetParameter",
"ssm:GetParameters",
"ssm:DeleteParameter",
"ssm:GetParameterHistory",
"ssm:DeleteParameters",
"ssm:GetParametersByPath"
],
"Resource": ["*"],
"Condition": {
"StringNotEquals": {
"ssm:resourceTag/env": "development-1"
}
}
}
]
}
使用AWS 策略模拟器,它会通知您,当尝试View
, Create
,时Modify
,会通知Delete
带有拒绝消息的参数"ssm:resourceTag/env": "development-2"
,而其他项目"ssm:resourceTag/env": "development-1"
可以修改、查看等。
但是,当将同一策略绑定到 EC2 实例时,该策略会阻止在拒绝中添加的任何操作。
EC2 通知消息:
/development-1/project-1
aws --region us-east-2 ssm get-parameters-by-path --path /development-1/project-1/ --recursive --with-decryption --output text --query "Parameters[].[Value]"
An error occurred (AccessDeniedException) when calling the GetParametersByPath operation: User: arn:aws:sts::111111111:assumed-role/rule-ec2/i-11111111111 is not authorized to perform: ssm:GetParametersByPath on resource: arn:aws:ssm:us-east-2:11111111111:parameter/development-1/project-1/ with an explicit deny
/development-2/project-2
aws --region us-east-2 ssm get-parameters-by-path --path /development-2/project-2/ --recursive --with-decryption --output text --query "Parameters[].[Value]"
An error occurred (AccessDeniedException) when calling the GetParametersByPath operation: User: arn:aws:sts::11111111111:assumed-role/rule-ec2/i-11111111111 is not authorized to perform: ssm:GetParametersByPath on resource: arn:aws:ssm:us-east-2:11111111111:parameter/development-2/project-2/ with an explicit deny
使用的标签:
键=值
/development-1/project-1
:
环境=发展-1
/development-2/project-2
:
环境=发展-2
我究竟做错了什么?