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

r/dms_replication_task: set cdc_start_position to computed #23328

Merged
merged 2 commits into from
Feb 23, 2022
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/23328.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_dms_replication_task: Allow `cdc_start_position` to be computed
```
7 changes: 7 additions & 0 deletions internal/service/dms/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package dms

const (
endpointStatusDeleting = "deleting"

replicationTaskStatusCreating = "creating"
replicationTaskStatusDeleting = "deleting"
replicationTaskStatusFailed = "failed"
replicationTaskStatusModifying = "modifying"
replicationTaskStatusReady = "ready"
replicationTaskStatusStopped = "stopped"
)

const (
Expand Down
49 changes: 49 additions & 0 deletions internal/service/dms/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,52 @@ func FindEndpointByID(conn *dms.DatabaseMigrationService, id string) (*dms.Endpo

return output.Endpoints[0], nil
}

func FindReplicationTaskByID(conn *dms.DatabaseMigrationService, id string) (*dms.ReplicationTask, error) {
input := &dms.DescribeReplicationTasksInput{
Filters: []*dms.Filter{
{
Name: aws.String("replication-task-id"),
Values: []*string{aws.String(id)}, // Must use d.Id() to work with import.
},
},
}

var results []*dms.ReplicationTask

err := conn.DescribeReplicationTasksPages(input, func(page *dms.DescribeReplicationTasksOutput, lastPage bool) bool {
if page == nil {
return !lastPage
}

for _, task := range page.ReplicationTasks {
if task == nil {
continue
}
results = append(results, task)
}

return !lastPage
})

if tfawserr.ErrCodeEquals(err, dms.ErrCodeResourceNotFoundFault) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if len(results) == 0 {
return nil, tfresource.NewEmptyResultError(input)
}

if count := len(results); count > 1 {
return nil, tfresource.NewTooManyResultsError(count, input)
}

return results[0], nil
}
Loading