Skip to content

delete_resource_policy async

delete_resource_policy(
    resource_arn: EventBusArn,
    *,
    config_overrides: Optional[AsyncEventBridgeV2ClientConfig] = None,
    policy_name: Optional[PolicyName] = None,
    expected_revision_id: Optional[PolicyRevisionId] = None,
) -> DeleteResourcePolicyResponse

Deletes the named resource policy attached to an event bus.

Parameters:

  • policy_name (Optional[PolicyName], default: None ) –

    Which named policy to delete. Defaults to "default" when omitted (a delete AWS Resource Access Manager makes on the owner's behalf resolves to "AWS_RAM" instead). The two writers are exclusive in both directions — only Resource Access Manager can delete "AWS_RAM", and only the bus owner can delete "default" — so naming the other party's policy fails with AccessDeniedException. A well-formed name that is neither of the two fails with InvalidInputException.

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

    The delete succeeds only if the named policy's current revision ID matches this value; if it differs or the policy does not exist, the operation fails with ConflictException. The "NO_POLICY" sentinel is not valid here. When omitted, deleting an absent policy is an idempotent success. Supplying this value makes the delete non-idempotent: once it succeeds the expected revision no longer exists, so retrying an unanswered request fails with ConflictException even though the policy was deleted. To establish the outcome, read the policy back: ResourceNotFoundException means the delete took effect.

Raises:

  • AccessDeniedException –

    The caller does not have the permissions required to perform the operation. This error is also returned when the operation cannot use the AWS KMS key for the event bus.

  • InternalException –

    The request failed because of an internal service error. Retry the request.

  • InvalidInputException –

    A request parameter is missing or not valid.

  • ThrottlingException –

    The request was throttled because it exceeds a request rate limit. Retry the request with backoff.

  • ConcurrentModificationException –

    Another change to the resource is already in progress. Retry the request.

  • ConflictException –

    A client-supplied precondition (e.g. ExpectedRevisionId on a resource-policy write) did not match the current state of the resource. Retrying the same request will fail again; re-read the resource and re-evaluate before retrying. A conditional request is not retry-safe on its own. If an earlier attempt committed but its response never reached the caller, retrying fails with this error, which is indistinguishable from another writer having won. Compare the resource's current contents with what the request intended: a successful attempt stores a revision ID the caller never saw, so the revision alone cannot tell the two apart, but matching contents mean the change took effect.

  • ResourceNotFoundException –

    The resource does not exist.

  • UnknownServiceError –

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

Source code in docs_src/capo_eventbridgev2/_services/async_event_bridge_v2.py
async def delete_resource_policy(
    self,
    resource_arn: "capo_eventbridgev2.types.event_bus_arn.EventBusArn",
    *,
    config_overrides: Optional[AsyncEventBridgeV2ClientConfig] = None,
    policy_name: Optional["capo_eventbridgev2.types.policy_name.PolicyName"] = None,
    expected_revision_id: Optional[
        "capo_eventbridgev2.types.policy_revision_id.PolicyRevisionId"
    ] = None,
) -> "capo_eventbridgev2.types.delete_resource_policy_response.DeleteResourcePolicyResponse":
    """Deletes the named resource policy attached to an event bus.

    Args:
        policy_name: Which named policy to delete. Defaults to "default" when omitted (a delete AWS Resource Access Manager makes on the owner's behalf resolves to "AWS_RAM" instead). The two writers are exclusive in both directions — only Resource Access Manager can delete "AWS_RAM", and only the bus owner can delete "default" — so naming the other party's policy fails with AccessDeniedException. A well-formed name that is neither of the two fails with InvalidInputException.
        expected_revision_id: The delete succeeds only if the named policy's current revision ID matches this value; if it differs or the policy does not exist, the operation fails with ConflictException. The "NO_POLICY" sentinel is not valid here. When omitted, deleting an absent policy is an idempotent success. Supplying this value makes the delete non-idempotent: once it succeeds the expected revision no longer exists, so retrying an unanswered request fails with ConflictException even though the policy was deleted. To establish the outcome, read the policy back: ResourceNotFoundException means the delete took effect.

    Raises:
        capo_eventbridgev2.errors.access_denied_exception.AccessDeniedException: The caller does not have the permissions required to perform the operation. This error is also returned when the operation cannot use the AWS KMS key for the event bus.
        capo_eventbridgev2.errors.internal_exception.InternalException: The request failed because of an internal service error. Retry the request.
        capo_eventbridgev2.errors.invalid_input_exception.InvalidInputException: A request parameter is missing or not valid.
        capo_eventbridgev2.errors.throttling_exception.ThrottlingException: The request was throttled because it exceeds a request rate limit. Retry the request with backoff.
        capo_eventbridgev2.errors.concurrent_modification_exception.ConcurrentModificationException: Another change to the resource is already in progress. Retry the request.
        capo_eventbridgev2.errors.conflict_exception.ConflictException: A client-supplied precondition (e.g. ExpectedRevisionId on a resource-policy write) did not match the current state of the resource. Retrying the same request will fail again; re-read the resource and re-evaluate before retrying. A conditional request is not retry-safe on its own. If an earlier attempt committed but its response never reached the caller, retrying fails with this error, which is indistinguishable from another writer having won. Compare the resource's current contents with what the request intended: a successful attempt stores a revision ID the caller never saw, so the revision alone cannot tell the two apart, but matching contents mean the change took effect.
        capo_eventbridgev2.errors.resource_not_found_exception.ResourceNotFoundException: The resource does not exist.
        capo_eventbridgev2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_eventbridgev2.types.delete_resource_policy_request.DeleteResourcePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_eventbridgev2.types.delete_resource_policy_response.DeleteResourcePolicyResponse"
    ]:
        import capo_eventbridgev2._operations.aws_events_v2.delete_resource_policy

        (
            output,
            http_response,
        ) = await capo_eventbridgev2._operations.aws_events_v2.delete_resource_policy.async_delete_resource_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteResourcePolicy")
    )
    input_: capo_eventbridgev2.types.delete_resource_policy_request.DeleteResourcePolicyRequest = {
        "resource_arn": resource_arn
    }
    if policy_name is not None:
        input_["policy_name"] = policy_name
    if expected_revision_id is not None:
        input_["expected_revision_id"] = expected_revision_id

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