Skip to content

rotate_webhook_credentials

rotate_webhook_credentials(
    event_source_arn: WebhookEventSourceArn,
    *,
    config_overrides: Optional[EventBridgeV2ClientConfig] = None,
    credential: Optional[WebhookCredential] = None,
    client_token: Optional[ClientToken] = None,
) -> RotateWebhookCredentialsResponse

Sets a new credential on a webhook EventSource. If you supply Credential, EventBridge uses that value. Otherwise, EventBridge generates one. For HTTP Basic authentication, only the password changes. The username does not change. EventBridge never returns the credential. To read a generated value, call secretsmanager:GetSecretValue on the secret that SecretArn identifies.

You can rotate the credential of an EventSource in the ACTIVE, UPDATING, or UPDATE_FAILED state. For a revoked EventSource or an EventSource in any other state, EventBridge returns InvalidStateException. EventBridge also returns InvalidStateException if the secret of the EventSource is scheduled for deletion or has been deleted.

If you rotate the credential of one EventSource too many times in 24 hours, EventBridge returns LimitExceededException. Retry later. The limit becomes available again automatically.

If AWS Secrets Manager throttles the call, EventBridge returns ThrottlingException. Retry later.

To use this operation, you must have the following permissions in your IAM policy:

  • secretsmanager:PutSecretValue on the secret of the EventSource

  • secretsmanager:GetSecretValue on the secret of the EventSource, for HTTP Basic authentication only

  • kms:GenerateDataKey and kms:Decrypt on the AWS KMS key that encrypts the secret

The resource policy of the secret must not deny the secretsmanager actions.

EventBridge accepts the new credential when this call returns. In rare cases, the new credential takes up to 2 minutes to reach every EventBridge endpoint.

EventBridge also accepts the previous credential for 15 minutes after the rotation. The window ends at the CreatedDate of the AWSCURRENT secret version plus 15 minutes. Only the credential that the most recent rotation replaced stays valid. If you rotate again within 15 minutes, the older credential stops working immediately.

A retry with the same ClientToken within 8 hours returns the same result and does not rotate again. A retry of a rotation that supplied a value can arrive after a later rotation completed. In that case, the retried value becomes the current credential, and the credential it replaces does not stay valid.

Parameters:

  • event_source_arn (WebhookEventSourceArn) –

    The ARN of the webhook EventSource.

  • credential (Optional[WebhookCredential], default: None ) –

    The new credential. Set the member that matches the authentication type of the EventSource. If you set a member that does not match the authentication type, EventBridge returns InvalidInputException. If you omit Credential, EventBridge generates a value.

  • client_token (Optional[ClientToken], default: None ) –

    Unique, case-sensitive identifier that ensures the idempotency of the request. The SDK generates one automatically when the field is omitted.

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.

  • IdempotentParameterMismatchException –

    The request reuses the client token of an earlier request with different parameters. Use a new client token, or resend the earlier request unchanged.

  • InvalidStateException –

    The resource is not in a state that allows the operation. For example, an event bus that is still being created cannot accept events.

  • LimitExceededException –

    The request would exceed a service quota for the account.

  • 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/event_bridge_v2.py
