Skip to content

update_managed_instance_role async

update_managed_instance_role(
    instance_id: ManagedInstanceId,
    iam_role: IamRole,
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
) -> UpdateManagedInstanceRoleResult

Changes the Identity and Access Management (IAM) role that is assigned to the on-premises server, edge device, or virtual machines (VM). IAM roles are first assigned to these hybrid nodes during the activation process. For more information, see CreateActivation.

Parameters:

  • instance_id (ManagedInstanceId) –

    The ID of the managed node where you want to update the role.

  • iam_role (IamRole) –

    The name of the Identity and Access Management (IAM) role that you want to assign to the managed node. This IAM role must provide AssumeRole permissions for the Amazon Web Services Systems Manager service principal ssm.amazonaws.com. For more information, see Create the IAM service role required for Systems Manager in hybrid and multicloud environments in the Amazon Web Services Systems Manager User Guide.

    You can't specify an IAM service-linked role for this parameter. You must create a unique role.

Raises:

  • InternalServerError –

    An error occurred on the server side.

  • InvalidInstanceId –

    The following problems can cause this exception:

    • You don't have permission to access the managed node.

    • Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.

    • SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.

    • The managed node isn't in a valid state. Valid states are: Running, Pending, Stopped, and Stopping. Invalid states are: Shutting-down and Terminated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ssm/_services/async_ssm.py
async def update_managed_instance_role(
    self,
    instance_id: "capo_ssm.types.managed_instance_id.ManagedInstanceId",
    iam_role: "capo_ssm.types.iam_role.IamRole",
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
) -> "capo_ssm.types.update_managed_instance_role_result.UpdateManagedInstanceRoleResult":
    """<p>Changes the Identity and Access Management (IAM) role that is assigned to the on-premises server, edge device, or virtual machines (VM). IAM roles are first assigned to these hybrid nodes during the activation process. For more information, see <a>CreateActivation</a>.</p>

    Args:
        instance_id: <p>The ID of the managed node where you want to update the role.</p>
        iam_role: <p>The name of the Identity and Access Management (IAM) role that you want to assign to the managed node. This IAM role must provide AssumeRole permissions for the Amazon Web Services Systems Manager service principal <code>ssm.amazonaws.com</code>. For more information, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/hybrid-multicloud-service-role.html">Create the IAM service role required for Systems Manager in hybrid and multicloud environments</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p> <note> <p>You can't specify an IAM service-linked role for this parameter. You must create a unique role.</p> </note>

    Raises:
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.invalid_instance_id.InvalidInstanceId: <p>The following problems can cause this exception:</p> <ul> <li> <p>You don't have permission to access the managed node.</p> </li> <li> <p>Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.</p> </li> <li> <p>SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.</p> </li> <li> <p>The managed node isn't in a valid state. Valid states are: <code>Running</code>, <code>Pending</code>, <code>Stopped</code>, and <code>Stopping</code>. Invalid states are: <code>Shutting-down</code> and <code>Terminated</code>.</p> </li> </ul>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ssm.types.update_managed_instance_role_request.UpdateManagedInstanceRoleRequest]",
    ) -> AsyncOperationResponse[
        "capo_ssm.types.update_managed_instance_role_result.UpdateManagedInstanceRoleResult"
    ]:
        import capo_ssm._operations.amazon_ssm.update_managed_instance_role

        (
            output,
            http_response,
        ) = await capo_ssm._operations.amazon_ssm.update_managed_instance_role.async_update_managed_instance_role(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateManagedInstanceRole")
    )
    input_: capo_ssm.types.update_managed_instance_role_request.UpdateManagedInstanceRoleRequest = {
        "instance_id": instance_id,
        "iam_role": iam_role,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output