EBS volumes and EC2 instance mapping - amazon-web-services

We have 10 EC2 instances and each of them has it's own EBS volumes, none of them are tagged and now i selected all the EBS volumes at once an detached them from their current EC2 instances.I want to attach those EBS volumes back to their respective EC2 instances just as they were attached before i detached them.
Question : How do i find which EC2 instance was connected to which EBS volume previously, I want to find this info and re-attach them as they were previously present

There is a way.
Go to https://console.aws.amazon.com/cloudtrail
Set Filter = Resource Name & enter volume-id.
It'll give you all events regarding the volume you've provided.
Hope it'll help :)

You can configure CloudTrail for the same. You can get the API logs from CloudTrail when you delete or attache EBS volumes. From CloudTrail you can find EBS volume which was attached to the instance.

Related

How 2 extra EBS be attached to newly spun EC2 instance in autoscaling group?

In autoscaling group, I have an EC2 instance (with two EBS storage) which could terminate due to any fault and a new EC2 instance is spun in it's place inside the autoscaling group.
My question is how the two EBS storage attached to old EC2 instance be attached to new EC2 instance.
if this is manual process, could reference to terraform be provided.
#rukan I guess you need to make 'DeleteOnTermination' value as false, as you would need EBS of old instances for newly created one.
Reference :
https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_Ebs.html
https://francescoboffa.com/aws-stateful-service-ebs/
Update :
I tried to do some research on your requirement and I can conclude my answer that there is no standard method where we can re-use EBS volume in AWS auto-scaling group. Moreover It is not recommended one, as autoscaling groups start multiple EC2 instances. Each EBS volume can only be attached to a single EC2 instance. For now, I can suggest to use AWS EFS instead of EBS.
But, if this is must do requirement with EBS, then we need think of some complex logic where writing some kind of startup script which associated the volume with the EC2 instance then mounted it. You can refer this answer
Reference :
https://serverfault.com/questions/831974/can-i-re-use-an-ebs-volume-with-aws-asg

My AWS EC2 EBS backups: are they volume or instance backups?

I have created some EBS backups over the years, but I can't remember if they were volume or instance backups. Is there some way to tell by looking at one or more field(s) in the list, e.g., at https://ap-southeast-1.console.aws.amazon.com/ec2/v2/home?region=ap-southeast-1#Snapshots:sort=desc:startTime, or in the detailed "description" when I click on one of the snapshots? (the detailed description looking as in the snapshot below, for example) Unfortunately, there isn't a field that says "EBS backup type" that takes a value of "instance" or "volume". As indicated in this stackoverflow question, for example, both types are stored as "EBS Snapshots", so as I understand it then, both will appear mixed together in the same list of EBS snapshots.
Most of the previous questions, e.g., this stackoverflow question, or other pages I've found from searching, have been about the differences between volume and instance backups, and how one might choose one or the other. However, I'm not asking about that, but just if there is any way I can tell what type my previous backups are. Or do I just have to tag the type myself or put it as part of the description string?
UPDATE
From looking at the VolumeID of the snapshot (vol-0565abe0e54ad4adf in the image, for example), I'm guessing that if an existing ec2 instance is using that volume, then that particular snapshot was an instance snapshot? But it could also have been a volume snapshot of that volume?
UPDATE 2
It appears there is some confusion regarding what I'm referring to (from the answers and comments posted so far). I'm not using DLM, but the EC2 console (see image below, and "Snapshot" is the place I navigate to.
Then, when I click on "Create snapshot", I see the following, which shows the options of volume and instance (the first question). This may be a new option, as I don't remember seeing it before.
An EBS snapshot is a backup of a single EBS volume. The EBS snapshot contains all the data stored on the EBS volume at the time the EBS snapshot was created.
An AMI image is a backup of an entire EC2 instance. Associated with an AMI image are EBS snapshots. Those EBS snapshots are the backups of the individual EBS volumes attached to the EC2 instance at the time the AMI image was created.
To get Snapshots associated with still running Volumes, attempt to match their VolumeID with the VolumeID of still running Volumes. Output the SnapshotID of matches.
A snapshot is performed on a single volume, these will always be a backup of the individual volume rather than th complete ec2 instance.
To restore this snapshot, you would restore it to create a new EBS volume that could then be attached to an EC2 instance.
If however your instance is running a single volume you can go one step further. Instead of launching as an EBS volume you can instead create an AMI from the snapshot. This AMI can then be used to launch further instances using the base image taking from the snapshot.
I suspect you are using Data Lifecycle Manager (DLM), not exactly AWS Backup, because you are getting snapshots, AWS Backup work with vault, so you would not see snapshot.
If this is the case, DLM only work with volumes, so you only get backup of your volumes, not instances.
With AWS Backup you can have both, backup of your volumes and/or backup of your instances.
They will be contained inside a vault when backup happens, when necessary you will need to restore it from vault, which will gives you an AMI or a volumes, depending on which kind of backup you did.
Thanks for your update!
I got your point, the instance option there is just a helper to facilitate your life, imagine that you have an instance with 2 volumes and you want to create a snapshot of both volumes, in this case you could go to this screen and create one
snapshot each time (refering volume id on each time), or you can do it once refering the instance id and console will get both volumes for you and create both snapshots.
Doesn't matter which option you choose there, it will just create snapshot from volume, it will not do anything about your instance. If you want you can add a tag in your snapshot to refer to your instance, but it is just a meta-data.
So in your case you are just creating "backups" of your volumes!
If you lose your volume you can restore it, but if you lose your instance you will have to recreate your instance again (with all details) manually.
If you want to create a "backup" from your instance you need to create an image, which will give you and AMI, not a snapshot.
AMI will "backup" your instance details and will create a snapshot from all instance volumes (not ephemeral ones).

How to attach one volume to multiple instances in EUCALYPTUS amazon aws cloud server

[Eucalyptus]
I have a EBS volume created, and i will have to attach it to all other running instances. Currently AWS EBS volume attaches to only one running instances at a time.
So, Are there any other volume types which actually attaches one volume to multiple instances? Please help.
A Better approach would be to use AWS EFS. It's Network File Sharing on Steroids (provided by AWS, obviously). You can share a volume between multiple instances. AWS EFS - Elastic File System
Hope this helps.
No, you can not attach one EBS Volume to multiple instances at the same time in Eucalyptus. You can only attach to one instance, then detach the volume and attach to another instance.

Are the ebs volumes used by the instances launched by an autoscaling group deleted when the instances are replaced/terminated?

I have an auto-scaling group with 2 instances.
Every time an instance is launched an EBS volume is attached to it. When it is replaced/terminated is the EBS volume deleted ?
I want to keep a tight budget on my account and I dont want to have volumes lingering and pay for them.
You can configure it both ways. If you are using the web interface to configure the launch configuration when you get to Storage you will see this:
You just need to check the "Delete on Termination" checkbox on the right, whenever an instance is terminated the EBS volume associated will be deleted as well.

How do I find out which AWS Region an EBS snapshot lives?

Is there any way to figure out which region an AWS EBS snapshot lives in?
A collaborator shared an ebs snapshot with me but I'm having a very slow transfer rate when I attached it to my instance (which is in USEAST-1d). I was wondering if the snapshot lived somewhere else but couldn't find a way to check it.
Snapshots operate on Amazon EC2 regional scope. You cannot create a volume from a snapshot residing in different region. Since you are able to create a volume in US-East-1A, i assume your snapshot also resides on US-East region.
Also as eric mentioned it is not possible to attach a snapshot to an EC2 directly, you have to create an EBS volume and then attach the volume to EC2 instance