remove_role_from_instance_profile

IAM.Client.remove_role_from_instance_profile(**kwargs)

Removes the specified IAM role from the specified EC2 instance profile.

Warning

Make sure that you do not have any Amazon EC2 instances running with the role you are about to remove from the instance profile. Removing a role from an instance profile that is associated with a running instance might break any applications running on the instance.

For more information about IAM roles, see Working with roles. For more information about instance profiles, see About instance profiles.

See also: AWS API Documentation

Request Syntax

response = client.remove_role_from_instance_profile(
    InstanceProfileName='string',
    RoleName='string'
)
Parameters
  • InstanceProfileName (string) --

    [REQUIRED]

    The name of the instance profile to update.

    This parameter allows (through its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

  • RoleName (string) --

    [REQUIRED]

    The name of the role to remove.

    This parameter allows (through its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Returns

None

Exceptions

  • IAM.Client.exceptions.NoSuchEntityException
  • IAM.Client.exceptions.LimitExceededException
  • IAM.Client.exceptions.UnmodifiableEntityException
  • IAM.Client.exceptions.ServiceFailureException

Examples

The following command removes the role named Test-Role from the instance profile named ExampleInstanceProfile.

response = client.remove_role_from_instance_profile(
    InstanceProfileName='ExampleInstanceProfile',
    RoleName='Test-Role',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}