Instance Store Volume shared across multiple EC2 Instances - amazon-web-services

I am trying to understand instance store volume and I understand instance store is ideal for temporary storage and provides massive IOPS. It is retained in case of reboot but lost if you stop and start, hibernation or instance termination.
One question I have here is can Instance store be shared across EC2 instance ?
I am seeing the below in the documentation so asking. Also how to achieve this on AWS console ?
An instance store provides temporary block-level storage for your
instance. This storage is located on disks that are physically
attached to the host computer. Instance store is ideal for temporary
storage of information that changes frequently, such as buffers,
caches, scratch data, and other temporary content, or for data that is
replicated across a fleet of instances, such as a load-balanced pool
of web servers
Documentation taken : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html

The diagram is showing a physical host computer in an AWS Data Center. The host can be reconfigured to run many different sizes of an Instance Family (eg large, 2xlarge, 4xlarge). Do not be too concerned by the details of what it is showing.
The simple fact is that, no, instance store volumes cannot be shared across multiple Amazon EC2 instances.

The diagram given in the docs is very confusing(at least for me). I am not able to get my head around it. Maybe the InstanceA,B and C are not meant to be EC2 instances but instance store volumes as in the same diagram you see Host Computer 1 and 2.
Also the most important part is
You can specify instance store volumes for an instance only when you launch it. You can't detach an instance store volume from one instance and attach it to a different instance.
Which is what you want to know. It means you cannot share an instance store volume between 2 or more EC2 instances. When the EC2 machine is up and running, there is no way you can attach it and while launching there is no way you can specify which volume to mounted on the EC2 instance when it's created.

Related

Is volume in aws like a hard drive that the instance uses?

I am learning about aws and using ec2 instances. I am trying to understand what a volume is.
I have read from the aws site that:
An Amazon EBS volume is a durable, block-level storage device that you
can attach to your instances. After you attach a volume to an
instance, you can use it as you would use a physical hard drive.
Is it where things are stored when I install things like npm and node? Does it function like the harddrive o my server?
AWS EBS is block storage volume, and for the ease of understanding, yes you can consider it same as hard drive, however with more benefits over traditional hard drive. few of them are:
You can increase/decrease size of the storage as per your requirement
(Hence name Elastic)
You can add multiple ebs to your instances, for example 20 GB of volume1 and 30 GB of volume2
And for the question you asked if you can install npm & node yes you
can as it would be attached to your EC2 instance and your instance
can easily utilised attached data, modules,etc
For further explanation you can refer this user guide from AWS on EBS: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html
Yes it is exactly like a hard drive on your server and you can have multiple devices.
The cool thing is that you also can expand them if you need extra space.
where things are stored when I install things like npm and node
Yes, technically ebs volume is virtual storage drive which is
connected to your instance through network, ( flash drive connected over network).
Since network is involved which implicitly means there will be some latency because of data transfer through network.
The data is persistent even if instance stops,terminates, hibernates or hardware failure.
Since it is network drive it can be attached or detached to any other instance.
Adding to this there is another type of storage which you will find called as instance store
You can specify instance store volumes for an instance only when you launch it. You can't detach an instance store volume from one instance and attach it to a different instance.
it gives very high IOPS because it is directly (physically) attached to instance.
The use case for instance store would where data changes rapidly like for cache or buffers.
Your data will be lost if any of these events happens like The underlying disk drive fails The instance stops, instance hibernates instance terminates or drive failure.

Resize a running Amazon EC2 instance

