edit-icon download-icon

CreatePolicy

Last Updated: Nov 10, 2017

Interface description

Creates an authorization policy.

Request parameters

Action

  • Type: String
  • Required: Yes
  • Description: Required. The parameter value is “CreatePolicy”.

PolicyName

  • Type: String
  • Required: Yes
  • Description: Authorization policy name. It consists of a maximum of 128 characters.
  • Format: ^[a-zA-Z0-9\-]+$

Description

  • Type: String
  • Required: No
  • Description: Authorization policy description. It consists of a maximum of 1,024 characters.

PolicyDocument

  • Type: String
  • Required: Yes
  • Description: Authorization policy content. It consists of a maximum of 2,048 characters.

Return parameters

Policy

  • Type: Policy Type
  • Description: Authorization policy content.

Required permissions

Action

ram:CreatePolicy

Resource

acs:ram:*:${AccountId}:policy/*

Error messages

InvalidParameter.PolicyName.InvalidChars
  • HTTP Status: 400
  • Error Message: The parameter - “PolicyNam” contains invalid chars.
InvalidParameter.PolicyName.Length
  • HTTP Status: 400
  • Error Message: The parameter - “PolicyName” beyond the length limit.
InvalidParameter.PolicyDocument.Length
  • HTTP Status: 400
  • Error Message: The parameter - “PolicyName” beyond the length limit.
InvalidParameter.Description.Length
  • HTTP Status: 400
  • Error Message: The parameter - “Description” beyond the length limit.
MalformedPolicyDocument
  • HTTP Status: 400
  • Error Message: {The error details}
EntityAlreadyExists.Policy
  • HTTP Status: 409
  • Error Message: The group does already EXIST.
LimitExceeded.Policy
  • HTTP Status: 409
  • Error Message: The count of policy beyond the current limits.

Operation examples

Request example

  1. https://ram.aliyuncs.com/?Action=CreatePolicy
  2. &PolicyName=OSS-Administrator
  3. &PolicyDocument={ "Statement": [{ "Action": ["oss:*"], "Effect": "Allow", "Resource": ["acs:oss:*:*:*"]}], "Version": "1"}
  4. &Description=OSS administrator permission
  5. &<Public request parameters>

Return example

XML format

  1. <CreatePolicyResponse>
  2. <RequestId>9B34724D-54B0-4A51-B34D-4512372FE1BE</RequestId>
  3. <Policy>
  4. <PolicyName>OSS-Administrator</PolicyName>
  5. <PolicyType>Custom</PolicyType>
  6. <Description>OSS administrator permission</Description>
  7. <DefaultVersion>v1</DefaultVersion>
  8. <CreateDate>2015-01-23T12:33:18Z</CreateDate>
  9. </Policy>
  10. </CreatePolicyResponse>

JSON format

  1. {
  2. "RequestId": "9B34724D-54B0-4A51-B34D-4512372FE1BE",
  3. "Policy": {
  4. "PolicyName": "OSS-Administrator",
  5. "PolicyType": "Custom",
  6. "Description": "OSS administrator permission",
  7. "DefaultVersion": "v1",
  8. "CreateDate": "2015-01-23T12:33:18Z"
  9. }
  10. }
Thank you! We've received your feedback.