简体   繁体   中英

Fetch private subnet through name filter

I am trying to fetch private subnet-ids through aws cli. I have used this command earlier aws ec2 describe-subnets --filters Name=vpc-id,Values=abc Name=tag:Name,Values=private --query 'Subnets[*].SubnetId' .

But this time I don't want to provide a static value=private, instead I want to find subnets that contain the word private in their name.

Is there a way to use contains or begins with in the filters for aws cli command?

Thanks.

If you want to filter for subnets that contain private in the Name tag, you can use:

aws ec2 describe-subnets --filters "Name=tag:Name,Values=*private*"

If you want to filter for subnets that start with private in the Name tag, you can use:

aws ec2 describe-subnets --filters "Name=tag:Name,Values=private*"

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