The Terraform's example is Resource: aws_dms_replication_task I created a test resource as
resource "aws_dms_replication_task" "test" {
migration_type = "full-load"
replication_instance_arn = aws_dms_replication_instance.test-dms-replication-instance-tf.replication_instance_arn
replication_task_id = "test-dms-replication-task-tf"
source_endpoint_arn = aws_dms_endpoint.test-dms-source-endpoint-tf.endpoint_arn
table_mappings = jsonencode(file("${path.module}/test.json"))
tags = {
Name = "test"
}
target_endpoint_arn = aws_dms_endpoint.test-dms-target-endpoint-tf.endpoint_arn
}
The test.json file is
{
"rules": [
{
"rule-type": "transformation",
"rule-id": "1",
"rule-name": "Rule name 1",
"rule-action": "rename",
"rule-target": "schema",
"object-locator": {
"schema-name": "SCHEMA_1",
"table-name": "TABLE_1"
},
"value": "main"
}
]
}
When run the terraform apply, got this error
Error: InvalidParameterValueException: Invalid Table Mappings document. Invalid json Invalid json object
If use the format as example maybe ok
table_mappings = "{\"rules\":[{\"rule-type\":\"selection\",\"rule-id\":\"1\",\"rule-name\":\"1\",\"object-locator\":{\"schema-name\":\"%\",\"table-name\":\"%\"},\"rule-action\":\"include\"}]}"
How to realize the same result if use Terraform's function?