Skip to content

Filter and operators support in AWS SDK v3 #3842

Answered by RanVaknin
guptanid27 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @guptanid27 ,

The SDKs do not support filtering of EC2 API results. I think the reason you can do that using the console and CLI is for you to quickly show and sort data that otherwise would have needed some "massaging" on the SDK level.

Using the example from the link you provided, using the CLI to filter describeInstances would look like this:

aws ec2 describe-instances --filters Name=instance-state-name,Values=running

With the SDK you can achieve the same functionality by simply operating on the raw list of data:

import { EC2Client, DescribeInstancesCommand } from "@aws-sdk/client-ec2";

const client = new EC2Client({region: "us-east-1"});

try {
    const response = await client.send

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by RanVaknin
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants