Stefan M
Stefan M

Reputation: 424

boto3 DMS enable CloudWatch logs

I am writing scripts in Python that are creating DMS tasks using the boto3 package. I wonder if there is any way of programatically enabling CloudWatch logging for the tasks? I can't find any option to do this with the create_replication_task function.

Upvotes: 1

Views: 518

Answers (1)

Abdullah Khawer
Abdullah Khawer

Reputation: 5708

You can achieve this by defining ReplicationTaskSettings in your create_replication_task call. That is an optional parameter. You define the task settings in a JSON string format. You need to add the following in your task settings:

"Logging": {
    "EnableLogging": true
}

In that way, you can enable CloudWatch logging while creating the task from Python using Boto3.

A sample request would be as follows:

import boto3

client = boto3.client('dms')

response = client.create_replication_task(
    ReplicationTaskIdentifier='string',
    SourceEndpointArn='string',
    TargetEndpointArn='string',
    ReplicationInstanceArn='string',
    MigrationType='full-load'|'cdc'|'full-load-and-cdc',
    TableMappings='string',
    ReplicationTaskSettings="{\"Logging\": {\"EnableLogging\": true}}",
)

Reference to create_replication_task API is here:

AWS SDK for Python - Boto3 - AWS DMS - Create Replication Task API

Reference to ReplicationTaskSettings parameter is here:

AWS SDK for Python - Boto3 - AWS DMS - Create Replication Task API - Replication Task Settings

Upvotes: 1

Related Questions