CmdID

CmdID / aws / aws ec2

aws ec2 associate-iam-instance-profile

Associates an IAM instance profile with a running or stopped instance. AWS CLI reference

1 example 2 options Its page in the AWS CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from aws-cli, each command read by CmdID

To associate an IAM instance profile with an instance

The following associate-iam-instance-profile example associates an IAM instance profile named admin-role with instance i-123456789abcde123.

aws ec2 associate-iam-instance-profile --instance-id i-123456789abcde123 --iam-instance-profile Name=admin-roleIdentify
--instance-idThe ID of the instance.
--iam-instance-profileThe IAM instance profile.
Its output
{
    "IamInstanceProfileAssociation": {
        "InstanceId": "i-123456789abcde123",
        "State": "associating",
        "AssociationId": "iip-assoc-0e7736511a163c209",
        "IamInstanceProfile": {
            "Id": "AIPAJBLK7RKJKWDXVHIEC",
            "Arn": "arn:aws:iam::123456789012:instance-profile/admin-role"
        }
    }
}

For more information, see Attach an IAM role to an instance in the Amazon EC2 User Guide.

Options

2 in the AWS CLI reference
--iam-instance-profileThe IAM instance profile.
--instance-idThe ID of the instance.