AWS API: Proper syntax for filtering by tag name and value (e.g. describeInstances)

It took me quite a while to figure out the right syntax for filtering instances by tag name and value in the AWS EC2 API's describeInstances.

The documentation is not exactly crystal-clear to me:

  • tag:key=value - The key/value combination of a tag assigned to the resource, where tag:key is the tag's key.

Anyway, here is the proper syntax, provided we are interested in the tag elasticbeanstalk:environment-name:

    var params = {
        Filters: [
                Name: 'tag:elasticbeanstalk:environment-name',
                Values: ['mySuperApp']

So the name of the tag is embedded in the Name part and not, as I initially understood, { Name: 'tag', Values: ['elasticbeanstalk:environment-name=mySuperApp'] }

Credit: garnaat.

Tags: DevOps

Copyright © 2024 Jakub Holý
Powered by Cryogen
Theme by KingMob