Skip to content

create_event_subscription

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

Creates an DMS event notification subscription.

You can specify the type of source (SourceType) you want to be notified of, provide a list of DMS source IDs (SourceIds) that triggers the events, and provide a list of event categories (EventCategories) for events you want to be notified of. If you specify both the SourceType and SourceIds, such as SourceType = replication-instance and SourceIdentifier = my-replinstance, you will be notified of all the replication instance events for the specified source. If you specify a SourceType but don't specify a SourceIdentifier, you receive notice of the events for that source type for all your DMS sources. If you don't specify either SourceType nor SourceIdentifier, you will be notified of events generated from all DMS sources belonging to your customer account.

For more information about DMS events, see Working with Events and Notifications in the Database Migration Service User Guide.

Parameters:

  • subscription_name (String) –

    The name of the DMS event notification subscription. This name must be less than 255 characters.

  • sns_topic_arn (String) –

    The Amazon Resource Name (ARN) of the Amazon SNS topic created for event notification. 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 DMS resource that generates the events. For example, if you want to be notified of events generated by a replication instance, you set this parameter to replication-instance. If this value isn't specified, all events are returned.

    Valid values: replication-instance | replication-task

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

    A list of event categories for a source type that you want to subscribe to. For more information, see Working with Events and Notifications in the Database Migration Service User Guide.

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

    A list of identifiers for which DMS provides notification events.

    If you don't specify a value, notifications are provided for all sources.

    If you specify multiple values, they must be of the same type. For example, if you specify a database instance ID, then all of the other values must be database instance IDs.

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

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

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

    One or more tags to be assigned to the event subscription.

Raises:

Source code in docs_src/capo_database_migration_service/_services/database_migration_service.py
def create_event_subscription(
    self,
    subscription_name: "capo_database_migration_service.types.string.String",
    sns_topic_arn: "capo_database_migration_service.types.string.String",
    *,
    config_overrides: Optional[DatabaseMigrationServiceClientConfig] = None,
    source_type: Optional[
        "capo_database_migration_service.types.string.String"
    ] = None,
    event_categories: Optional[
        "capo_database_migration_service.types.event_categories_list.EventCategoriesList"
    ] = None,
    source_ids: Optional[
        "capo_database_migration_service.types.source_ids_list.SourceIdsList"
    ] = None,
    enabled: Optional[
        "capo_database_migration_service.types.boolean_optional.BooleanOptional"
    ] = None,
    tags: Optional["capo_database_migration_service.types.tag_list.TagList"] = None,
) -> "capo_database_migration_service.types.create_event_subscription_response.CreateEventSubscriptionResponse":
    """<p> Creates an DMS event notification subscription. </p> <p>You can specify the type of source (<code>SourceType</code>) you want to be notified of, provide a list of DMS source IDs (<code>SourceIds</code>) that triggers the events, and provide a list of event categories (<code>EventCategories</code>) for events you want to be notified of. If you specify both the <code>SourceType</code> and <code>SourceIds</code>, such as <code>SourceType = replication-instance</code> and <code>SourceIdentifier = my-replinstance</code>, you will be notified of all the replication instance events for the specified source. If you specify a <code>SourceType</code> but don't specify a <code>SourceIdentifier</code>, you receive notice of the events for that source type for all your DMS sources. If you don't specify either <code>SourceType</code> nor <code>SourceIdentifier</code>, you will be notified of events generated from all DMS sources belonging to your customer account.</p> <p>For more information about DMS events, see <a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Events.html">Working with Events and Notifications</a> in the <i>Database Migration Service User Guide.</i> </p>

    Args:
        subscription_name: <p>The name of the DMS event notification subscription. This name must be less than 255 characters.</p>
        sns_topic_arn: <p> The Amazon Resource Name (ARN) of the Amazon SNS topic created for event notification. The ARN is created by Amazon SNS when you create a topic and subscribe to it. </p>
        source_type: <p> The type of DMS resource that generates the events. For example, if you want to be notified of events generated by a replication instance, you set this parameter to <code>replication-instance</code>. If this value isn't specified, all events are returned. </p> <p>Valid values: <code>replication-instance</code> | <code>replication-task</code> </p>
        event_categories: <p>A list of event categories for a source type that you want to subscribe to. For more information, see <a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Events.html">Working with Events and Notifications</a> in the <i>Database Migration Service User Guide.</i> </p>
        source_ids: <p>A list of identifiers for which DMS provides notification events.</p> <p>If you don't specify a value, notifications are provided for all sources.</p> <p>If you specify multiple values, they must be of the same type. For example, if you specify a database instance ID, then all of the other values must be database instance IDs.</p>
        enabled: <p> A Boolean value; set to <code>true</code> to activate the subscription, or set to <code>false</code> to create the subscription but not activate it. </p>
        tags: <p>One or more tags to be assigned to the event subscription.</p>

    Raises:
        capo_database_migration_service.errors.kms_access_denied_fault.KMSAccessDeniedFault: <p>The ciphertext references a key that doesn't exist or that the DMS account doesn't have access to.</p>
        capo_database_migration_service.errors.kms_disabled_fault.KMSDisabledFault: <p>The specified KMS key isn't enabled.</p>
        capo_database_migration_service.errors.kms_invalid_state_fault.KMSInvalidStateFault: <p>The state of the specified KMS resource isn't valid for this request.</p>
        capo_database_migration_service.errors.kms_not_found_fault.KMSNotFoundFault: <p>The specified KMS entity or resource can't be found.</p>
        capo_database_migration_service.errors.kms_throttling_fault.KMSThrottlingFault: <p>This request triggered KMS request throttling.</p>
        capo_database_migration_service.errors.resource_already_exists_fault.ResourceAlreadyExistsFault: <p>The resource you are attempting to create already exists.</p>
        capo_database_migration_service.errors.resource_not_found_fault.ResourceNotFoundFault: <p>The resource could not be found.</p>
        capo_database_migration_service.errors.resource_quota_exceeded_fault.ResourceQuotaExceededFault: <p>The quota for this resource quota has been exceeded.</p>
        capo_database_migration_service.errors.sns_invalid_topic_fault.SNSInvalidTopicFault: <p>The SNS topic is invalid.</p>
        capo_database_migration_service.errors.sns_no_authorization_fault.SNSNoAuthorizationFault: <p>You are not authorized for the SNS subscription.</p>
        capo_database_migration_service.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_database_migration_service.types.create_event_subscription_message.CreateEventSubscriptionMessage]",
    ) -> OperationResponse[
        "capo_database_migration_service.types.create_event_subscription_response.CreateEventSubscriptionResponse"
    ]:
        import capo_database_migration_service._operations.amazon_dm_sv20160101.create_event_subscription

        output, http_response = (
            capo_database_migration_service._operations.amazon_dm_sv20160101.create_event_subscription.create_event_subscription(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

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