Skip to content

create_event_subscription async

create_event_subscription(
    *,
    config_overrides: Optional[AsyncRedshiftClientConfig] = None,
    subscription_name: Optional[String] = None,
    sns_topic_arn: Optional[String] = None,
    source_type: Optional[String] = None,
    source_ids: Optional[SourceIdsList] = None,
    event_categories: Optional[EventCategoriesList] = None,
    severity: Optional[String] = None,
    enabled: Optional[BooleanOptional] = None,
    tags: Optional[TagList] = None,
) -> CreateEventSubscriptionResult

Creates an Amazon Redshift event notification subscription. This action requires an ARN (Amazon Resource Name) of an Amazon SNS topic created by either the Amazon Redshift console, the Amazon SNS console, or the Amazon SNS API. To obtain an ARN with Amazon SNS, you must create a topic in Amazon SNS and subscribe to the topic. The ARN is displayed in the SNS console.

You can specify the source type, and lists of Amazon Redshift source IDs, event categories, and event severities. Notifications will be sent for all events you want that match those criteria. For example, you can specify source type = cluster, source ID = my-cluster-1 and mycluster2, event categories = Availability, Backup, and severity = ERROR. The subscription will only send notifications for those ERROR events in the Availability and Backup categories for the specified clusters.

If you specify both the source type and source IDs, such as source type = cluster and source identifier = my-cluster-1, notifications will be sent for all the cluster events for my-cluster-1. If you specify a source type but do not specify a source identifier, you will receive notice of the events for the objects of that type in your Amazon Web Services account. If you do not specify either the SourceType nor the SourceIdentifier, you will be notified of events generated from all Amazon Redshift sources belonging to your Amazon Web Services account. You must specify a source type if you specify a source ID.

Parameters:

  • subscription_name (Optional[String], default: None ) –

    The name of the event subscription to be created.

    Constraints:

    • Cannot be null, empty, or blank.

    • Must contain from 1 to 255 alphanumeric characters or hyphens.

    • First character must be a letter.

    • Cannot end with a hyphen or contain two consecutive hyphens.

  • sns_topic_arn (Optional[String], default: None ) –

    The Amazon Resource Name (ARN) of the Amazon SNS topic used to transmit the event notifications. The ARN is created by Amazon SNS when you create a topic and subscribe to it.

  • source_type (Optional[String], default: None ) –

    The type of source that will be generating the events. For example, if you want to be notified of events generated by a cluster, you would set this parameter to cluster. If this value is not specified, events are returned for all Amazon Redshift objects in your Amazon Web Services account. You must specify a source type in order to specify source IDs.

    Valid values: cluster, cluster-parameter-group, cluster-security-group, cluster-snapshot, and scheduled-action.

  • source_ids (Optional[SourceIdsList], default: None ) –

    A list of one or more identifiers of Amazon Redshift source objects. All of the objects must be of the same type as was specified in the source type parameter. The event subscription will return only events generated by the specified objects. If not specified, then events are returned for all objects within the source type specified.

    Example: my-cluster-1, my-cluster-2

    Example: my-snapshot-20131010

  • event_categories (Optional[EventCategoriesList], default: None ) –

    Specifies the Amazon Redshift event categories to be published by the event notification subscription.

    Values: configuration, management, monitoring, security, pending

  • severity (Optional[String], default: None ) –

    Specifies the Amazon Redshift event severity to be published by the event notification subscription.

    Values: ERROR, INFO

  • enabled (Optional[BooleanOptional], default: None ) –

    A boolean value; set to true to activate the subscription, and set to false to create the subscription but not activate it.

  • tags (Optional[TagList], default: None ) –

    A list of tag instances.

Raises:

