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)

已提问 5 年前348 查看次数
1 回答
0

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

已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则