0

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

 2 years ago
source link: https://blog.jakubholy.net/2015/06/11/aws-api-proper-syntax-for-filtering-by-tag-e-g-describeinstances/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

June 11, 2015
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']
            }
        ]
    };
    ec2.describeInstances(params);


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

Are you benefitting from my writing? Consider buying me a coffee or supporting my work via GitHub Sponsors. Thank you! You can also book me for a mentoring / pair-programming session via Codementor or (cheaper) email.

Allow me to write to you!

Let's get in touch! I will occasionally send you a short email with a few links to interesting stuff I found and with summaries of my new blog posts. Max 1-2 emails per month. I read and answer to all replies.

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK