spotinst-lambda
v0.4.2
Published
AWS Lambda scripts to interface with Spotinst
Downloads
4
Readme
spotinst-lambda
A lambda-formation project that will Create, Update and Cancel Spotinst resources for AWS Lambda and CloudFormation.
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|subscriptionrequestType required
string
- create|update|deletegroup
object
- Spotinst group definition. Required forelasticgroup
create|update, not used for deletesubscription
object
- Spotinst group definition. Required forsubscription
create|update, not used for deleteid
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": {}
}
}
Lambda - delete elasticgroup
{
"accessToken": TOKEN
"requestType": "delete",
"resourceType": "elasticgroup",
"id": ELASTICGROUP_ID
}
CloudFormation
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"CFCR195GN": {
"Type": "Custom::elasticgroup",
"Properties": {
"ServiceToken": SERVICE_TOKEN,
"accessToken": TOKEN,
"group": {
"name": "test",
"strategy": {
"risk": 100,
"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": "testkey",
"securityGroupIds": [
SECURITY_GROUP_ID
]
},
"product": "Linux/UNIX"
},
"scheduling": {},
"thirdPartiesIntegration": {}
}
}
}
}
}