Jump to Content

Class CreatePolicyCommandProtected

Creates a new managed policy for your Amazon Web Services account.

This operation creates a policy version with a version identifier of v1 and sets v1 as the policy's default version. For more information about policy versions, see Versioning for managed policies in the IAM User Guide.

As a best practice, you can validate your IAM policies. To learn more, see Validating IAM policies in the IAM User Guide.

For more information about managed policies in general, see Managed policies and inline policies in the IAM User Guide.

Example

Use a bare-bones client and the command you need to make an API call.

import { IAMClient, CreatePolicyCommand } from "@aws-sdk/client-iam"; // ES Modules import
// const { IAMClient, CreatePolicyCommand } = require("@aws-sdk/client-iam"); // CommonJS import
const client = new IAMClient(config);
const input = {
PolicyName: "STRING_VALUE", // required
Path: "STRING_VALUE",
PolicyDocument: "STRING_VALUE", // required
Description: "STRING_VALUE",
Tags: [
{
Key: "STRING_VALUE", // required
Value: "STRING_VALUE", // required
},
],
};
const command = new CreatePolicyCommand(input);
const response = await client.send(command);

Param

CreatePolicyCommandInput

Returns

CreatePolicyCommandOutput

See

Throws

ConcurrentModificationException (client fault)

The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again.

Throws

EntityAlreadyExistsException (client fault)

The request was rejected because it attempted to create a resource that already exists.

Throws

InvalidInputException (client fault)

The request was rejected because an invalid or out-of-range value was supplied for an input parameter.

Throws

LimitExceededException (client fault)

The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.

Throws

MalformedPolicyDocumentException (client fault)

The request was rejected because the policy document was malformed. The error message describes the specific error.

Throws

ServiceFailureException (server fault)

The request processing has failed because of an unknown error, exception or failure.

Hierarchy

Constructors

Properties

middlewareStack: MiddlewareStack<CreatePolicyCommandInput, CreatePolicyCommandOutput>

Methods