简体   繁体   中英

Is it possible to use Regex expressions in the nodeJS aws sdk?

I can run this AWS cli command and get the correct images created in the past 45 days.

 aws ec2 describe-images --region us-east-1 --owners self  -- query'Images[CreationDate<`2021-12-18`] | sort_by(@, &CreationDate)[].Name'

But following this documentation: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeImages-property Is there a way to input a regex in order to get the Images that were created in the last X days? I can't find a way to query like this in NodeJs's aws sdk.

The --query parameter in the AWS CLI tool is a client-side filtering method . The full results will be returned from AWS, and then the --query parameters are applied to the JSON response that was returned.

The equivalent of this in NodeJS would be to call the AWS SDK and get all the results back, and then iterate over the results and apply your regex, or use some sort of JSON filtering library on the results after you have obtained them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM