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!
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.
Also...
Make sure there are no extra unintended spaces in any of your parameters. For example
https://ec2.amazonaws.com/?Action=RunInstances&ImageId=ami-7ba91a12&MaxCount=3&MinCount=1&Placement.AvailabilityZone=us-east-1b&Monitoring.Enabled=true&AWSAccessKeyId=AKIAJTLX2WXU44OXMBKQ&Version=2012-07-20 &Timestamp=2012-09-19T21:07:32&SignatureVersion=2&SignatureMethod=HmacSHA256&Signature=XXXXXXXXXXXXXXXXXXXXX
Or you will get that error message. Even spaces in other parameters besides the version will trip up this error.
You can find the latest release of ec2 tools at this website. http://aws.amazon.com/developertools/351