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
.
Sample
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import cdk_ec2spot as ec2spot
# create a ec2spot provider
provider = ec2spot.Provider(stack, "Provider")
# import or create a vpc
vpc = provider.get_or_create_vpc(stack)
# create an AutoScalingGroup with Launch Template for spot instances
provider.create_auto_scaling_group("SpotASG",
vpc=vpc,
default_capacity_size=2,
instance_type=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 without compilation. See https://github.com/aws/jsii/issues/826
provider.create_fleet("SpotFleet",
vpc=vpc,
default_capacity_size=2,
instance_type=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 without compilation. See https://github.com/aws/jsii/issues/826
provider.create_instance("SpotInstance", vpc=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-0.0.40.tar.gz
(3.7 MB
view hashes)
Built Distribution
Close
Hashes for cdk_ec2spot-0.0.40-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3558b0a40a280153a3a03deb4dc08201a86c3dc4b8a6c3e1ae32e42632717965 |
|
MD5 | 3a10ce5617935f44e393973974a8858f |
|
BLAKE2b-256 | d6f73c19edf6af4241e1e9a9e61da3bce7838e48b64cf96f31801429aa743cfb |