A lambda-formation project that will Create, Update and Cancel Spotinst resources for AWS Lambda and CloudFormation.
$ # 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
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
username - Spotinst Username
password - Spotinst Password
clientId - Client ID for Spotinst Account
clientSecret - Client Secret for Spotinst Account
accessCode - Short term access code retrieved using Spotinst token
service or Personal Access
Token
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 forelasticgroupcreate|update, not used for delete -
subscription
object- Spotinst group definition. Required forsubscriptioncreate|update, not used for delete -
id
string- required for update|delete
Set the resource Type to Custom::elasticgroup or Custom::subscription
{
"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": {}
}
}
{
"accessToken": TOKEN
"requestType": "delete",
"resourceType": "elasticgroup",
"id": ELASTICGROUP_ID
}
{
"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": {}
}
}
}
}
}