Source code in docs_src/capo_redshift/_services/async_redshift.py
async def create_event_subscription(
    self,
    *,
    config_overrides: Optional[AsyncRedshiftClientConfig] = None,
    subscription_name: Optional["capo_redshift.types.string.String"] = None,
    sns_topic_arn: Optional["capo_redshift.types.string.String"] = None,
    source_type: Optional["capo_redshift.types.string.String"] = None,
    source_ids: Optional[
        "capo_redshift.types.source_ids_list.SourceIdsList"
    ] = None,
    event_categories: Optional[
        "capo_redshift.types.event_categories_list.EventCategoriesList"
    ] = None,
    severity: Optional["capo_redshift.types.string.String"] = None,
    enabled: Optional[
        "capo_redshift.types.boolean_optional.BooleanOptional"
    ] = None,
    tags: Optional["capo_redshift.types.tag_list.TagList"] = None,
) -> "capo_redshift.types.create_event_subscription_result.CreateEventSubscriptionResult":
    """<p>Creates an Amazon Redshift event notification subscription. This action requires an ARN (Amazon Resource Name) of an Amazon SNS topic created by either the Amazon Redshift console, the Amazon SNS console, or the Amazon SNS API. To obtain an ARN with Amazon SNS, you must create a topic in Amazon SNS and subscribe to the topic. The ARN is displayed in the SNS console.</p> <p>You can specify the source type, and lists of Amazon Redshift source IDs, event categories, and event severities. Notifications will be sent for all events you want that match those criteria. For example, you can specify source type = cluster, source ID = my-cluster-1 and mycluster2, event categories = Availability, Backup, and severity = ERROR. The subscription will only send notifications for those ERROR events in the Availability and Backup categories for the specified clusters.</p> <p>If you specify both the source type and source IDs, such as source type = cluster and source identifier = my-cluster-1, notifications will be sent for all the cluster events for my-cluster-1. If you specify a source type but do not specify a source identifier, you will receive notice of the events for the objects of that type in your Amazon Web Services account. If you do not specify either the SourceType nor the SourceIdentifier, you will be notified of events generated from all Amazon Redshift sources belonging to your Amazon Web Services account. You must specify a source type if you specify a source ID.</p>

    Args:
        subscription_name: <p>The name of the event subscription to be created.</p> <p>Constraints:</p> <ul> <li> <p>Cannot be null, empty, or blank.</p> </li> <li> <p>Must contain from 1 to 255 alphanumeric characters or hyphens.</p> </li> <li> <p>First character must be a letter.</p> </li> <li> <p>Cannot end with a hyphen or contain two consecutive hyphens.</p> </li> </ul>
        sns_topic_arn: <p>The Amazon Resource Name (ARN) of the Amazon SNS topic used to transmit the event notifications. The ARN is created by Amazon SNS when you create a topic and subscribe to it.</p>
        source_type: <p>The type of source that will be generating the events. For example, if you want to be notified of events generated by a cluster, you would set this parameter to cluster. If this value is not specified, events are returned for all Amazon Redshift objects in your Amazon Web Services account. You must specify a source type in order to specify source IDs.</p> <p>Valid values: cluster, cluster-parameter-group, cluster-security-group, cluster-snapshot, and scheduled-action.</p>
        source_ids: <p>A list of one or more identifiers of Amazon Redshift source objects. All of the objects must be of the same type as was specified in the source type parameter. The event subscription will return only events generated by the specified objects. If not specified, then events are returned for all objects within the source type specified.</p> <p>Example: my-cluster-1, my-cluster-2</p> <p>Example: my-snapshot-20131010</p>
        event_categories: <p>Specifies the Amazon Redshift event categories to be published by the event notification subscription.</p> <p>Values: configuration, management, monitoring, security, pending</p>
        severity: <p>Specifies the Amazon Redshift event severity to be published by the event notification subscription.</p> <p>Values: ERROR, INFO</p>
        enabled: <p>A boolean value; set to <code>true</code> to activate the subscription, and set to <code>false</code> to create the subscription but not activate it. </p>
        tags: <p>A list of tag instances.</p>

    Raises:
        capo_redshift.errors.event_subscription_quota_exceeded_fault.EventSubscriptionQuotaExceededFault: <p>The request would exceed the allowed number of event subscriptions for this account. For information about increasing your quota, go to <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/amazon-redshift-limits.html">Limits in Amazon Redshift</a> in the <i>Amazon Redshift Cluster Management Guide</i>. </p>
        capo_redshift.errors.invalid_tag_fault.InvalidTagFault: <p>The tag is invalid.</p>
        capo_redshift.errors.sns_invalid_topic_fault.SNSInvalidTopicFault: <p>Amazon SNS has responded that there is a problem with the specified Amazon SNS topic.</p>
        capo_redshift.errors.sns_no_authorization_fault.SNSNoAuthorizationFault: <p>You do not have permission to publish to the specified Amazon SNS topic.</p>
        capo_redshift.errors.sns_topic_arn_not_found_fault.SNSTopicArnNotFoundFault: <p>An Amazon SNS topic with the specified Amazon Resource Name (ARN) does not exist.</p>
        capo_redshift.errors.source_not_found_fault.SourceNotFoundFault: <p>The specified Amazon Redshift event source could not be found.</p>
        capo_redshift.errors.subscription_already_exist_fault.SubscriptionAlreadyExistFault: <p>There is already an existing event notification subscription with the specified name.</p>
        capo_redshift.errors.subscription_category_not_found_fault.SubscriptionCategoryNotFoundFault: <p>The value specified for the event category was not one of the allowed values, or it specified a category that does not apply to the specified source type. The allowed values are Configuration, Management, Monitoring, and Security.</p>
        capo_redshift.errors.subscription_event_id_not_found_fault.SubscriptionEventIdNotFoundFault: <p>An Amazon Redshift event with the specified event ID does not exist.</p>
        capo_redshift.errors.subscription_severity_not_found_fault.SubscriptionSeverityNotFoundFault: <p>The value specified for the event severity was not one of the allowed values, or it specified a severity that does not apply to the specified source type. The allowed values are ERROR and INFO.</p>
        capo_redshift.errors.tag_limit_exceeded_fault.TagLimitExceededFault: <p>You have exceeded the number of tags allowed.</p>
        capo_redshift.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_redshift.types.create_event_subscription_message.CreateEventSubscriptionMessage]",
    ) -> AsyncOperationResponse[
        "capo_redshift.types.create_event_subscription_result.CreateEventSubscriptionResult"
    ]:
        import capo_redshift._operations.redshift_service_version20121201.create_event_subscription

        (
            output,
            http_response,
        ) = await capo_redshift._operations.redshift_service_version20121201.create_event_subscription.async_create_event_subscription(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEventSubscription")
    )
    input_: capo_redshift.types.create_event_subscription_message.CreateEventSubscriptionMessage = {}
    if subscription_name is not None:
        input_["subscription_name"] = subscription_name
    if sns_topic_arn is not None:
        input_["sns_topic_arn"] = sns_topic_arn
    if source_type is not None:
        input_["source_type"] = source_type
    if source_ids is not None:
        input_["source_ids"] = source_ids
    if event_categories is not None:
        input_["event_categories"] = event_categories
    if severity is not None:
        input_["severity"] = severity
    if enabled is not None:
        input_["enabled"] = enabled
    if tags is not None:
        input_["tags"] = tags

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