Logo

dev-resources.site

for different kinds of informations.

Create spot instances on GCP & AWS

Published at
1/13/2025
Categories
cloud
finops
googlecloud
aws
Author
jdxlabs
Categories
4 categories in total
cloud
open
finops
open
googlecloud
open
aws
open
Author
7 person written this
jdxlabs
open
Create spot instances on GCP & AWS

When you create virtual machines on Cloud providers, the price depends on the size on the machine and the region where you create it.

You have the possibility to reserve capacity for a long period of time (1 year for instance), to have reductions from the provider.

Another way to have reductions is to get Spot instances : it offers reduced price machines based on spare resources not used by other machines.

The advantage is that you have very interesting price for you virtual machines, the downside is that you should consider this resources can break at any moment.

For developement and testing environments, that’s a very good option.

You have to handle the automated rebuild of the instances to work properly. That’s why we will build a Managed Instance Group on GCP and an Autoscaling Group on AWS.

We are going to see how to implement that on both providers.

On Google Cloud

First, you need to create an Instance Template, in the Compute Engine section :

gcp step 1

Give a name to this Instance Template, and select a region (we choose one where there are free credits) :

gcp step 2

We choose e2-micro instance (General purpose with 1 Gb RAM), we can see that the cost is very low for one month, including storage : $3.44 :

gcp step 3

You can set some firewall rules :

gcp step 4

And assign to your prefered VPC, then create :

gcp step 5

Now you will create a MIG (Managed Instance Group), to create the VMs according to this template :

gcp step 6

Create a stateless Instance Group, give a name and select the template :

gcp step 7

Set a location with multiple zones, set an Autoscaling to have permanently 2 machines running, then create the MIG :

gcp step 8

Now you can access your VMs, by clicking “Connect SSH” :

gcp step 9

On AWS

First, you need to create a Launch Template, in the EC2 section :

aws step 1

Give a name to this Launch Template :

aws step 2

Select an AMI from the catalog, Amazon Linux will allow to easily connect with session manager, and Arm will use less resources and cheaper :

aws step 3

Select t4g.nano, that is an optimized general purpose instance, with a base price of 0.0046 USD per hour :

aws step 4

Select the VPC and Security group you want to use (for the SG, just allow All traffic in Outbound, for now) :

aws step 5

Specify a tag “Name” for your instances to recognize them in the list later :

aws step 6

In Advanced details, specify an IAM role for SSM acces, and that you want Spot instances, then create the template :

aws step 7.1

aws step 7.2

aws step 7.3

Now, create an Auto Scaling Group (ASG) :

aws step 8

Name it and select the template just created :

aws step 9

Select the network options you prefer :

aws step 10

Select the scaling policies you want, then you can create the ASG :

aws step 11

Now you can access your VMs, using Session Manager :

aws step 12

Conclusion

You can see that this mechanism is really similar on both of these cloud providers and Spot instances are really easy to implement.

Of course, the best option will be to automate it an IaC tool like Terraform or OpenTofu and to optimize it according to your needs.

You now have the keys to implement them on your projects, to have low-cost computing resources for any development objective.

cloud Article's
30 articles in total
Favicon
What is Cloud Service Providers? Types, Benefits, & Examples
Favicon
DEPLOYING A WEB APPLICATION WITH ARM TEMPLATE AND AZURE CLI
Favicon
Top 7 Kubernetes Certifications in 2025
Favicon
Configuring Public IP addresses in Azure
Favicon
Kubernetes on Hybrid Cloud: Talos network
Favicon
Cloud computing can be confusing, but it doesn't have to be! ☁️🤔 In the latest episode of Cloud in List of Threes (CiLoTs), I’m serving up easy-to-digest (pun intended 🤭) explanations analogy to explain Regions, Availability Zones, and Edge Locations
Favicon
From Regions to Edge Locations: A CiLoTs Guide to Cloud Infrastructure
Favicon
Unlocking AI Potential: Simplifying Generative AI with AWS Bedrock
Favicon
Want to learn a top skill in 2025? Then check out Cloud Computing.
Favicon
🤖 DevOps-GPT: Automating SRE Resolutions with AI-Powered Agents and Insights 🤖
Favicon
Joining the AWS Community Builders Program A Journey of Growth and Collaboration
Favicon
Por onde começar os estudos da AWS - Parte 1
Favicon
Introduction to AWS services & It's carrier opportunities
Favicon
Research Paper Series: Using Lightweight Formal Methods to Validate a Key-Value Storage Node in Amazon S3
Favicon
Patching Scheduled Auto Scaling Groups with AWS
Favicon
S3 Batch Operations: Simplify Repetitive Tasks
Favicon
Firebase Alternatives to Consider in 2025
Favicon
Key Lift and Shift Migration Use Cases for Cloud Migration Success
Favicon
AWS, Azure, and GCP: Which provider is best for your needs?
Favicon
open source multi tenant cloud database
Favicon
Iniciando nuevamente...
Favicon
Oracle Cloud’s 25A Release Is Coming: Are You Prepared?
Favicon
Google Cloud Shell: Establishing Secure Connections via SSH
Favicon
Create spot instances on GCP & AWS
Favicon
Kubernetes on Hybrid Cloud: Bare-metal or Hypervisor
Favicon
🌥️ Evolução da Hospedagem em Nuvem
Favicon
Por que e como rodar bancos de dados em diferentes nuvens?
Favicon
What Makes a Good Cloud Architect?
Favicon
Attended Re:invent Recap at aws user group surat
Favicon
MDM Cloud Migration Architecture: The Future of Data Management

Featured ones: