Quantcast
Channel: Active questions tagged powershell-3.0 - Stack Overflow
Viewing all articles
Browse latest Browse all 149

How to get latest EBS volume Id with specific tag using aws cli?

$
0
0

I have to query my AWS account to find latest created volume with specific tags and should have it attached to running EC2 instance. How do I achieve this using aws cli and powershell?

I was using below powershell script and aws cli to achieve this, But I was not able to find out exact query to get latest volume id using aws cli command to replace variable $volumeid. Any help would be appreciated.

$volumeid = "aws ec2 describe-volumes --region us-east-1 --filters Name=tag:Application_Name,Values=APPone Name=tag:Name,Values=APP_test --query "Volumes[*].{ID:VolumeId}"$instanceId = (New-Object System.Net.WebClient).DownloadString("http://169.254.169.254/latest/meta-data/instance-id")Add-EC2Volume -VolumeId $volumeid  -InstanceId $instanceId -Device xvdf -Region us-east-1

Viewing all articles
Browse latest Browse all 149

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>