Skip to content

put_resource_policy async

put_resource_policy(
    policy_name: PolicyName,
    policy_document: PolicyDocument,
    *,
    config_overrides: Optional[AsyncXRayClientConfig] = None,
    policy_revision_id: Optional[PolicyRevisionId] = None,
    bypass_policy_lockout_check: Optional[Boolean] = None,
) -> PutResourcePolicyResult

Sets the resource policy to grant one or more Amazon Web Services services and accounts permissions to access X-Ray. Each resource policy will be associated with a specific Amazon Web Services account. Each Amazon Web Services account can have a maximum of 5 resource policies, and each policy name must be unique within that account. The maximum size of each resource policy is 5KB.

Parameters:

  • policy_name (PolicyName) –

    The name of the resource policy. Must be unique within a specific Amazon Web Services account.

  • policy_document (PolicyDocument) –

    The resource policy document, which can be up to 5kb in size.

  • policy_revision_id (Optional[PolicyRevisionId], default: None ) –

    Specifies a specific policy revision, to ensure an atomic create operation. By default the resource policy is created if it does not exist, or updated with an incremented revision id. The revision id is unique to each policy in the account.

    If the policy revision id does not match the latest revision id, the operation will fail with an InvalidPolicyRevisionIdException exception. You can also provide a PolicyRevisionId of 0. In this case, the operation will fail with an InvalidPolicyRevisionIdException exception if a resource policy with the same name already exists.

  • bypass_policy_lockout_check (Optional[Boolean], default: None ) –

    A flag to indicate whether to bypass the resource policy lockout safety check.

    Setting this value to true increases the risk that the policy becomes unmanageable. Do not set this value to true indiscriminately.

    Use this parameter only when you include a policy in the request and you intend to prevent the principal that is making the request from making a subsequent PutResourcePolicy request.

    The default value is false.

Raises:

Source code in docs_src/capo_xray/_services/async_x_ray.py
async def put_resource_policy(
    self,
    policy_name: "capo_xray.types.policy_name.PolicyName",
    policy_document: "capo_xray.types.policy_document.PolicyDocument",
    *,
    config_overrides: Optional[AsyncXRayClientConfig] = None,
    policy_revision_id: Optional[
        "capo_xray.types.policy_revision_id.PolicyRevisionId"
    ] = None,
    bypass_policy_lockout_check: Optional["capo_xray.types.boolean.Boolean"] = None,
) -> "capo_xray.types.put_resource_policy_result.PutResourcePolicyResult":
    """<p> Sets the resource policy to grant one or more Amazon Web Services services and accounts permissions to access X-Ray. Each resource policy will be associated with a specific Amazon Web Services account. Each Amazon Web Services account can have a maximum of 5 resource policies, and each policy name must be unique within that account. The maximum size of each resource policy is 5KB. </p>

    Args:
        policy_name: <p>The name of the resource policy. Must be unique within a specific Amazon Web Services account.</p>
        policy_document: <p>The resource policy document, which can be up to 5kb in size.</p>
        policy_revision_id: <p>Specifies a specific policy revision, to ensure an atomic create operation. By default the resource policy is created if it does not exist, or updated with an incremented revision id. The revision id is unique to each policy in the account.</p> <p>If the policy revision id does not match the latest revision id, the operation will fail with an <code>InvalidPolicyRevisionIdException</code> exception. You can also provide a <code>PolicyRevisionId</code> of 0. In this case, the operation will fail with an <code>InvalidPolicyRevisionIdException</code> exception if a resource policy with the same name already exists. </p>
        bypass_policy_lockout_check: <p>A flag to indicate whether to bypass the resource policy lockout safety check.</p> <important> <p>Setting this value to true increases the risk that the policy becomes unmanageable. Do not set this value to true indiscriminately.</p> </important> <p>Use this parameter only when you include a policy in the request and you intend to prevent the principal that is making the request from making a subsequent <code>PutResourcePolicy</code> request.</p> <p>The default value is false.</p>

    Raises:
        capo_xray.errors.invalid_policy_revision_id_exception.InvalidPolicyRevisionIdException: <p>A policy revision id was provided which does not match the latest policy revision. This exception is also if a policy revision id of 0 is provided via <code>PutResourcePolicy</code> and a policy with the same name already exists.</p>
        capo_xray.errors.lockout_prevention_exception.LockoutPreventionException: <p>The provided resource policy would prevent the caller of this request from calling PutResourcePolicy in the future.</p>
        capo_xray.errors.malformed_policy_document_exception.MalformedPolicyDocumentException: <p>Invalid policy document provided in request.</p>
        capo_xray.errors.policy_count_limit_exceeded_exception.PolicyCountLimitExceededException: <p>Exceeded the maximum number of resource policies for a target Amazon Web Services account.</p>
        capo_xray.errors.policy_size_limit_exceeded_exception.PolicySizeLimitExceededException: <p>Exceeded the maximum size for a resource policy.</p>
        capo_xray.errors.throttled_exception.ThrottledException: <p>The request exceeds the maximum number of requests per second.</p>
        capo_xray.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_xray.types.put_resource_policy_request.PutResourcePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_xray.types.put_resource_policy_result.PutResourcePolicyResult"
    ]:
        import capo_xray._operations.awsx_ray.put_resource_policy

        (
            output,
            http_response,
        ) = await capo_xray._operations.awsx_ray.put_resource_policy.async_put_resource_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutResourcePolicy")
    )
    input_: capo_xray.types.put_resource_policy_request.PutResourcePolicyRequest = {
        "policy_name": policy_name,
        "policy_document": policy_document,
    }
    if policy_revision_id is not None:
        input_["policy_revision_id"] = policy_revision_id
    if bypass_policy_lockout_check is not None:
        input_["bypass_policy_lockout_check"] = bypass_policy_lockout_check

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