CreatePolicy#

Description#

Creates a new IAM policy.

Request Parameters#

Required parameters#

  • Document — Policy-defined access rules in JSON format.

    • Type: String

    • Required: Yes

  • PolicyName — The name of the policy.

    • Type: String

    • Required: Yes

  • Type — The type of the policy.

    • Type: String

    • Required: Yes

Optional parameters#

  • Description — The description of the policy.

    • Type: String

    • Required: No

Response Elements#

  • Policy — New policy details.

Examples#

Request

https://iam.k2.cloud/?Action=CreatePolicy
&Description=Policy example
&Document={"Statement": [{"Action": ["iam:ListUsers"]}]}
&PolicyName=policy-1
&Type=global

Response

<CreatePolicyResponse>
    <CreatePolicyResult>
        <Policy>
            <PolicyArn>arn:c2:iam::c2dev:policy/policy-1</PolicyArn>
            <PolicyId>2cec7683-7ecf-470f-b3f1-498a140752da</PolicyId>
            <PolicyName>policy-1</PolicyName>
            <Owner>self</Owner>
            <Type>global</Type>
            <CreateDate>1724418895</CreateDate>
            <UpdateDate>1724418895</UpdateDate>
            <Description>Policy example</Description>
        </Policy>
    </CreatePolicyResult>
    <requestId>806cbf6d-ae2e-4c1f-9387-ef52c696ea13</requestId>
    <ResponseMetadata>
        <RequestId>806cbf6d-ae2e-4c1f-9387-ef52c696ea13</RequestId>
    </ResponseMetadata>
</CreatePolicyResponse>
c2-iam CreatePolicy PolicyName policy-2 Type project Document '{"Statement": [{"Action": ["ec2:DescribeInstances"]}]}'