DisassociateIamInstanceProfileCommand

Disassociates an IAM instance profile from a running or stopped instance.

Use DescribeIamInstanceProfileAssociations to get the association ID.

Example Syntax

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

import { EC2Client, DisassociateIamInstanceProfileCommand } from "@aws-sdk/client-ec2"; // ES Modules import
// const { EC2Client, DisassociateIamInstanceProfileCommand } = require("@aws-sdk/client-ec2"); // CommonJS import
const client = new EC2Client(config);
const input = { // DisassociateIamInstanceProfileRequest
  AssociationId: "STRING_VALUE", // required
};
const command = new DisassociateIamInstanceProfileCommand(input);
const response = await client.send(command);
// { // DisassociateIamInstanceProfileResult
//   IamInstanceProfileAssociation: { // IamInstanceProfileAssociation
//     AssociationId: "STRING_VALUE",
//     InstanceId: "STRING_VALUE",
//     IamInstanceProfile: { // IamInstanceProfile
//       Arn: "STRING_VALUE",
//       Id: "STRING_VALUE",
//     },
//     State: "associating" || "associated" || "disassociating" || "disassociated",
//     Timestamp: new Date("TIMESTAMP"),
//   },
// };

Example Usage

 Loading code editor

DisassociateIamInstanceProfileCommand Input

Parameter
Type
Description
AssociationId
Required
string | undefined

The ID of the IAM instance profile association.

DisassociateIamInstanceProfileCommand Output

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

Information about the IAM instance profile association.

Throws

Name
Fault
Details
EC2ServiceException
Base exception class for all service exceptions from EC2 service.