Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow movement of DMS tasks to new instances #30721

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/30721.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_dms_replication_task: Allow in-place migration between DMS instances
```
1 change: 1 addition & 0 deletions internal/service/dms/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const (
replicationTaskStatusDeleting = "deleting"
replicationTaskStatusFailed = "failed"
replicationTaskStatusModifying = "modifying"
replicationTaskStatusMoving = "moving"
replicationTaskStatusReady = "ready"
replicationTaskStatusStopped = "stopped"
replicationTaskStatusStopping = "stopping"
Expand Down
33 changes: 31 additions & 2 deletions internal/service/dms/replication_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func ResourceReplicationTask() *schema.Resource {
"replication_instance_arn": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: verify.ValidARN,
},
"replication_task_arn": {
Expand Down Expand Up @@ -212,7 +211,7 @@ func resourceReplicationTaskUpdate(ctx context.Context, d *schema.ResourceData,
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).DMSConn()

if d.HasChangesExcept("tags", "tags_all", "start_replication_task") {
if d.HasChangesExcept("tags", "tags_all", "start_replication_task", "replication_instance_arn") {
input := &dms.ModifyReplicationTaskInput{
ReplicationTaskArn: aws.String(d.Get("replication_task_arn").(string)),
MigrationType: aws.String(d.Get("migration_type").(string)),
Expand Down Expand Up @@ -261,6 +260,36 @@ func resourceReplicationTaskUpdate(ctx context.Context, d *schema.ResourceData,
}
}

if d.HasChange("replication_instance_arn") {
input := &dms.MoveReplicationTaskInput{
ReplicationTaskArn: aws.String(d.Get("replication_task_arn").(string)),
TargetReplicationInstanceArn: aws.String(d.Get("replication_instance_arn").(string)),
}
status := d.Get("status").(string)
if status == replicationTaskStatusRunning {
log.Println("[DEBUG] stopping DMS replication task:", input)
if err := stopReplicationTask(ctx, d.Id(), conn); err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}
log.Println("[DEBUG] moving DMS replication task:", input)
_, err := conn.MoveReplicationTaskWithContext(ctx, input)
if err != nil {
return sdkdiag.AppendErrorf(diags, "moving DMS Replication Task (%s): %s", d.Id(), err)
}

if err := waitReplicationTaskMoved(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for DMS Replication Task (%s) update: %s", d.Id(), err)
}

if d.Get("start_replication_task").(bool) {
err := startReplicationTask(ctx, d.Id(), conn)
if err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}
}

if d.HasChanges("start_replication_task") {
status := d.Get("status").(string)
if d.Get("start_replication_task").(bool) {
Expand Down
Loading