From 932d654a7ce274c1e8ff71d1004f859ce646f96e Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 13 Apr 2024 20:38:09 +0100 Subject: [PATCH 1/7] f-aws_dms_replication_task support for resource identifier --- internal/service/dms/replication_task.go | 9 ++++ internal/service/dms/replication_task_test.go | 44 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/internal/service/dms/replication_task.go b/internal/service/dms/replication_task.go index fb688f6ff65..f18d2660ea3 100644 --- a/internal/service/dms/replication_task.go +++ b/internal/service/dms/replication_task.go @@ -79,6 +79,11 @@ func ResourceReplicationTask() *schema.Resource { DiffSuppressFunc: suppressEquivalentTaskSettings, DiffSuppressOnRefresh: true, }, + "resource_identifier": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "source_endpoint_arn": { Type: schema.TypeString, Required: true, @@ -146,6 +151,10 @@ func resourceReplicationTaskCreate(ctx context.Context, d *schema.ResourceData, input.ReplicationTaskSettings = aws.String(v.(string)) } + if v, ok := d.GetOk("resource_identifier"); ok { + input.ResourceIdentifier = aws.String(v.(string)) + } + _, err := conn.CreateReplicationTaskWithContext(ctx, input) if err != nil { diff --git a/internal/service/dms/replication_task_test.go b/internal/service/dms/replication_task_test.go index 0f932794f1c..a523fe58160 100644 --- a/internal/service/dms/replication_task_test.go +++ b/internal/service/dms/replication_task_test.go @@ -185,6 +185,34 @@ func TestAccDMSReplicationTask_cdcStartPosition(t *testing.T) { }) } +func TestAccDMSReplicationTask_resourceIdentifier(t *testing.T) { + ctx := acctest.Context(t) + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_dms_replication_task.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.DMSServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckReplicationTaskDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccReplicationTaskConfig_resourceIdentifier(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckReplicationTaskExists(ctx, resourceName), + resource.TestCheckResourceAttr(resourceName, "resource_identifier", "resource_identifier"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"start_replication_task"}, + }, + }, + }) +} + func TestAccDMSReplicationTask_startReplicationTask(t *testing.T) { ctx := acctest.Context(t) if testing.Short() { @@ -490,6 +518,22 @@ resource "aws_dms_replication_task" "test" { `, rName, tags)) } +func testAccReplicationTaskConfig_resourceIdentifier(rName string) string { + return acctest.ConfigCompose(testAccReplicationTaskConfig_base(rName), fmt.Sprintf(` +resource "aws_dms_replication_task" "test" { + migration_type = "full-load" + replication_instance_arn = aws_dms_replication_instance.test.replication_instance_arn + replication_task_id = %[1]q + replication_task_settings = "{\"BeforeImageSettings\":null,\"FailTaskWhenCleanTaskResourceFailed\":false,\"ChangeProcessingDdlHandlingPolicy\":{\"HandleSourceTableAltered\":true,\"HandleSourceTableDropped\":true,\"HandleSourceTableTruncated\":true},\"ChangeProcessingTuning\":{\"BatchApplyMemoryLimit\":500,\"BatchApplyPreserveTransaction\":true,\"BatchApplyTimeoutMax\":30,\"BatchApplyTimeoutMin\":1,\"BatchSplitSize\":0,\"CommitTimeout\":1,\"MemoryKeepTime\":60,\"MemoryLimitTotal\":1024,\"MinTransactionSize\":1000,\"StatementCacheSize\":50},\"CharacterSetSettings\":null,\"ControlTablesSettings\":{\"ControlSchema\":\"\",\"FullLoadExceptionTableEnabled\":false,\"HistoryTableEnabled\":false,\"HistoryTimeslotInMinutes\":5,\"StatusTableEnabled\":false,\"SuspendedTablesTableEnabled\":false},\"ErrorBehavior\":{\"ApplyErrorDeletePolicy\":\"IGNORE_RECORD\",\"ApplyErrorEscalationCount\":0,\"ApplyErrorEscalationPolicy\":\"LOG_ERROR\",\"ApplyErrorFailOnTruncationDdl\":false,\"ApplyErrorInsertPolicy\":\"LOG_ERROR\",\"ApplyErrorUpdatePolicy\":\"LOG_ERROR\",\"DataErrorEscalationCount\":0,\"DataErrorEscalationPolicy\":\"SUSPEND_TABLE\",\"DataErrorPolicy\":\"LOG_ERROR\",\"DataTruncationErrorPolicy\":\"LOG_ERROR\",\"EventErrorPolicy\":\"IGNORE\",\"FailOnNoTablesCaptured\":false,\"FailOnTransactionConsistencyBreached\":false,\"FullLoadIgnoreConflicts\":true,\"RecoverableErrorCount\":-1,\"RecoverableErrorInterval\":5,\"RecoverableErrorStopRetryAfterThrottlingMax\":false,\"RecoverableErrorThrottling\":true,\"RecoverableErrorThrottlingMax\":1800,\"TableErrorEscalationCount\":0,\"TableErrorEscalationPolicy\":\"STOP_TASK\",\"TableErrorPolicy\":\"SUSPEND_TABLE\"},\"FullLoadSettings\":{\"CommitRate\":10000,\"CreatePkAfterFullLoad\":false,\"MaxFullLoadSubTasks\":8,\"StopTaskCachedChangesApplied\":false,\"StopTaskCachedChangesNotApplied\":false,\"TargetTablePrepMode\":\"DROP_AND_CREATE\",\"TransactionConsistencyTimeout\":600},\"Logging\":{\"EnableLogging\":false,\"LogComponents\":[{\"Id\":\"TRANSFORMATION\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SOURCE_UNLOAD\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"IO\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TARGET_LOAD\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"PERFORMANCE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SOURCE_CAPTURE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SORTER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"REST_SERVER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"VALIDATOR_EXT\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TARGET_APPLY\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TASK_MANAGER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TABLES_MANAGER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"METADATA_MANAGER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"FILE_FACTORY\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"COMMON\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"ADDONS\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"DATA_STRUCTURE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"COMMUNICATION\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"FILE_TRANSFER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"}]},\"LoopbackPreventionSettings\":null,\"PostProcessingRules\":null,\"StreamBufferSettings\":{\"CtrlStreamBufferSizeInMB\":5,\"StreamBufferCount\":3,\"StreamBufferSizeInMB\":8},\"TargetMetadata\":{\"BatchApplyEnabled\":false,\"FullLobMode\":false,\"InlineLobMaxSize\":0,\"LimitedSizeLobMode\":true,\"LoadMaxFileSize\":0,\"LobChunkSize\":0,\"LobMaxSize\":32,\"ParallelApplyBufferSize\":0,\"ParallelApplyQueuesPerThread\":0,\"ParallelApplyThreads\":0,\"ParallelLoadBufferSize\":0,\"ParallelLoadQueuesPerThread\":0,\"ParallelLoadThreads\":0,\"SupportLobs\":true,\"TargetSchema\":\"\",\"TaskRecoveryTableEnabled\":false},\"TTSettings\":{\"EnableTT\":false,\"TTRecordSettings\":null,\"TTS3Settings\":null}}" + source_endpoint_arn = aws_dms_endpoint.source.endpoint_arn + resource_identifier = "resource_identifier" + table_mappings = "{\"rules\":[{\"rule-type\":\"selection\",\"rule-id\":\"1\",\"rule-name\":\"1\",\"object-locator\":{\"schema-name\":\"%%\",\"table-name\":\"%%\"},\"rule-action\":\"include\"}]}" + + target_endpoint_arn = aws_dms_endpoint.target.endpoint_arn +} +`, rName)) +} + func testAccReplicationTaskConfig_update(rName, migType string, memLimitTotal int, ruleName string) string { return acctest.ConfigCompose(testAccReplicationTaskConfig_base(rName), fmt.Sprintf(` resource "aws_dms_replication_task" "test" { From 8b157a842a9522f2d2d60eb82c6359ecc9d8ab9c Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 13 Apr 2024 20:40:18 +0100 Subject: [PATCH 2/7] f-support for network_card_index --- .changelog/36901.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/36901.txt diff --git a/.changelog/36901.txt b/.changelog/36901.txt new file mode 100644 index 00000000000..13c89e85709 --- /dev/null +++ b/.changelog/36901.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_dms_replication_task: Add `resource_identifier` argument +``` \ No newline at end of file From 48d39e8a3761c8a05dadb3ee4bbf6001e54a9961 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 13 Apr 2024 20:42:03 +0100 Subject: [PATCH 3/7] f-support for network_card_index --- website/docs/r/dms_replication_task.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/dms_replication_task.html.markdown b/website/docs/r/dms_replication_task.html.markdown index 84ee9d4c752..868f3982370 100644 --- a/website/docs/r/dms_replication_task.html.markdown +++ b/website/docs/r/dms_replication_task.html.markdown @@ -49,6 +49,7 @@ This resource supports the following arguments: - Cannot contain two consecutive hyphens. * `replication_task_settings` - (Optional) An escaped JSON string that contains the task settings. For a complete list of task settings, see [Task Settings for AWS Database Migration Service Tasks](http://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TaskSettings.html). +* `resource_identifier` - (Optional) A friendly name for the resource identifier at the end of the EndpointArn response parameter that is returned in the created Endpoint object. * `source_endpoint_arn` - (Required) The Amazon Resource Name (ARN) string that uniquely identifies the source endpoint. * `start_replication_task` - (Optional) Whether to run or stop the replication task. * `table_mappings` - (Required) An escaped JSON string that contains the table mappings. For information on table mapping see [Using Table Mapping with an AWS Database Migration Service Task to Select and Filter Data](http://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.html) From 82b854fce79d5ffc03f215ab57c1729e89159698 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 13 Apr 2024 20:44:39 +0100 Subject: [PATCH 4/7] f-support for network_card_index --- internal/service/dms/replication_task.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/service/dms/replication_task.go b/internal/service/dms/replication_task.go index f18d2660ea3..4263dc8fa89 100644 --- a/internal/service/dms/replication_task.go +++ b/internal/service/dms/replication_task.go @@ -83,6 +83,12 @@ func ResourceReplicationTask() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 31), + validation.StringMatch(regexache.MustCompile("^[A-Za-z][0-9A-Za-z-]+$"), "must start with a letter, only contain alphanumeric characters and hyphens"), + validation.StringDoesNotMatch(regexache.MustCompile(`--`), "cannot contain two consecutive hyphens"), + validation.StringDoesNotMatch(regexache.MustCompile(`-$`), "cannot end in a hyphen"), + ), }, "source_endpoint_arn": { Type: schema.TypeString, From ce0b59a84e534c10c56c2b0115d1d15fcafd3f18 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 13 Apr 2024 20:57:19 +0100 Subject: [PATCH 5/7] f-support for network_card_index --- internal/service/dms/replication_task.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/service/dms/replication_task.go b/internal/service/dms/replication_task.go index 4263dc8fa89..e7513f12788 100644 --- a/internal/service/dms/replication_task.go +++ b/internal/service/dms/replication_task.go @@ -10,6 +10,7 @@ import ( "log" "time" + "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go/aws" dms "github.com/aws/aws-sdk-go/service/databasemigrationservice" "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" From 070a529fca9d64c50dbd16448bc4f4a492c4feec Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 13 Apr 2024 21:03:24 +0100 Subject: [PATCH 6/7] f-support for network_card_index --- internal/service/dms/replication_task_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/dms/replication_task_test.go b/internal/service/dms/replication_task_test.go index a523fe58160..7ea00c468f4 100644 --- a/internal/service/dms/replication_task_test.go +++ b/internal/service/dms/replication_task_test.go @@ -200,7 +200,7 @@ func TestAccDMSReplicationTask_resourceIdentifier(t *testing.T) { Config: testAccReplicationTaskConfig_resourceIdentifier(rName), Check: resource.ComposeTestCheckFunc( testAccCheckReplicationTaskExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "resource_identifier", "resource_identifier"), + resource.TestCheckResourceAttr(resourceName, "resource_identifier", "identifier"), ), }, { @@ -526,7 +526,7 @@ resource "aws_dms_replication_task" "test" { replication_task_id = %[1]q replication_task_settings = "{\"BeforeImageSettings\":null,\"FailTaskWhenCleanTaskResourceFailed\":false,\"ChangeProcessingDdlHandlingPolicy\":{\"HandleSourceTableAltered\":true,\"HandleSourceTableDropped\":true,\"HandleSourceTableTruncated\":true},\"ChangeProcessingTuning\":{\"BatchApplyMemoryLimit\":500,\"BatchApplyPreserveTransaction\":true,\"BatchApplyTimeoutMax\":30,\"BatchApplyTimeoutMin\":1,\"BatchSplitSize\":0,\"CommitTimeout\":1,\"MemoryKeepTime\":60,\"MemoryLimitTotal\":1024,\"MinTransactionSize\":1000,\"StatementCacheSize\":50},\"CharacterSetSettings\":null,\"ControlTablesSettings\":{\"ControlSchema\":\"\",\"FullLoadExceptionTableEnabled\":false,\"HistoryTableEnabled\":false,\"HistoryTimeslotInMinutes\":5,\"StatusTableEnabled\":false,\"SuspendedTablesTableEnabled\":false},\"ErrorBehavior\":{\"ApplyErrorDeletePolicy\":\"IGNORE_RECORD\",\"ApplyErrorEscalationCount\":0,\"ApplyErrorEscalationPolicy\":\"LOG_ERROR\",\"ApplyErrorFailOnTruncationDdl\":false,\"ApplyErrorInsertPolicy\":\"LOG_ERROR\",\"ApplyErrorUpdatePolicy\":\"LOG_ERROR\",\"DataErrorEscalationCount\":0,\"DataErrorEscalationPolicy\":\"SUSPEND_TABLE\",\"DataErrorPolicy\":\"LOG_ERROR\",\"DataTruncationErrorPolicy\":\"LOG_ERROR\",\"EventErrorPolicy\":\"IGNORE\",\"FailOnNoTablesCaptured\":false,\"FailOnTransactionConsistencyBreached\":false,\"FullLoadIgnoreConflicts\":true,\"RecoverableErrorCount\":-1,\"RecoverableErrorInterval\":5,\"RecoverableErrorStopRetryAfterThrottlingMax\":false,\"RecoverableErrorThrottling\":true,\"RecoverableErrorThrottlingMax\":1800,\"TableErrorEscalationCount\":0,\"TableErrorEscalationPolicy\":\"STOP_TASK\",\"TableErrorPolicy\":\"SUSPEND_TABLE\"},\"FullLoadSettings\":{\"CommitRate\":10000,\"CreatePkAfterFullLoad\":false,\"MaxFullLoadSubTasks\":8,\"StopTaskCachedChangesApplied\":false,\"StopTaskCachedChangesNotApplied\":false,\"TargetTablePrepMode\":\"DROP_AND_CREATE\",\"TransactionConsistencyTimeout\":600},\"Logging\":{\"EnableLogging\":false,\"LogComponents\":[{\"Id\":\"TRANSFORMATION\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SOURCE_UNLOAD\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"IO\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TARGET_LOAD\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"PERFORMANCE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SOURCE_CAPTURE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SORTER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"REST_SERVER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"VALIDATOR_EXT\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TARGET_APPLY\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TASK_MANAGER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"TABLES_MANAGER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"METADATA_MANAGER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"FILE_FACTORY\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"COMMON\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"ADDONS\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"DATA_STRUCTURE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"COMMUNICATION\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"FILE_TRANSFER\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"}]},\"LoopbackPreventionSettings\":null,\"PostProcessingRules\":null,\"StreamBufferSettings\":{\"CtrlStreamBufferSizeInMB\":5,\"StreamBufferCount\":3,\"StreamBufferSizeInMB\":8},\"TargetMetadata\":{\"BatchApplyEnabled\":false,\"FullLobMode\":false,\"InlineLobMaxSize\":0,\"LimitedSizeLobMode\":true,\"LoadMaxFileSize\":0,\"LobChunkSize\":0,\"LobMaxSize\":32,\"ParallelApplyBufferSize\":0,\"ParallelApplyQueuesPerThread\":0,\"ParallelApplyThreads\":0,\"ParallelLoadBufferSize\":0,\"ParallelLoadQueuesPerThread\":0,\"ParallelLoadThreads\":0,\"SupportLobs\":true,\"TargetSchema\":\"\",\"TaskRecoveryTableEnabled\":false},\"TTSettings\":{\"EnableTT\":false,\"TTRecordSettings\":null,\"TTS3Settings\":null}}" source_endpoint_arn = aws_dms_endpoint.source.endpoint_arn - resource_identifier = "resource_identifier" + resource_identifier = "identifier" table_mappings = "{\"rules\":[{\"rule-type\":\"selection\",\"rule-id\":\"1\",\"rule-name\":\"1\",\"object-locator\":{\"schema-name\":\"%%\",\"table-name\":\"%%\"},\"rule-action\":\"include\"}]}" target_endpoint_arn = aws_dms_endpoint.target.endpoint_arn From 41aff4cae2cbe5ee3560b76f5e9d581642e0a57d Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 15 Apr 2024 10:20:10 -0400 Subject: [PATCH 7/7] Fix 'TestAccDMSReplicationTask_resourceIdentifier'. --- internal/service/dms/replication_task_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/dms/replication_task_test.go b/internal/service/dms/replication_task_test.go index 7ea00c468f4..4ab75048c78 100644 --- a/internal/service/dms/replication_task_test.go +++ b/internal/service/dms/replication_task_test.go @@ -207,7 +207,7 @@ func TestAccDMSReplicationTask_resourceIdentifier(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"start_replication_task"}, + ImportStateVerifyIgnore: []string{"resource_identifier", "start_replication_task"}, }, }, })