I have a lambda function that needs to run a DMS replication task and right now I’m doing it like this:
const AWS = require('aws-sdk');
var dms = new AWS.DMS();
var params = {
ReplicationTaskArn: 'arn:aws:dms:us-east-1:XXXXXXXX:task:YYYYYYYY',
StartReplicationTaskType: 'reload-target',
};
dms.startReplicationTask(params, function (err, data) {});
As you can see, I’ve hardcoded the ReplicationTaskArn, but this ARN changes because the Replication Task is generated by serverless (cloudformation). Is it possible to somehow get a reference to the replication task and then use that reference in the lambda function (instead of hard-coding the Task ARN)?
Relevant parts of the serverless.yml file:
functions:
runDmsTask:
handler: src/functions/runDmsTask.runDmsTask
resources:
Resources:
myReplicationTask:
Type: AWS::DMS::ReplicationTask
Properties:
ReplicationTaskIdentifier: my-replication-task
Outputs:
myReplicationTaskArn:
Value:
Ref: myReplicationTask