-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING(aws-ec2): move AutoScalingGroup (#608)
This construct should have been in the @aws-cdk/aws-autoscaling package, as that is the CloudFormation namespace name. This will also help avoid a dependency cycle pending in another PR, where we want to add a dependency from aws-lambda => aws-ec2.
- Loading branch information
Showing
18 changed files
with
188 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
examples/cdk-examples-typescript/use-vpc-from-another-stack/cdk.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"app": "node index", | ||
"context": { | ||
"availability-zones:993655754359:us-east-1": [ | ||
"us-east-1a", | ||
"us-east-1b", | ||
"us-east-1c", | ||
"us-east-1d", | ||
"us-east-1e", | ||
"us-east-1f" | ||
], | ||
"availability-zones:585695036304:us-east-1": [ | ||
"us-east-1a", | ||
"us-east-1b", | ||
"us-east-1c", | ||
"us-east-1d", | ||
"us-east-1e", | ||
"us-east-1f" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,57 @@ | ||
## The CDK Construct Library for AWS Auto-Scaling | ||
This module is part of the [AWS Cloud Development Kit](https://github.com/awslabs/aws-cdk) 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: | ||
|
||
```ts | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
|
||
new ec2.AutoScalingGroup(stack, 'ASG', { | ||
vpc, | ||
instanceType: new ec2.InstanceTypePair(InstanceClass.Burstable2, InstanceSize.Micro), | ||
machineImage: new ec2.LinuxImage({ | ||
'us-east-1': 'ami-97785bed' | ||
}) | ||
}); | ||
``` | ||
|
||
> 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. | ||
### AMIs | ||
|
||
AMIs control the OS that gets launched when you start your instance. | ||
|
||
Depending on the type of AMI, you select it a different way. | ||
|
||
The latest version of Windows images are regionally published under labels, | ||
so you can select Windows images like this: | ||
|
||
new ec2.WindowsImage(WindowsVersion.WindowsServer2016EnglishNanoBase) | ||
|
||
You can select the latest Amazon Linux image like this: | ||
|
||
new ec2.AmazonLinuxImage() | ||
|
||
Other Linux images are unfortunately not currently published this way, so you have | ||
to supply a region-to-AMI map when creating a Linux image: | ||
|
||
machineImage: new ec2.GenericLinuxImage({ | ||
'us-east-1': 'ami-97785bed', | ||
'eu-west-1': 'ami-12345678', | ||
// ... | ||
}) | ||
|
||
> NOTE: Selecting Linux images will change when the information is published in an automatically | ||
> consumable way. | ||
### Allowing Connections | ||
|
||
See the documentation of the aws-ec2 package for more information about allowing | ||
connections between resources backed by instances. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './auto-scaling-group'; | ||
|
||
// AWS::AutoScaling CloudFormation Resources: | ||
export * from './autoscaling.generated'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-loadbalancer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import autoscaling = require('../lib'); | ||
|
||
const app = new cdk.App(process.argv); | ||
const stack = new cdk.Stack(app, 'aws-cdk-ec2-integ'); | ||
|
||
const vpc = new ec2.VpcNetwork(stack, 'VPC', { | ||
maxAZs: 3 | ||
}); | ||
|
||
const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', { | ||
vpc, | ||
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.Burstable2, ec2.InstanceSize.Micro), | ||
machineImage: new ec2.AmazonLinuxImage(), | ||
}); | ||
|
||
new ec2.ClassicLoadBalancer(stack, 'LB', { | ||
vpc, | ||
internetFacing: true, | ||
listeners: [{ | ||
externalPort: 80, | ||
allowConnectionsFrom: [new ec2.AnyIPv4()] | ||
}], | ||
healthCheck: { | ||
port: 80 | ||
}, | ||
targets: [asg] | ||
}); | ||
|
||
process.stdout.write(app.run()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.