associateIamInstanceProfile

Associates an IAM instance profile with a running or stopped instance. You cannot associate more than one IAM instance profile with an instance.

Samples

import aws.sdk.kotlin.services.ec2.model.IamInstanceProfileSpecification

fun main() { 
   //sampleStart 
   // This example associates an IAM instance profile named admin role with the specified instance.
val resp = ec2Client.associateIamInstanceProfile {
    iamInstanceProfile = IamInstanceProfileSpecification {
        name = "admin-role"
    }
    instanceId = "i-123456789abcde123"
} 
   //sampleEnd
}