How to launch an EC2 instance from reserved instance - amazon-web-services

Once I purchased a reserved instance and i launched an instance with the same specification of the reserved instance. But in billing the launched instance is shown as on-demand instance.
May I know the steps to launch an EC2 instance from a reserved instance?

Please check if your specification really mach, the RI should be applied when parameters match
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/apply_ri.html

Related

Apply Amazon EC2 t2.small Reserved Instance to t3.small

I converted an Amazon EC2 t2.small instance into a t3.small instance.
Can I apply the t2.small Reserved Instance to the t3.small instance?
An Amazon EC2 Reserved Instance only applies to a specific instance family (eg T2 or T3).
If you purchased it as a Convertible Reserved Instance, then you can exchange the T2 Reserved Instance for a T3 Reserved Instance. (Actually, it's more like a refund and credit applied to the new Reserved Instance.)
If it is not 'Convertible', then you cannot change the Reserved Instance. However, you could sell the existing Reserved Instance on the Reserved Instance Marketplace and purchase a new one for T3.
See: Standard vs. Convertible Offering Classes - Amazon EC2 Reserved Instances and Other AWS Service Reservation Models

What happens internally in AWS when EC2 instance is upgraded

Wanted to know more about internals of AWS when we autoscale an instance from one tier to another. Does AWS creates an image and spins up new instance and restores the image ? or what exactly happens inside. ?
Amazon EC2 Auto Scaling will either Launch a new instance or Terminate an existing instance. This is known as horizontal scaling. No instance is "upgraded".
In fact, it is not possible to "upgrade" an Amazon EC2 instance. Instead, you need to Stop the instance, change the Instance Type, then Start the instance again. This will launch the instance on a different host, which is dedicated to running the new Instance Type.
The disks used on Amazon EC2 are (typically) Amazon Elastic Block Store (EBS) volumes. These are network-attached volumes that exist separately to the EC2 instance. Thus, the disks are preserved when the instance is stopped and they are automatically reattached to the instance when it is started again.

Launching AWS reserved Instances with Terraform

I want to create reserved instances for long periods of time like e.g. with one year run time. Does anybody know if Terraform allows to create such reserved instances in AWS?
I could now find anything in the Terraform documentation.
Reserved instances in AWS work on a first come first served basis. If you create any on demand instance that happens to match the criteria of your reserved instance then it will use your reserved instance quota first.
The AWS docs also explain this:
Reserved Instances are automatically applied to running On-Demand
Instances provided that the specifications match. If you have no
running On-Demand Instances that match the specifications of your
Reserved Instance, the Reserved Instance is unused until you launch an
instance with the required specifications.
If you're launching an instance to take advantage of the billing
benefit of a Reserved Instance, ensure that you specify the following
information during launch:
Platform: You must choose an Amazon Machine Image (AMI) that matches the platform (product description) of your Reserved Instance. For
example, if you specified Linux/UNIX, you can launch an instance from
an Amazon Linux AMI.
Instance type: Specify the same instance type as your Reserved Instance; for example, t2.large.
Availability Zone: If you purchased a Reserved Instance for a specific Availability Zone, you must launch the instance into the same
Availability Zone. If you purchased a regional Reserved Instance, you
can launch your instance into any Availability Zone.
Tenancy: The tenancy of your instance must match the tenancy of the Reserved Instance; for example, dedicated or shared. For more
information, see Dedicated Instances.

How to work on amazon aws ec2 reserved instance?

Recently I have purchased a reserved instance EC2 t2.medium.
There is no option to start and stop, whereas my freetire has all the features including stop, start, with public ip, etc.
Please Suggest me, how to use and work around reserved instance||
Reseverd instances are not started or stopped, they merely present the reservation of an on-demand instance at a reduced price. In order to use your reserved instance, you just need to have an instance of the same type as your reserved one already launched, or launch an on-demand instance of the same type and the reservation will be allocated to your instance. The only thing you need to make sure is that the servers will be started in the same availability zone as your reserved instance (for example - if your reserved instance is for us-east-1c AZ you have to choose the same AZ for your on-demand instance)
To make sure you are using the full amount of reserved instances at your disposal, you can check the reports section of your ec2 dashboard. the EC2 Reserved Instance Utilization reports will show you the amount of reserved instance being utilized.

Stopping AWS EC2 instance leads to autocreation of another instance of the stopped one

I had to stop my m3.medium EC2 instance from the AWS console to resize it to m3.large. However, after it stopped, it automatically created a new instance.
Any idea why this is happening? It caused some big troubles for me.
Your AutoScaling group with minimum size = 1 spun up a new instance because there were no instances in the 'running' state available to respond to requests, particularly health checks. Your instance was deemed 'unhealthy' and replaced by the ASG.
If your instance storage was ephemeral, I'm afraid it is gone forever unless you recently saved an AMI. If your instance storage was backed by EBS, you can recover it by attaching the EBS volume to a new instance.
In the future, consider configuring your autoscaling group's launch configuration to have everything you need ahead of time, by either bootstrapping the instance or by baking an AMI.
For 'bootstrapping' an instance:
Create a new launch configuration with a standard AMI avaialble from Amazon.
Add user data to the launch configuration to handle installation and configuration of your desired programs.
For 'baking' an AMI:
Install your desired programs and configuration on a new EC2 instance.
Take an image (AMI) of that EC2 instance.
Use that image in your new launch configuration.
Manually working on an instance within an ASG and expecting the instance to persist indefinitely is dangerous, as you've just discovered.
Further Reading:
EC2 Documentation - AutoScaling Health Checks
EC2 Documentation - Amazon Machine Images