微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从 boto3 脚本创建 AWS DMS 任务的问题

如何解决从 boto3 脚本创建 AWS DMS 任务的问题

使用以下 python boto3 脚本创建 AWS DMS 任务并启动复制任务,但出现以下错误

错误

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

Python 脚本:

#!/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'
)

解决方法

可能必须使用 waiter 才能完成任务:

在您可以对其执行其他操作之前。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。