Skip to content

put_resource_policy async

put_resource_policy(
    resource_arn: ResourceArn,
    policy: ResourcePolicy,
    *,
    config_overrides: Optional[AsyncLambdaWebClientConfig] = None,
    revision_id: Optional[PolicyRevisionId] = None,
) -> PutResourcePolicyResponse

Adds or updates a resource-based policy on a web function. A resource-based policy grants permissions to other AWS accounts or services to perform actions on the web function.

Parameters:

  • resource_arn (ResourceArn) –

    The Amazon Resource Name (ARN) of the web function.

  • policy (ResourcePolicy) –

    The JSON-formatted resource-based policy to attach to the web function.

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

    The revision ID of the existing policy. Use this to prevent conflicts when updating a policy concurrently. If you don't specify a value, the update proceeds without checking the current revision.

Raises:

  • AccessDeniedException –

    You don't have permission to perform this operation. Check the IAM policies for your identity and any resource-based policy on the web function.

  • ConflictException –

    The request conflicts with the current state of the resource. For example, the resource is being modified by another request, you tried to delete a revision that is serving traffic on an endpoint, or the policy revision ID that you specified doesn't match the current policy. Resolve the conflict and try again.

  • InternalServerException –

    The request failed because of an internal error in the service. Retry the request. If the error persists, open a support case.

  • ResourceNotFoundException –

    The specified web function, revision, endpoint, or resource-based policy doesn't exist. Verify the resource identifier and try again.

  • ServiceQuotaExceededException –

    The request would exceed a service quota, such as the maximum number of web functions in your account or the maximum number of revisions or endpoints per web function. Request a quota increase or reduce usage and try again.

  • ThrottlingException –

    The request was denied because it exceeded the request rate that Lambda allows for your account. Reduce the frequency of requests and retry with exponential backoff.

  • ValidationException –

    The request failed validation because a parameter was missing, malformed, or outside the allowed range. Check the request parameters and try again.

  • UnknownServiceError –

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

Source code in docs_src/capo_lambda_web/_services/async_lambda_web.py
async def put_resource_policy(
    self,
    resource_arn: "capo_lambda_web.types.resource_arn.ResourceArn",
    policy: "capo_lambda_web.types.resource_policy.ResourcePolicy",
    *,
    config_overrides: Optional[AsyncLambdaWebClientConfig] = None,
    revision_id: Optional[
        "capo_lambda_web.types.policy_revision_id.PolicyRevisionId"
    ] = None,
) -> "capo_lambda_web.types.put_resource_policy_response.PutResourcePolicyResponse":
    """<p>Adds or updates a resource-based policy on a web function. A resource-based policy grants permissions to other AWS accounts or services to perform actions on the web function.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the web function.</p>
        policy: <p>The JSON-formatted resource-based policy to attach to the web function.</p>
        revision_id: <p>The revision ID of the existing policy. Use this to prevent conflicts when updating a policy concurrently. If you don't specify a value, the update proceeds without checking the current revision.</p>

    Raises:
        capo_lambda_web.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform this operation. Check the IAM policies for your identity and any resource-based policy on the web function.</p>
        capo_lambda_web.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. For example, the resource is being modified by another request, you tried to delete a revision that is serving traffic on an endpoint, or the policy revision ID that you specified doesn't match the current policy. Resolve the conflict and try again.</p>
        capo_lambda_web.errors.internal_server_exception.InternalServerException: <p>The request failed because of an internal error in the service. Retry the request. If the error persists, open a support case.</p>
        capo_lambda_web.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified web function, revision, endpoint, or resource-based policy doesn't exist. Verify the resource identifier and try again.</p>
        capo_lambda_web.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service quota, such as the maximum number of web functions in your account or the maximum number of revisions or endpoints per web function. Request a quota increase or reduce usage and try again.</p>
        capo_lambda_web.errors.throttling_exception.ThrottlingException: <p>The request was denied because it exceeded the request rate that Lambda allows for your account. Reduce the frequency of requests and retry with exponential backoff.</p>
        capo_lambda_web.errors.validation_exception.ValidationException: <p>The request failed validation because a parameter was missing, malformed, or outside the allowed range. Check the request parameters and try again.</p>
        capo_lambda_web.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lambda_web.types.put_resource_policy_request.PutResourcePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_lambda_web.types.put_resource_policy_response.PutResourcePolicyResponse"
    ]:
        import capo_lambda_web._operations.lambda_web.put_resource_policy

        (
            output,
            http_response,
        ) = await capo_lambda_web._operations.lambda_web.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_lambda_web.types.put_resource_policy_request.PutResourcePolicyRequest = {
        "resource_arn": resource_arn,
        "policy": policy,
    }
    if revision_id is not None:
        input_["revision_id"] = revision_id

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