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
# Example automatically generated from non-compiling source. May contain errors.
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:
# Example automatically generated from non-compiling source. May contain errors.
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()
:
# Example automatically generated from non-compiling source. May contain errors.
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.2.tar.gz
(39.1 kB
view hashes)
Built Distribution
Close
Hashes for cdk_ec2spot-2.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f4ba354dc0f00e3f72a1c0049925fc11c17280adb5d98c7e8e09a2b61bb55a4 |
|
MD5 | b414e68aa93326e4f42c847400a7f4e0 |
|
BLAKE2b-256 | ad1a8d4852d49610895c0a4ac001a0fb32bcf3a1950fc20b0f912edd45be0d06 |