Skip to content

register_cross_account_access_role

register_cross_account_access_role(
    role_arn: Arn, *, config_overrides: Optional[InspectorClientConfig] = None
) -> None

Registers the IAM role that grants Amazon Inspector access to AWS Services needed to perform security assessments.

Parameters:

  • role_arn (Arn) –

    The ARN of the IAM role that grants Amazon Inspector access to AWS Services needed to perform security assessments.

Raises:

Examples:

Register cross account access role Registers the IAM role that Amazon Inspector uses to list your EC2 instances at the start of the assessment run or when you call the PreviewAgents action.

>>> client.register_cross_account_access_role(role_arn='arn:aws:iam::123456789012:role/inspector')
Source code in docs_src/capo_inspector/_services/inspector.py
def register_cross_account_access_role(
    self,
    role_arn: "capo_inspector.types.arn.Arn",
    *,
    config_overrides: Optional[InspectorClientConfig] = None,
) -> None:
    """<p>Registers the IAM role that grants Amazon Inspector access to AWS Services needed to perform security assessments.</p>

    Args:
        role_arn: <p>The ARN of the IAM role that grants Amazon Inspector access to AWS Services needed to perform security assessments. </p>

    Raises:
        capo_inspector.errors.access_denied_exception.AccessDeniedException: <p>You do not have required permissions to access the requested resource.</p>
        capo_inspector.errors.internal_exception.InternalException: <p>Internal server error.</p>
        capo_inspector.errors.invalid_cross_account_role_exception.InvalidCrossAccountRoleException: <p>Amazon Inspector cannot assume the cross-account role that it needs to list your EC2 instances during the assessment run.</p>
        capo_inspector.errors.invalid_input_exception.InvalidInputException: <p>The request was rejected because an invalid or out-of-range value was supplied for an input parameter.</p>
        capo_inspector.errors.service_temporarily_unavailable_exception.ServiceTemporarilyUnavailableException: <p>The serice is temporary unavailable.</p>
        capo_inspector.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Register cross account access role
        Registers the IAM role that Amazon Inspector uses to list your EC2 instances at the start of the assessment run or when you call the PreviewAgents action.

        >>> client.register_cross_account_access_role(role_arn='arn:aws:iam::123456789012:role/inspector')
    """

    def _handler(
        req: "OperationRequest[capo_inspector.types.register_cross_account_access_role_request.RegisterCrossAccountAccessRoleRequest]",
    ) -> OperationResponse[None]:
        import capo_inspector._operations.inspector_service.register_cross_account_access_role

        output, http_response = (
            capo_inspector._operations.inspector_service.register_cross_account_access_role.register_cross_account_access_role(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RegisterCrossAccountAccessRole")
    )
    input_: capo_inspector.types.register_cross_account_access_role_request.RegisterCrossAccountAccessRoleRequest = {
        "role_arn": role_arn
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output