I am facing a challenge to scale an existing Amazon EC2 instance from t2.micro to t2.medium.
Can someone suggest me about the best practice to do this, without losing any data which stored on the t2.micro instance?
Follow these steps:
Stop the EC2 instance.
Change the instance type (e.g. t2.micro to t2.medium).
Start the EC2 instance.
Note: You will not lose the data.
When you stop an EC2 instance, what AWS does is the following:
It (AWS) shuts down the machine. So, the CPU, RAM, etc, are available for someone else to use.
It preserves the hard disk(s). Hence, your data is always with you.
In the shut-down state, you can change the machine type. This only logically links the CPU, RAM, etc. When you start the machine, AWS allocates the actual machine to you and connects your hard disk to that machine.
Note: In the shut-down state, you don't pay for CPU, RAM etc but since you keep the disk, you continue to pay a little amount towards the disk.
If you do not want to use the machine in the future select option menu > Instance State > Terminate.
The answer is simple, stop the EC2 instance, change its instance type and start it.
Note: Stopping and restarting the instance erases any data on instance store volumes. Be sure that you back up any data on the instance store volume that you want to keep. Instance store volumes are different from EBS volumes.
Reference: Back Up an Instance Store Volume to EBS

Unable to identify ephemeral storage on EC2 t2.small instance running on Linux

I am trying to create swap memory on an EC2 instance as RAM utilization is quite high.
As per recommendations to do it on ephemeral storage, I am trying to find out which mount point is ephemeral storage?
This is the fstab entry on my instance:
Now I need to know which one is ephemeral storage so that I can use it for swap. If any of these is not ephemeral then how can I get it?
You are using a t2.small instance type.
The T2 instance family does not have an Instance Store (also known as Ephemeral Storage).
To discover which instance types have Instance Store, see: Amazon EC2 Instance Types
On that page, you will notice that the T2 instances say EBS-Only in the Storage column. If you wish to have an Instance Store, select a different instance type that includes an Instance Store. Alternatively, just use a normal Amazon EBS volume for swap space, since the main reason for using a T2 instance is for cost savings.

Doubts about recovering a .pem of an EC2 in AWS

We are working with an EC2 instance in Amazon Web Services but we have lost our .pem.
In order to create a new one, we are following this guidance:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-lost-key-pair
However, we are a bit worried because of this warning:
When you stop an instance, the data on any instance store volumes is
erased. Therefore, if you have any data on instance store volumes that
you want to keep, be sure to back it up to persistent storage.
We cannot access the instance, therefore we cannot really make a proper backup. Instead, we have make a snapshot of the volumes in Elastic Block Store.
We are wondering if this is enough and we can indeed stop the instance to proceed to the pair key recover or we need to do something else in order not to lose any data.
It depends on the type of instance.
If it's EBS backed you are probably safe to proceed as the volume will be reattached.
If it's instance store backed and you lost access to it you basically have lost what's on that machine.
By the sounds of it it's EBS backed. If it's instance store backed and you later created and attached an EBS volume and used that, you're going to be able to restore/reattach that volume just fine - but it's going to be to another machine.
Depending on how many instances we are talking about you should also be able to take an AMI Image of the running instance which will take snapshot of the EBS but also the exact state of the instance.
However if the instance's root device type is using a EBS backed store all the data should be safe so saving a snapshot and relaunching a new instance with the snapshot should have the data.
Good luck.

Persistent storage on Elastic Beanstalk

How can i attach persistent storage on Elastic Beanstalk ?
I know i need to have a .config file where i set the parameters of the environment to run every time an instance is created.
My goal is to have a volume, let's say 100GB, that even if the instances got deleted/terminated, i have this volume with persistent data where all instances can access to read from.
I could use S3 to store this data, but it would require changes to the application, and latency could be a problem.
This way i could access the filesystem like any common server.
AWS now offer a solution called Elastic File System (Amazon EFS) that lets multiple instances access a shared file store.
If your desire is to have a central data repository that all EC2 instances can access, then Amazon S3 would be your best option.
Normal disk volumes are provided via Elastic Block Store (EBS). EBS volumes can only be mounted to one EC2 instance at a time. Therefore, to share data that is contained on an EBS volume, you will need to use normal network sharing methods to mount network volumes.
However, if your goal is to provide shared access without one specific instance sharing a volume to other instances, then it is better to use S3 because it is accessible from all instances. It would likely be worth the effort of modifying your application to take advantage of S3.