def rotate_webhook_credentials(
    self,
    event_source_arn: "capo_eventbridgev2.types.webhook_event_source_arn.WebhookEventSourceArn",
    *,
    config_overrides: Optional[EventBridgeV2ClientConfig] = None,
    credential: Optional[
        "capo_eventbridgev2.types.webhook_credential.WebhookCredential"
    ] = None,
    client_token: Optional[
        "capo_eventbridgev2.types.client_token.ClientToken"
    ] = None,
) -> "capo_eventbridgev2.types.rotate_webhook_credentials_response.RotateWebhookCredentialsResponse":
    """<p>Sets a new credential on a webhook EventSource. If you supply Credential, EventBridge uses that value. Otherwise, EventBridge generates one. For HTTP Basic authentication, only the password changes. The username does not change. EventBridge never returns the credential. To read a generated value, call secretsmanager:GetSecretValue on the secret that SecretArn identifies.</p> <p>You can rotate the credential of an EventSource in the ACTIVE, UPDATING, or UPDATE_FAILED state. For a revoked EventSource or an EventSource in any other state, EventBridge returns InvalidStateException. EventBridge also returns InvalidStateException if the secret of the EventSource is scheduled for deletion or has been deleted.</p> <p>If you rotate the credential of one EventSource too many times in 24 hours, EventBridge returns LimitExceededException. Retry later. The limit becomes available again automatically.</p> <p>If AWS Secrets Manager throttles the call, EventBridge returns ThrottlingException. Retry later.</p> <p>To use this operation, you must have the following permissions in your IAM policy:</p> <ul> <li> <p>secretsmanager:PutSecretValue on the secret of the EventSource</p> </li> <li> <p>secretsmanager:GetSecretValue on the secret of the EventSource, for HTTP Basic authentication only</p> </li> <li> <p>kms:GenerateDataKey and kms:Decrypt on the AWS KMS key that encrypts the secret</p> </li> </ul> <p>The resource policy of the secret must not deny the secretsmanager actions.</p> <p>EventBridge accepts the new credential when this call returns. In rare cases, the new credential takes up to 2 minutes to reach every EventBridge endpoint.</p> <p>EventBridge also accepts the previous credential for 15 minutes after the rotation. The window ends at the CreatedDate of the AWSCURRENT secret version plus 15 minutes. Only the credential that the most recent rotation replaced stays valid. If you rotate again within 15 minutes, the older credential stops working immediately.</p> <p>A retry with the same ClientToken within 8 hours returns the same result and does not rotate again. A retry of a rotation that supplied a value can arrive after a later rotation completed. In that case, the retried value becomes the current credential, and the credential it replaces does not stay valid.</p>

    Args:
        event_source_arn: <p>The ARN of the webhook EventSource.</p>
        credential: <p>The new credential. Set the member that matches the authentication type of the EventSource. If you set a member that does not match the authentication type, EventBridge returns InvalidInputException. If you omit Credential, EventBridge generates a value.</p>
        client_token: <p>Unique, case-sensitive identifier that ensures the idempotency of the request. The SDK generates one automatically when the field is omitted.</p>

    Raises:
        capo_eventbridgev2.errors.access_denied_exception.AccessDeniedException: <p>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.</p>
        capo_eventbridgev2.errors.internal_exception.InternalException: <p>The request failed because of an internal service error. Retry the request.</p>
        capo_eventbridgev2.errors.invalid_input_exception.InvalidInputException: <p>A request parameter is missing or not valid.</p>
        capo_eventbridgev2.errors.throttling_exception.ThrottlingException: <p>The request was throttled because it exceeds a request rate limit. Retry the request with backoff.</p>
        capo_eventbridgev2.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Another change to the resource is already in progress. Retry the request.</p>
        capo_eventbridgev2.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>The request reuses the client token of an earlier request with different parameters. Use a new client token, or resend the earlier request unchanged.</p>
        capo_eventbridgev2.errors.invalid_state_exception.InvalidStateException: <p>The resource is not in a state that allows the operation. For example, an event bus that is still being created cannot accept events.</p>
        capo_eventbridgev2.errors.limit_exceeded_exception.LimitExceededException: <p>The request would exceed a service quota for the account.</p>
        capo_eventbridgev2.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource does not exist.</p>
        capo_eventbridgev2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_eventbridgev2.types.rotate_webhook_credentials_request.RotateWebhookCredentialsRequest]",
    ) -> OperationResponse[
        "capo_eventbridgev2.types.rotate_webhook_credentials_response.RotateWebhookCredentialsResponse"
    ]:
        import capo_eventbridgev2._operations.aws_events_v2.rotate_webhook_credentials

        output, http_response = (
            capo_eventbridgev2._operations.aws_events_v2.rotate_webhook_credentials.rotate_webhook_credentials(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_eventbridgev2.types.rotate_webhook_credentials_request.RotateWebhookCredentialsRequest",
    ) -> dict[str, Any]:
        import capo_eventbridgev2.types.rotate_webhook_credentials_request

        return capo_eventbridgev2.types.rotate_webhook_credentials_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("RotateWebhookCredentials", redact_input=_redact_input),
    )
    input_: capo_eventbridgev2.types.rotate_webhook_credentials_request.RotateWebhookCredentialsRequest = {
        "event_source_arn": event_source_arn
    }
    if credential is not None:
        input_["credential"] = credential
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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