1
votes

Using the below python boto3 script to create the AWS DMS task and start the replication task, but getting the below error:

Error:

botocore.errorfactory.InvalidResourceStateFault: An error occurred (InvalidResourceStateFault) when calling the StartReplicationTask operation: Replication Task cannot be started, invalid state

Python script:

#!/usr/bin/python
import boto3
client_dms = boto3.client('dms')

#Create a replication DMS task
response = client_dms.create_replication_task(
    ReplicationTaskIdentifier='test-new1',
    ResourceIdentifier='test-new',
    ReplicationInstanceArn='arn:aws:dms:us-east-1:xxxxxxxxxx:rep:test1',
    SourceEndpointArn='arn:aws:dms:us-east-1:xxxxxxxxxx:endpoint:source',
    TargetEndpointArn='arn:aws:dms:us-east-1:xxxxxxxxxx:endpoint:target',
    MigrationType='full-load',
    TableMappings='{\n \"TableMappings\": [\n {\n \"Type\": \"Include\",\n \"SourceSchema\": \"test\",\n \"SourceTable\": \"table_name\"\n}\n ]\n}\n\n'
)

#Start the task from DMS
response = client_dms.start_replication_task(
    ReplicationTaskArn='arn:aws:dms:us-east-1:xxxxxxxxxx:task:test-new',
    StartReplicationTaskType='start-replication'
)
1

1 Answers

0
votes

Probably have to use waiter for the task to be ready:

before you can perform other actions on it.