The CDK Construct Library for AWS Auto-Scaling
This module is part of the AWS Cloud Development Kit project.
Fleet
Auto Scaling Group
An AutoScalingGroup
represents a number of instances on which you run your code. You
pick the size of the fleet, the instance type and the OS image:
import autoscaling = require('@aws-cdk/aws-autoscaling');
import ec2 = require('@aws-cdk/aws-ec2');
new autoscaling.AutoScalingGroup(stack, 'ASG', {
vpc,
instanceType: new ec2.InstanceTypePair(InstanceClass.Burstable2, InstanceSize.Micro),
machineImage: new ec2.AmazonLinuxImage()
});
NOTE: AutoScalingGroup has an property called allowAllOutbound
(allowing the instances to contact the
internet) which is set to true
by default. Be sure to set this to false
if you don't want
your instances to be able to start arbitrary connections.
Machine Images (AMIs)
AMIs control the OS that gets launched when you start your EC2 instance. The EC2
library contains constructs to select the AMI you want to use.
Depending on the type of AMI, you select it a different way.
The latest version of Amazon Linux and Microsoft Windows images are
selectable by instantiating one of these classes:
example of creating images
NOTE: The Amazon Linux images selected will be cached in your cdk.json
, so that your
AutoScalingGroups don't automatically change out from under you when you're making unrelated
changes. To update to the latest version of Amazon Linux, remove the cache entry from the context
section of your cdk.json
.
We will add command-line options to make this step easier in the future.
Allowing Connections
See the documentation of the aws-ec2 package for more information about allowing
connections between resources backed by instances.
0.15.0 (2018-11-06)
Bug Fixes
- aws-autoscaling: allow minSize to be set to 0 (#1015) (67f7fa1)
- aws-codebuild: correctly pass the timeout property to CFN when creating a Project. (#1071) (b1322bb)
- aws-codebuild: correctly set S3 path when using it as artifact. (#1072) (f32cba9)
- aws-kms: add output value when exporting an encryption key (#1036) (cb490be)
- Switch from
js-yaml
to yaml
(#1092) (0b132b5)
Features
- don't upload the same asset multiple times (#1011) (35937b6), closes #989
- app-delivery: CI/CD for CDK Stacks (#1022) (f2fe4e9)
- add a new construct library for ECS (#1058) (ae03ddb)
- applets: integrate into toolkit (#1039) (fdabe95), closes #849 #342 #291
- aws-codecommit: use CloudWatch Events instead of polling by default in the CodePipeline Action. (#1026) (d09d30c)
- aws-dynamodb: allow specifying partition/sort keys in props (#1054) (ec87331), closes #1051
- aws-ec2: AmazonLinuxImage supports AL2 (#1081) (97b57a5), closes #1062
- aws-lambda: high level API for event sources (#1063) (1be3442)
- aws-sqs: improvements to IAM grants API (#1052) (6f2475e)
- codepipeline/cfn: Use fewer statements for pipeline permissions (#1009) (8f4c2ab)
- pkglint: Make sure .snk files are ignored (#1049) (53c8d76), closes #643
- toolkit: deployment ui improvements (#1067) (c832eaf)
- Update to CloudFormation resource specification v2.11.0
BREAKING CHANGES TO EXPERIMENTAL FEATURES
- The ec2.Connections object has been changed to be able to manage multiple security groups. The relevant property has been changed from
securityGroup
to securityGroups
(an array of security group objects). - aws-codecommit: this modifies the default behavior of the CodeCommit Action. It also changes the internal API contract between the aws-codepipeline-api module and the CodePipeline Actions in the service packages.
- applets: The applet schema has changed to allow Multiple applets can be define in one file by structuring the files like this:
- applets: The applet schema has changed to allow definition of multiple applets in the same file.
The schema now looks like this:
applets:
MyApplet:
type: ./my-applet-file
properties:
property1: value
...
By starting an applet specifier with npm://, applet modules can directly be referenced in NPM. You can include a version specifier (@1.2.3) to reference specific versions.
- aws-sqs:
queue.grantReceiveMessages
has been removed. It is unlikely that this would be sufficient to interact with a queue. Alternatively you can use queue.grantConsumeMessages
or queue.grant('sqs:ReceiveMessage')
if there's a need to only grant this action.