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.

googlecloud Article's
30 articles in total
Favicon
Are millions of accounts vulnerable due to Google's OAuth Flaw?
Favicon
How to Become a Google Cloud Platform (GCP) Engineer in 2025
Favicon
How I Use Google Cloud AI for Programming
Favicon
Google Cloud Shell: Establishing Secure Connections via SSH
Favicon
Deploy your Flask API on GCP Cloud Run 🚀
Favicon
Create spot instances on GCP & AWS
Favicon
Sécuriser l'association entre un projet et son compte de facturation sur Google Cloud Platform
Favicon
Top 6 Big Data Trends and Future Predictions
Favicon
My SaaS passed CASA Tier 2 Assessment and yours can too. Here is how
Favicon
A Complete Guide to Database Services in Google Cloud Platform: Features, Capacity, and Popularity
Favicon
🏆 Branching to Level Up in the Cloud! ☁️
Favicon
🌟 Ticket - 2024: Status - Closed 🏆
Favicon
Data Transfer from S3 to Cloud Storage using GCP Storage Transfer Service
Favicon
Creating a Local Environment to Operate GCS Emulator from Flask
Favicon
Why Rust is the Future of AI and ML Ops
Favicon
How Data Analytics in the Cloud Can Level Up Your App
Favicon
Crack the AWS Solution Architect Associate Exam with Eduleem's Expert Training Program!
Favicon
Top Tips: Savings Plans vs. Reserved Instances Across AWS, Azure, and GCP
Favicon
Why Cloud Monitoring is Non-Negotiable for Today’s Tech Giants
Favicon
Why Cloud Provider’s Native Tooling Struggles to Deliver FinOps Excellence
Favicon
Cloud Migration Made Easy: Expert Solutions for Seamless Business Transition
Favicon
HOW TO CREATE A PRESIGNED URL FOR AN S3 (simple storage service)aws
Favicon
NgSysV2-5.3: A Young Person's Introduction to the Google Cloud Shell
Favicon
Read “Enhance Your AI Interactions with Vertex AI Prompt Optimizer“ by Daksh Srivastava on Medium
Favicon
The Secrets of Cloud Services — Avoid Hidden Traps and Maximize Benefits
Favicon
Top 45+ GCP Interview Questions in 2025 - Google Cloud Platform Interview Tips
Favicon
Automating BigQuery Data Preprocessing and AutoML with Vertex AI Pipelines
Favicon
Cloudnosys Now Available on Google Cloud Marketplace
Favicon
Buy Best Cloud Accounts
Favicon
Mastering Cloud Costs Optimization: Proven Strategies And Best Practices

Featured ones: