編輯靜態政策
您可以使用 UpdatePolicy 操作編輯靜態政策。下列範例會編輯簡單的靜態政策。
此範例使用 檔案definition.txt來包含政策定義。
{
"static": {
"description": "Grant everyone of janeFriends UserGroup access to the vacationFolder Album",
"statement": "permit(principal in UserGroup::\"janeFriends\", action, resource in Album::\"vacationFolder\" );"
}
}
下列命令參考該檔案。
$ aws verifiedpermissions create-policy \
--definition file://definition.txt \
--policy-store-id PSEXAMPLEabcdefg111111
{
"createdDate": "2023-06-12T20:33:37.382907+00:00",
"lastUpdatedDate": "2023-06-12T20:33:37.382907+00:00",
"policyId": "SPEXAMPLEabcdefg111111",
"policyStoreId": "PSEXAMPLEabcdefg111111",
"policyType": "STATIC",
"principal": {
"entityId": "janeFriends",
"entityType": "UserGroup"
},
"resource": {
"entityId": "vacationFolder",
"entityType": "Album"
}
}
更新政策的名稱
您可以在更新政策時設定或更新政策名稱。對於政策存放區中的所有政策,名稱必須是唯一的,字首必須是 name/。如果您未在更新請求中包含名稱欄位,則現有名稱保持不變。若要移除名稱,請將其設定為空字串。
$ aws verifiedpermissions update-policy \
--policy-id SPEXAMPLEabcdefg111111 \
--policy-store-id PSEXAMPLEabcdefg111111 \
--definition file://definition.txt \
--name name/example-policy
{
"createdDate": "2023-06-12T20:33:37.382907+00:00",
"lastUpdatedDate": "2023-06-12T20:47:42.804511+00:00",
"policyId": "SPEXAMPLEabcdefg111111",
"policyStoreId": "PSEXAMPLEabcdefg111111",
"policyType": "STATIC",
"principal": {
"entityId": "janeFriends",
"entityType": "UserGroup"
},
"resource": {
"entityId": "vacationFolder",
"entityType": "Album"
}
}