I have 3000+ ebs volumes and I want to list them in aws cli.. however when I run the command
aws ec2 describe-volumes
the result ends up showing only one ebs volume and the terminal keeps saying "skipping".
I want to list all in a text file output maybe? or is there any other way to get all ebs volumes.
I need this to describe and filter out unused ebs volumes.. and then delete them!
Based on the comments.
The solution was to use either (to save output to file):
aws ec2 describe-volumes > myfile.txt
or to display it:
ec2 describe-volumes | less
Related
I can see 77 "System" snapshots in us-east-1 on the website / AWS Console. When I run the following:
aws rds describe-db-snapshots --region us-east-1 --include-shared --include-public --no-paginate --output text
... I get 35. I tried this in AWS CloudShell as well as locally with the access/secret from https://console.aws.amazon.com/iam/home?region=us-east-1#/security_credentials so this should be running with maximum (my) privileges.
I think it's excluding Aurora snapshots because the only engine value I see is postgres and not aurora-postgresql. I am going crazy trying to figure out why I can't see everything with the CLI ... any thoughts, pointers, RTFM's?
UPDATE: I added --filters "Name=engine,Values=aurora-postgresql" and sure enough the output is blank whereas --filters "Name=engine,Values=postgres" shows the 30+ entries for non-Aurora. So why are Aurora snapshots being excluded?
(Thanks to #JohnRotenstein for the answer in a comment to my question.)
There is a separate command called describe-db-cluster-snapshots that operates very similarly and outputs results for clusters, obviously, like Aurora. The only way to get the full list as seen in the Console is to combine this output with describe-db-snapshots.
Im trying to identify a way to list all running instances with grafana. Have any of you been able to do this?
Essentially I want a grafana dashboard to display:
Instance-ID >> Region >> Status(up or down) >> Current running time
Do any of you know a way to achieve this?
I don't know if you can do that in grafana, but you can see just the information you want (except for the running time) in the prometheus alert module.
You can find it if you go to prometheus:9090 -> Status -> Targets
It should look something like this
Tom
For anyone that comes to this thread, I have resolved my predicament by using the aws cli.
Essentially I broke it down into two pieces, first get the list of regions, then second get all the instance information i required:
echo Grabbing instances in all regions, please wait..
for region in $(aws ec2 describe-regions --output text | cut -f3);
do
> $region.txt;
$quote="'";
aws ec2 describe-instances --region $region --query 'Reservations[].Instances[].[Tags[?Key==`Name`]| [0].Value,State.Name,InstanceType,PublicIpAddress,Placement.AvailabilityZone,LaunchTime]' --filters Name=instance-state-name,Values=running --output json >> /home/ubuntu/$region.txt; done
Hi Guys I need to do a script which copies the ips from an aws region AMIs that I have running, after copying this IPs place them into a text file inside. If the Instances are turned off, that IP would get removed, and the text file would change real-time, on it's own automatically, I need this to run across all regions, so any Instance that I have "X" AMI running with, the script would find it, copy its IP keep it if it's running and remove it from the file if they switch to shutdown mode.
stack the IPs in a text like
55.555.555.55
66.123.545.54
.....
.....
real-time.
I've never really used aws cli and I know this is possible to do.
Use the describe-instances command in the AWS CLI. All the information that you need (AMI, instance state, IP address) will be included in the response to that command. Note that you will have to run describe-instances once for each region. (Set the --region flag when running the CLI to set the region.)
You can parse the JSON output of the CLI however you want then write the information you want to the text file.
This command uses a aws cli "describe-instances" command with a filter for only instances that are running.
This outputs a lot of data including the "PublicIp" field. The sed command strips out just the ip address from that line and the uniq removes duplicates
aws ec2 describe-instances --filters 'Name=instance-state-name,Values=running' | sed -n 's/^.*"PublicIp": "\([0-9\.]*\)\",/\1/p'| uniq
See http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html for details on the aws cli describe instances command, including other filters you might want to apply
I am very new to AWS. I've got a Windows instance running and have my aws command line configured. I've read through the AWS docs but can't seem to find exactly what I'm looking for.
How do I view my current instances from the command line?
If by view your current instances, you mean list all running instances from the command line, you can call the describe-instances command:
aws ec2 describe-instances
This will list all of your current instances.
See describe-instances
As noted in the answer by Rodrigo M, you should use describe-instances to view your EC2 instances. In general, the help command is the best way to explore the CLI. Start with aws ec2 help and try the various options. You can get more details on subcommands with aws ec2 describe-instances help as well.
The output is a bit verbose and by default in JSON. This can be a bit overwhelming and hard to read without additional processing. I'd recommend getting familiar with the --query aws CLI parameter if you intend to use the CLI interactively.
In particular, I use this for a quick overview of my EC2 instances:
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId, Tags[?Key==`Name`] | [0].Value, State.Name, PublicDnsName]' --output table
To check one particular attribute on an instance:
aws ec2 describe-instances --query Reservations[0].Instances[0].InstanceType --output text --instance-ids <my-instance-id>
The CLI is very powerful once you get comfortable with learning the commands and managing the output. It's also helpful for learning the porgramming APIs as well, since aws CLI commands generally map one-to-one with an API call.
I am working on creating a monitor dashboard for monitoring status of ec2 instances.
I am searching for a method to get information (especially instances ID) of newly spawned instances using auto scaling.
Can anyone point me in the right direction. Thanks
If you know your instance type then you can use describe-instances command to get details about instances and use query command to get the details what you need (in your case Instance-id)
aws ec2 describe-instances --filters "Name=instance-type,Values=t1.micro" --query 'Reservations[*].{InstanceId:Instances[0].InstanceId}'
## Enter your instance type in the 'Values' field of '--filters' command
I was able to get instance id by using combination of following commands
aws elb describe-load-balancers --load-balancer-name "LoadBalanceID" --region "region" --output text | grep INSTANCES
Using the AWS CLI you can get a list of scaling activities for an auto scaling group.
aws autoscaling describe-scaling-activities --auto-scaling-group-name my-group-name
See AWS CLI
This is the newer Python CLI, so you would need to install that if you have not already done so. It will return a JSON block with all of the scale up and down activities in the group, including the reason an the date and time.