Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws-sdk javascript filter on tag:key=value

Folks, I am having difficult time understanding the docs http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html

I need to grab all the running instances with the following tags assigned to them:

project=foo environment=production

The following does not seem to work.

var params = {
    DryRun: false,
    Filters: [
        {
            Name: 'instance-state-name',
            Values: [
                'running'
            ],
        },
        {
            Name: 'tag:key=value',
            Values: [
                'foo',
                'production'
            ],
        },
    ]
};

ec2.describeInstances(params, function (err, data) {
...
like image 929
Cmag Avatar asked May 02 '14 22:05

Cmag


1 Answers

If your tag's key is 'foo' and its value is 'production', you should change your code to the following. The Name is in the 'tag:key' format, and the Values are the data you are looking for that correspond to that key.

{
    Name: 'tag:foo',
    Values: [
            'production'
    ],
},
like image 122
clairestreb Avatar answered Oct 02 '22 19:10

clairestreb