Cloudformation - DMS Replication task

0

Cloudformation DMS replication task, TableMappings: , doesn't take json. Error Invalid JSON but I have checked in JSON checker, JSON is valid. Please let me know if there is any way to provided JSON file has input. sample JSON File.

{
    "rules": [
        {
            "rule-type": "selection",
            "rule-id": "528656830",
            "rule-name": "528624433",
            "object-locator": {
                "schema-name": "APPLSYS",
                "table-name": "FND_CURRENCIES"
            },
            "rule-action": "include",
            "filters": []
        }
    ]
}
asked 2 years ago749 views
1 Answer
1

Hi,

The property TableMappings of the resource AWS::DMS::ReplicationTask accepts a single String:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dms-replicationtask.html#aws-resource-dms-replicationtask-properties

As the double quote (") is a String delimiter in the CloudFormation YAML Syntax you need to escape the double quotes of your JSON string, as shown in the example:

AWSTemplateFormatVersion: 2010-09-09
Resources: 
  myReplicationTask: 
    Properties: 
      MigrationType: full-load
      ReplicationInstanceArn: ReplicationInstance
      SourceEndpointArn: SourceEndpoint
      TableMappings: "{ \"rules\": [ { \"rule-type\": \"selection\", \"rule-id\": \"1\", \"rule-name\": \"1\", \"object-locator\": { \"schema-name\": \"%\", \"table-name\": \"%\" }, \"rule-action\": \"include\" } ] }"
      TargetEndpointArn: TargetEndpoint
    Type: "AWS::DMS::ReplicationTask"

source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dms-replicationtask.html#aws-resource-dms-replicationtask--examples

EXPERT
answered 2 years ago
  • Thanks, actually I got the solution before your reply. JSON was correctly formatted, it wasn't taking it as string, hence JSON had to be within single quote.

    TableMappings: '{ "rules": [ { "rule-type": "selection", "rule-id": "528656830", "rule-name": "528624433", "object-locator": { "schema-name": "APPLSYS", "table-name": "FND_CURRENCIES" }, "rule-action": "include", "filters": [] } } ] }'

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions