Skip to content

AWS Autoscaling Group with Spot Fleet

Compare
Choose a tag to compare
@mohammadzainabbas mohammadzainabbas released this 30 Dec 15:43
· 1144 commits to main since this release

AWS Autoscaling Group with Spot Fleet

Deploy

Overview

A Pulumi IaC program written in Python to deploy AWS Autoscaling Group with Launch Template to request Spot Instances for multi-type instances.

Included:

  • AMI ID (Look up the latest AWS Deep Learning AMI GPU CUDA)
  • Create new VPC, Subnets (Public and Private), RouteTables and Security Group
  • Define Launch Configuration with User Data
  • Create Autoscaling Group with Launch Template and Spot Fleet

Prerequisites

  • Python 3.9+
  • Pulumi
  • AWS CLI v2 (with valid credentials configured)
  • AWS Native CLI

Quick Start

Setup

  1. Configuring OpenID Connect for AWS:

Follow the guideline here to configure Pulumi to use OpenID Connect to authenticate with AWS.

  1. Clone the repo:
git clone https://github.com/mohammadzainabbas/pulumi-labs.git

or if GitHub CLI is installed:

gh repo clone mohammadzainabbas/pulumi-labs
  1. Change directory:
cd aws-fleet-python
  1. Create a new Python virtualenv, activate it, and install dependencies:
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
  1. Create a new Pulumi stack, which is an isolated deployment target for this example:
pulumi stack init
  1. Update your environment:

Now, update your environment (that you'd already setup in step 1) in Pulumi.dev.yaml like the following:

environment:
  - aws-jarvis

Note that the aws-jarvis is the name of the environment that I've created in step 1.

  1. Set the AWS region (optional):

To deploy to a region other than the default one configured for your AWS CLI profile, run pulumi config set aws:region <region>

pulumi config set aws:region us-east-1

If you don't specify anything, everything will be deployed in eu-west-3 region.

  1. Run pulumi up to preview and deploy changes:
pulumi up

Note: you can use --yes flag to skip the confirmation prompt.

and voila! You've deployed Auto scaling group using spot fleet along with your custom launch config to AWS.

Cleanup

To destroy the Pulumi stack and all of its resources:

pulumi destroy

Note: you can use --yes flag to skip the confirmation prompt.

Full Changelog: v1.0...v2.0