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)

asked 5 years ago341 views
1 Answer
0

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

answered 5 years ago

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