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)

demandé il y a 5 ans348 vues
1 réponse
0

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

répondu il y a 5 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions