[{"data":1,"prerenderedAt":31},["ShallowReactive",2],{"snippet-vpc-subnets-serverless":3},{"id":4,"title":5,"contributors":6,"description":8,"extension":9,"gitHub":10,"introBox":13,"languages":17,"meta":19,"resources":20,"services":21,"snippets":23,"stem":27,"tags":28,"type":29,"__hash__":30},"snippets\u002Fsnippets\u002Fvpc-subnets-serverless.json","Find all VPC subnets with a specific tag",[7],"content\u002Fcontributors\u002Fxolile-speelman.json","Using AWS CLI to find all VPC subnets with a specific a tag","json",{"template":11},{"repoURL":12},"https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-snippets\u002Ftree\u002Fmain\u002Fvpc-subnets-serverless",{"headline":14,"text":15},"How it works",[16],"The AWS CLI command can find across multiple regions all instances of AWS VPC Subnet that has a specific tag attached",[18],"Bash",{},null,[22],"vpc",[24],{"title":5,"description":25,"language":18,"code":26},"The following describe-subnets example uses a filter to retrieve the details of those subnets with the tag VPCname=HappyVPC and the --query parameter to display the subnet IDs of the subnets with this tag. You can replace the key pair value to your own tags you to filter in your account.","for region in `aws ec2 describe-regions --query \"Regions[].RegionName\" --region us-east-1 --output text`\ndo\n    echo \"[${region}]\"\n    aws ec2 describe-subnets --filters \"Name=tag:VPCname,Values=HappyVPC\" --query \"Subnets[*].SubnetId\" --output text --region ${region}\ndone\necho \"finished\"\n","snippets\u002Fvpc-subnets-serverless",[],"AWS CLI","lxCIpYRobsoNY-7MH0CnmoTl6lO6DP2Z76b5d6-ku7c",1792578864499]