Edit or delete a policy
Change a custom policy's document, name or description, or delete the policy and detach it everywhere.
Only custom policies can be changed. Managed policies are maintained by Deutsche Cloud; to change what one grants, copy its document into a custom policy (see Create a policy). Replace policy-id with the policy's id.
Prerequisites
- To edit,
iam:UpdatePolicyon the policy. To delete,iam:DeletePolicy. - In the console, also
iam:ListPoliciesto see Policies andiam:GetPolicyon the policy to open it (without it the page is not found).
Edit the document
A change applies to every user, group and role that holds the policy, from their next request on.
- Open Identity, choose Policies, then the policy.
- Choose Document, then Edit. A managed policy has no Edit.
- Change the JSON, then choose Save document. The document is checked as you type; an unchanged document is not saved.
The console changes the document only; the name and the description change through the CLI, the API or Terraform.
dcloud iam policies update policy-id \
--document '{"Version":"2024-01-01","Statement":[{"Effect":"Allow","Action":["s3:GetObject"],"Resource":["*"]}]}'--name and --description change the name and the description.
PATCH /iam/api/policies/9b2e4c1a-7d3f-4e8a-b6c5-0a1b2c3d4e5f
{ "description": "Read objects in every bucket" }Change document on the dcloud_iam_policy resource and apply.
The new document is checked the same way as at creation; see Create a policy.
Delete the policy
Warning
Every user, group and role holding the policy loses its permissions the moment it is deleted.
- Open the policy, then choose Danger zone.
- Choose Delete policy, type the policy name, and confirm.
dcloud iam policies delete policy-idDELETE /iam/api/policies/9b2e4c1a-7d3f-4e8a-b6c5-0a1b2c3d4e5fRemove the dcloud_iam_policy resource and its attachments from your configuration and apply.
Deleting detaches the policy from everyone who held it.
If the change is refused
- 400
Cannot modify a managed policyorCannot delete a managed policy. - 400
Invalid policy document: …for a document that does not pass the checks.