本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
此範例顯示如何建立身分型政策,授予使用者對具有相同標籤的安全群組採取特定動作的許可。此政策會授予許可以在 Amazon EC2 主控台中檢視安全群組,並針對具有 Department=Test
標籤的現有安全群組新增和移除傳入與傳出規則,以及列出和修改規則說明。此政策定義了程式設計和主控台存取的許可。若要使用此政策,請將範例政策中的斜體預留位置文字
取代為您自己的資訊。然後,遵循建立政策或編輯政策中的指示進行操作。
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"ec2:DescribeSecurityGroups",
"ec2:DescribeSecurityGroupRules",
"ec2:DescribeTags"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupIngress",
"ec2:RevokeSecurityGroupIngress",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:RevokeSecurityGroupEgress",
"ec2:ModifySecurityGroupRules",
"ec2:UpdateSecurityGroupRuleDescriptionsIngress",
"ec2:UpdateSecurityGroupRuleDescriptionsEgress"
],
"Resource": [
"arn:aws:ec2:region:111122223333
:security-group/*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/Department": "Test"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:ModifySecurityGroupRules"
],
"Resource": [
"arn:aws:ec2:region:111122223333
:security-group-rule/*"
]
}
]
}