CDK construct library for EC2 Spot
Project description
cdk-ec2spot
CDK construct library that allows you to create EC2 Spot instances with AWS AutoScaling Group
, Spot Fleet
or just single Spot Instance
.
Install
Use the npm dist tag to opt in CDKv1 or CDKv2:
// for CDKv2
npm install cdk-ec2spot
or
npm install cdk-ec2spot@latest
// for CDKv1
npm install cdk-ec2spot@cdkv1
Sample
import * as ec2spot from 'cdk-ec2spot';
// create a ec2spot provider
const provider = new ec2spot.Provider(stack, 'Provider');
// import or create a vpc
const vpc = provider.getOrCreateVpc(stack);
// create an AutoScalingGroup with Launch Template for spot instances
provider.createAutoScalingGroup('SpotASG', {
vpc,
defaultCapacitySize: 2,
instanceType: new ec2.InstanceType('m5.large'),
});
EC2 Spot Fleet support
In addition to EC2 AutoScaling Group, you may use createFleet()
to create an EC2 Spot Fleet:
provider.createFleet('SpotFleet', {
vpc,
defaultCapacitySize: 2,
instanceType: new ec2.InstanceType('t3.large'),
});
Single Spot Instnce
If you just need single spot instance without any autoscaling group or spot fleet, use createInstance()
:
provider.createInstance('SpotInstance', { vpc })
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cdk-ec2spot-2.0.283.tar.gz
(41.3 kB
view hashes)
Built Distribution
Close
Hashes for cdk_ec2spot-2.0.283-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa505699fa0e2d1d11fe023cedd3ffc71dd8145d48bd9d256a2e2872274ba8f |
|
MD5 | 8f38b37f264e4de2af46b60c6270c00f |
|
BLAKE2b-256 | 60ef47966d9a7d3d3400b1e6bfbf0c9b35c208a8e6a1be455a1ab22aaa49de5f |