TypeError: ecs.tagResource is not a function

0

Hi,

Trying to work out why I cant tag a Running ECS Task via Lambda. I've enabled the new ARNs in ECS. Using Node.js 6.10 runtime. Error message seems to indicate that the function doesnt exist on the object Im calling (See Code).

What am I doing wrong, is the function on a different object? Also if I try to tag when starting the task, it tells me that the "tags" property is unexpected.

Many Thanks!
Paul.

Example Code:
'use strict';

var AWS = require('aws-sdk');
var ecs = new AWS.ECS();

exports.handler = (event, context, callback) => {
if(event['id'] && event.id!=null && event.id.length>0){
var params = {
resourceArn: process.env.PREFIX _ "/" _ event.id,
tags: [
{
key: "TestTag",
value: "TestTag"
}
]
};
ecs.tagResource(params, function(err, data) {
if (err){
console.log(err, err.stack); // an error occurred
callback(null, { status: true });
} else {
console.log(data); // successful response
callback(null, { status: true });
}
});
}else{
callback(null, { status: true });
}
};

Output:
2019-05-10T17:03:12.966Z 7ae84b85-846f-4638-845c-3414fc96f009 TypeError: ecs.tagResource is not a function
at exports.handler (/var/task/index.js:17:14)

gefragt vor 5 Jahren348 Aufrufe
1 Antwort
0

Fixed by changing the run time. Had to use NodeJS 10.x.

beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen