Filter and operators support in AWS SDK v3 #3842
-
Is "contains" filter supported in AWS SDK v3 for EC2 client? Also Please let us know filters and operator support in AWS SDK v3 for EC2 client and if there is any documentation related to it. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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
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(new DescribeInstancesCommand({}));
const runningInstances = response.Reservations.filter(reservation =>{
return reservation.Instances[0].State.Name !== "running"
})
console.log(runningInstances)
} catch (error) {
console.log(error)
} Let me know if you have any other questions. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
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:With the SDK you can achieve the same functionality by simply operating on the raw list of data: