AttachPrincipalPolicyCommand

Attaches the specified policy to the specified principal (certificate or other credential).

Note: This action is deprecated and works as expected for backward compatibility, but we won't add enhancements. Use AttachPolicy instead.

Requires permission to access the AttachPrincipalPolicy  action.

Example Syntax

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

import { IoTClient, AttachPrincipalPolicyCommand } from "@aws-sdk/client-iot"; // ES Modules import
// const { IoTClient, AttachPrincipalPolicyCommand } = require("@aws-sdk/client-iot"); // CommonJS import
const client = new IoTClient(config);
const input = { // AttachPrincipalPolicyRequest
  policyName: "STRING_VALUE", // required
  principal: "STRING_VALUE", // required
};
const command = new AttachPrincipalPolicyCommand(input);
const response = await client.send(command);
// {};

AttachPrincipalPolicyCommand Input

Parameter
Type
Description
policyName
Required
string | undefined

The policy name.

principal
Required
string | undefined

The principal, which can be a certificate ARN (as returned from the CreateCertificate operation) or an Amazon Cognito ID.

AttachPrincipalPolicyCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
InternalFailureException
server

An unexpected error has occurred.

InvalidRequestException
client

The request is not valid.

LimitExceededException
client

A limit has been exceeded.

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.