Elastigroup & CloudFormation

AWS CloudFormation gives developers and systems administrators an easy way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion.


Infrastructure as a code

As developers and DevOps engineers want to manage their infrastructure as a code using tools like AWS CloudFormation and HashiCorp Terraform, Spotinst is happy to release an easy integration for CloudFormation that ease the process of using Elastigroup custom resource, as part of a CloudFormation stack.

Elastigroup is the equivalent product to Amazon AutoScaling Groups, and therefore it is recommended to replace your AWS::AutoScaling::AutoScalingGroupAWS::AutoScaling::LaunchConfiguration and AWS::AutoScaling::ScalingPolicy with a new resource called "Custom::elasticgroup"

High Level Overview


Step by Step

1. Generate A Personal Access token from Spotinst

Generating a Personal access token from your Spotinst account. Go to Settings -> Personal Access Tokens -> Generate

Once you have the Personal Access Token, save it – we should use it later on in the CloudFormation template.

2. Create an Elastigroup

Create a Spotinst Elasticgroup custom resource with the Personal Access Token and Spotinst’s Lambda ARN.

Spotinst Lambda Function

The Lambda ARN is region dependent, please set the correct region:


example for us-east-1:


In the following example of the CloudFormation template, we create a custom resource "Type": "Custom::elasticgroup"

This resource contains the following elements that need to be covered:

  1. accessToken – Spotinst Access Token that was generated in step #1.
  2. ServiceToken – Spotinst’s Lambda function ARN.
  3. group – Spotinst Elastigroup configuration.
Here is the CloudFormation Template example – adjust it with your own accessToken and group.
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources": {
    "CFCR195GN": {
      "Type": "Custom::elasticgroup",
      "Properties": {
        "ServiceToken": "arn:aws:lambda:us-east-1:178579023202:function:spotinst-cloudformation",                      
        "accessToken": "4378fdd1bb97e9dba31b0b19bd1234123465vr65c6dctdx4e55e35d129837198273981723",  // Your Personal AccessToken
        "group": {
          "name": "Spotinst-CloudFormation",
          "strategy": {
            "risk": 100,
            "availabilityVsCost": "balanced"
          "capacity": {
            "target": 1,
            "minimum": 1,
            "maximum": 1
          "scaling": {},
          "compute": {
            "instanceTypes": {
              "ondemand": "m3.large",
              "spot": [
            "availabilityZones": [
                "name": "us-west-2c",
                "subnetId": "subnet-fa8861a3"
                "name": "us-west-2b",
                "subnetId": "subnet-cw219d2"
            "launchSpecification": {
              "monitoring": false,
              "imageId": "ami-63b25203",
              "keyPair": "my-keypair",
              "securityGroupIds": [
            "product": "Linux/UNIX"
          "scheduling": {},
          "thirdPartiesIntegration": {}
Best Regards,
The Spotinst Team.