GetPolicyCommand

Gets information about the specified policy with the policy document of the default version.

Requires permission to access the GetPolicy  action.

Example Syntax

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

import { IoTClient, GetPolicyCommand } from "@aws-sdk/client-iot"; // ES Modules import
// const { IoTClient, GetPolicyCommand } = require("@aws-sdk/client-iot"); // CommonJS import
const client = new IoTClient(config);
const input = { // GetPolicyRequest
  policyName: "STRING_VALUE", // required
};
const command = new GetPolicyCommand(input);
const response = await client.send(command);
// { // GetPolicyResponse
//   policyName: "STRING_VALUE",
//   policyArn: "STRING_VALUE",
//   policyDocument: "STRING_VALUE",
//   defaultVersionId: "STRING_VALUE",
//   creationDate: new Date("TIMESTAMP"),
//   lastModifiedDate: new Date("TIMESTAMP"),
//   generationId: "STRING_VALUE",
// };

GetPolicyCommand Input

See GetPolicyCommandInput for more details

Parameter
Type
Description
policyName
Required
string | undefined

The name of the policy.

GetPolicyCommand Output

See GetPolicyCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
creationDate
Date | undefined

The date the policy was created.

defaultVersionId
string | undefined

The default policy version ID.

generationId
string | undefined

The generation ID of the policy.

lastModifiedDate
Date | undefined

The date the policy was last modified.

policyArn
string | undefined

The policy ARN.

policyDocument
string | undefined

The JSON document that describes the policy.

policyName
string | undefined

The policy name.

Throws

Name
Fault
Details
InternalFailureException
server

An unexpected error has occurred.

InvalidRequestException
client

The request is not valid.

ResourceNotFoundException
client

The specified resource does not exist.

ServiceUnavailableException
server

The service is temporarily unavailable.

ThrottlingException
client

The rate exceeds the limit.

UnauthorizedException
client

You are not authorized to perform this operation.

IoTServiceException
Base exception class for all service exceptions from IoT service.