Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node AWS-lib: CreateTags action 'not valid for the web service'

Node AWS-lib: CreateTags action 'not valid for the web service'

Problem

I am using Node's aws-lib module. I understand it's a fairly thin wrapper around the node API, eg running call("CreateTags") will wrap the Createtags call as documented in the API.

I'm successfully calling other API functions, eg, RunInstance and DescribeInstances work fine. However CreateTags causes problems:

ec2.call("CreateTags", {
  'ResourceId.1':notmyrealresourceid,
  'Tag.1.Key':'Name'
  'Tag.1.Value':'Somemachine'
}, function(err, result){
  if ( err) {
    console.log('Failure tagging image');
    console.log(err)
  }
}) 

Responds with the following in err:

The action CreateTags is not valid for this web service.

The API definitely mentions CreateTags exists. How can I make it work? What am I missing? Thanks!

Problem courtesy of: mikemaccana

Solution

That appears to stem from a questionable default for the optional Amazon EC2 API 'version' parameter in aws-lib, see the current master branch definition of var ec2Client:

  // Amazon EC2 API handler which is wrapped around the genericAWSClient
  var ec2Client = function(obj) {
    var aws = genericAWSClient({
      host: obj.host, path: obj.path, accessKeyId: obj.accessKeyId,
      secretAccessKey: obj.secretAccessKey, secure: obj.secure
    });
    obj.call = function(action, query, callback) {
      query["Action"] = action
      query["Version"] = obj.version || '2009-11-30'
      query["SignatureMethod"] = "HmacSHA256"
      query["SignatureVersion"] = "2"
      return aws.call(action, query, callback);
    }
    return obj;
  }

That is, the selected EC2 API version defaults to the pretty ancient '2009-11-30' (current is '2012-04-01') and tag support has been introduced in API version '2010-08-31' only (see Release: Amazon EC2 on 2010-09-19 - a version independent overview is available via the Document History within the Amazon Elastic Compute Cloud API Reference).

Accordingly, you'll simply need to supply a sufficiently recent EC2 API version and should be fine.

Solution courtesy of: Steffen Opel

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node AWS-lib: CreateTags action 'not valid for the web service'

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×