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.

CloudFormation

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, Spot by NetApp is happy to release an easy integration for CloudFormation that eases the process of using our flagship product Elastigroup’s custom resource, as part of a CloudFormation stack.

Elastigroup is the equivalent product to Amazon AutoScaling Groups but comes with many advanced features and capabilities for cloud infrastructure automation and optimization. Therefore we recommend that you replace your AWS::AutoScaling::AutoScalingGroup, AWS::AutoScaling::LaunchConfiguration and AWS::AutoScaling::ScalingPolicy with a new resource called "Custom::elasticgroup"

High Level Overview

Spotinst_CloudFormation

Step by Step

1. Generate A Personal Access token from Spot

Generating a Personal access token from your Spot 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 Spot Elasticgroup custom resource with the Personal Access Token and Spot’s Lambda ARN.

Spot Lambda Function

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

arn:aws:lambda:<REGION>:178579023202:function:spotinst-cloudformation

example for us-east-1:

arn:aws:lambda:us-east-1:178579023202:function:spotinst-cloudformation

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 – Spot Access Token that was generated in step #1.
  2. ServiceToken – Spot’s Lambda function ARN.
  3. group – Spot 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": [
                "m3.large",
                "m4.large",
                "c3.large",
                "c4.large"
                ]
            },
            "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": [
                "sg-dd68abba"
                ]
            },
            "product": "Linux/UNIX"
          },
          "scheduling": {},
          "thirdPartiesIntegration": {}
        }
      }
    }
  }
}
Enjoy!