J Weezy
J Weezy

Reputation: 3957

Question: Does AWS offer an API endpoint to access the DMS mapping-rules for a database migration task?

Question: Does AWS offer an API endpoint to access the DMS mapping rules for a database migration task?

Problem: I need to programmatically retrieve a database migration task's mapping rules to determine whether a replication task has a filter-type rule on a source table. The output is described here and here. Essentially, DMS migration tasks can be problematic when reading from PostgreSQL and a source filter is applied on a column that is not a primary key, as described here.

Work attempted: In AWS DMS -> Database Migration Tasks -> <TaskName> there is a tab for Mapping rules. I have checked DatabaseMigrationServices for Boto3 and ran through the describe_endpoint and describe_replication_tasks endpoints, but I did not find any rules in the result outputs. I think I have exhausted internet search results, and now am asking a question here.

Expected result:

I am looking for a JSON output similar to below. Is it possible to pull this data programmatically? If yes, how?

{
    "rules": [{
        "rule-type": "selection",
        "rule-id": "1",
        "rule-name": "1",
        "object-locator": {
            "schema-name": "test",
            "table-name": "employee"
        },
        "rule-action": "include",
        "filters": [{
            "filter-type": "source",
            "column-name": "empid",
            "filter-conditions": [{
                "filter-operator": "gte",
                "value": "100"
            }]
        }]
    }]
} 

Upvotes: 0

Views: 298

Answers (1)

UAREDDY
UAREDDY

Reputation: 1

Can you try below code in lambda. If you print the response you wont able to see the Table mappings but you can in cloudwatch log

def lambda_handler(event, context):
    dms = boto3.client('dms')
    response = dms.describe_replication_tasks(
        Filters=[
            {
                'Name': 'replication-task-id',
                'Values': [
                    'test'
                ]
            }
        ],
        WithoutSettings=False)
    table_mappings = response['ReplicationTasks'][0]['TableMappings']
    
 
    return table_mappings

Upvotes: 0

Related Questions