Create a policy
Write a customer-managed policy, in the console's builder or as JSON, before you attach it to anyone.
Last updated 18 November 2026View as Markdown
A policy grants nothing until it is attached to a user, a group or a role. Replace S3ReadMyBucket with the policy's name and org-EXAMPLE1234 with your organization id. For the language itself, see Policy documents.
Prerequisites
- Permission for
iam:CreatePolicy. - In the console, also
iam:ListPolicies: the Policies list, where Create policy is, shows nothing else without it.
Write the policy
- Open Identity, then choose Policies.
- Choose Create policy.
- For Policy name, enter S3ReadMyBucket. (Optional) For Description, say what it is for.
- Under Permissions, write the document in one of four tabs:
- Quick: choose None, Read-only or Full per service. The result applies to every resource in the organization.
- Statements: one or more statements, each with an effect, its actions and a Resource.
- JSON: the document itself.
- Templates: start from a managed policy's document and change it.
- Choose Create policy. The console returns to the list of policies.
Each tab submits what it shows. Leaving Quick or Statements copies what you built into the JSON tab.
dcloud iam policies create --name S3ReadMyBucket \
--document '{"Version":"2024-01-01","Statement":[{"Effect":"Allow","Action":["s3:GetObject","s3:ListObjects"],"Resource":["rn:ews::org-EXAMPLE1234:s3:*"]}]}'The document is sent as JSON text inside the request:
POST /iam/api/policies
{ "name": "S3ReadMyBucket", "document": "{\"Version\":\"2024-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:GetObject\"],\"Resource\":[\"*\"]}]}" }resource "dcloud_iam_policy" "s3_read" {
name = "S3ReadMyBucket"
document = jsonencode({
Version = "2024-01-01"
Statement = [{
Effect = "Allow"
Action = ["s3:GetObject", "s3:ListObjects"]
Resource = ["rn:ews::${var.org_id}:s3:*"]
}]
})
}Result
The policy is listed under Policies as a custom policy. Attach it to put it into effect; see Attach a policy.
If the policy is refused
The document is checked before it is stored. Refusals are 400 with the statement and the reason:
Invalid policy document: Invalid JSONInvalid policy document: Statement[0] references unknown action "s3:GetObjekt": every action pattern must match at least one action.Invalid policy document: Statement[0] has invalid resource "…": a resource is*or a resource name.Invalid policy document: Statement[0].Condition.…: an operator or key outside the supported ones, or a value that cannot be read; see Policy documents.- 409
Quota exceeded: …when the organization has as many custom policies as its quota allows; see Quotas.
Related
- Edit or delete a policy
- Test access with the policy simulator: try a draft before you save it.
POST /iam/api/policies·dcloud iam policies create·dcloud_iam_policy
Did this page help you?
Related