GithubHelp home page GithubHelp logo

isabella232 / spotinst-lambda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spotinst/spotinst-lambda

0.0 0.0 0.0 482 KB

AWS Lambda functions to Create, Update and Cancel Spotinst resources

License: Apache License 2.0

Shell 1.59% JavaScript 98.41%

spotinst-lambda's Introduction

spotinst-lambda

A lambda-formation project that will Create, Update and Cancel Spotinst resources for AWS Lambda and CloudFormation.

To view full documentation

Build Status Coverage Status Dependency Status

Quick Start

$ # Install only dependencies (no devDependencies)
$ npm --production install
$
$ # create the distribution
$ npm run dist
$
$ # Now upload dist/spotinst-lambda.zip to AWS Lambda, S3 or include in CloudFormation

AWS Lambda

parameters

Credentials

Use either User Credentials parameters or accessCode. If both are provided then User Credentials take precedence.

While multiple forms of credentials are supported it is highly recommended to use a Personal Access Token

User Credentials

username - Spotinst Username

password - Spotinst Password

clientId - Client ID for Spotinst Account

clientSecret - Client Secret for Spotinst Account

Temp Credentials / Personal Access Token

accessCode - Short term access code retrieved using Spotinst token service or Personal Access Token

handler

index/handler

Params

In addition to one of the credential parameter groups:

  • resourceType required string - elasticgroup|subscription

  • requestType required string - create|update|delete

  • group object - Spotinst group definition. Required for elasticgroup create|update, not used for delete

  • subscription object - Spotinst group definition. Required for subscription create|update, not used for delete

  • id string - required for update|delete

CloudFormation

Set the resource Type to Custom::elasticgroup or Custom::subscription

Examples

Lambda - create elasticgroup

{
  "accessToken": TOKEN
  "requestType": "create",
  "resourceType": "elasticgroup",
  "group": {
    "name": "test",
    "strategy": {
      "risk": 100,
      "onDemandCount": null,
      "availabilityVsCost": "balanced"
    },
    "capacity": {
      "target": 1,
      "minimum": 1,
      "maximum": 1
    },
    "scaling": {},
    "compute": {
      "instanceTypes": {
        "ondemand": "m3.medium",
        "spot": [
          "m3.medium"
        ]
      },
      "availabilityZones": [
        {
          "name": "us-east-1a",
          "subnetId": SUBNET_ID
        }
      ],
      "launchSpecification": {
        "monitoring": false,
        "imageId": "ami-60b6c60a",
        "keyPair": "kevinkey",
        "securityGroupIds": [
          SECURITY_GROUP_ID
        ]
      },
      "product": "Linux/UNIX"
    },
    "scheduling": {},
    "thirdPartiesIntegration": {}
  }
}

Ocean

Resources: 
  SpotinstOcean: 
    Type: "Custom::ocean"
    Properties: 
      accessToken: !Ref SpotinstToken
      accountId: !Ref SpotinstAccountId
      autoTag: true
      ocean:
        name: !Ref OceanName
        controllerClusterId: !Ref ControllerClusterId
        region: !Sub ${AWS::Region}
        autoScaler:
          isEnabled: true
          cooldown: 180
          resourceLimits:
            maxMemoryGib: 1500
            maxVCpu: 750
          down:
            evaluationPeriods: 3
          headroom:
            cpuPerUnit: 2000
            memoryPerUnit: 0
            numOfUnits: 4
          isAutoConfig: false
        capacity:
          minimum: 0
          maximum: 1
          target: 1
        strategy:
          spotPercentage: 100
          fallbackToOd: true
          utilizeReservedInstances: false
        compute:
          subnetIds:
            - ""
          instanceTypes:
            whitelist:
              - "c4.8xlarge"
            # blacklist:
            #   - "c4.8xlarge"
          launchSpecification:
            imageId: ""
            # userData: "12345678987654321"
            securityGroupIds:
              - ""
            # iamInstanceProfile:
            #   arn: ""
            keyPair: ""
            tags:
              - tagKey: "creator"
                tagValue: "testing"

MrScaler

  "Resources": {
    "SpotinstEMR": {
      "Type": "Custom::mrScaler",
      "Properties": {
        "ServiceToken": "arn:aws:lambda:us-west-2:842422002533:function:spotinst-cloudformation",
        "accessToken": "Your Token",
        "accountId": "Your Account ID",
        "autoTag":true,
        "mrScaler":{
          "name":"Jeffrey New MRScaler",
          "description":"Spotinst MRScaler",
          "region":"us-west-2",
          "strategy":{
             "new":{
              "releaseLabel":"emr-5.17.0",
              "numberOfRetries":1
             },
             "provisioningTimeout":{
                "timeout":15,
                "timeoutAction":"terminateAndRetry"
             }
          },
          "compute":{
             "availabilityZones":[
                {
                   "name":"us-west-2b",
                   "subnetId":"subnet-1ba25052"
                }
             ],
             "instanceGroups":{
                "masterGroup":{
                   "instanceTypes":[
                      "m3.xlarge"
                   ],
                   "target":1,
                   "lifeCycle":"ON_DEMAND"
                },
                "coreGroup":{
                   "instanceTypes":[
                      "m3.xlarge"
                   ],
                   "target":1,
                   "lifeCycle":"SPOT"
                },
                "taskGroup":{
                   "instanceTypes":[
                      "m1.medium"
                   ],
                   "capacity":{
                      "minimum":0,
                      "maximum":30,
                      "target":1
                   },
                   "lifeCycle":"SPOT"
                }
             },
             "emrManagedMasterSecurityGroup":"sg-8cfb40f6",
             "emrManagedSlaveSecurityGroup":"sg-f2f94288",
             "additionalMasterSecurityGroups":["sg-f2f94288"],
             "additionalSlaveSecurityGroups":["sg-8cfb40f6"],
             "ec2KeyName":"Noam-key",
             "applications":[
                {
                  "name":"Ganglia",
                  "version": "1.0"
                },
                {"name":"Hadoop"},
                {"name":"Hive"},
                {"name":"Hue"},
                {"name":"Mahout"},
                {"name":"Pig"},
                {"name":"Tez"}
              ]
          },
          "cluster":{
             "visibleToAllUsers":true,
             "terminationProtected":true,
             "keepJobFlowAliveWhenNoSteps": true,
             "logUri":"s3://sorex-job-status",
             "additionalInfo":"{'test':'more information'}",
             "jobFlowRole": "EMR_EC2_DefaultRole",
             "securityConfiguration":"test-config-jeffrey"
          }
        }
      }
    },
  }

spotinst-lambda's People

Contributors

aharont avatar dorspot avatar guybrat avatar kmcgrath avatar liranp avatar mv32 avatar nadavnaor avatar shxkm avatar snir102002 avatar spotnir avatar talzur avatar zachinachshon avatar zivmessing avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.