Skip to content

Commit 97b57a5

Browse files
authored
feat(aws-ec2): AmazonLinuxImage supports AL2 (#1081)
Add support for Amazon Linux 2 to AmazonLinuxImage, by supplying a new `generation: AmazonLinuxGeneration.AmazonLinux2` parameter. Fixes #1062.
1 parent 8a0b693 commit 97b57a5

File tree

9 files changed

+563
-27
lines changed

9 files changed

+563
-27
lines changed

docs/pack-docs.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Development script to build all docs packages and rsync them into $root/dist so that build-docs.sh can work.
3+
set -euo pipefail
4+
cd ..
5+
6+
dist=$(pwd)/dist
7+
pacmak=$(pwd)/tools/cdk-build-tools/node_modules/.bin/jsii-pacmak
8+
scopes=$(lerna ls 2>/dev/null | grep -v "(private)" | cut -d" " -f1 | xargs -n1 -I{} echo "--scope {}" | tr "\n" " ")
9+
10+
mkdir -p $dist
11+
node_modules/.bin/lerna exec --no-bail ${scopes} -- $pacmak -t sphinx -o dist/sphinx || echo 'Swallowing error'
12+
node_modules/.bin/lerna exec --no-bail ${scopes} -- rsync -av dist/ $dist/ || echo 'Swallowing error'

packages/@aws-cdk/aws-autoscaling/README.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,24 @@ new autoscaling.AutoScalingGroup(stack, 'ASG', {
2323
> internet) which is set to `true` by default. Be sure to set this to `false` if you don't want
2424
> your instances to be able to start arbitrary connections.
2525
26-
### AMIs
26+
### Machine Images (AMIs)
2727

28-
AMIs control the OS that gets launched when you start your instance.
28+
AMIs control the OS that gets launched when you start your EC2 instance. The EC2
29+
library contains constructs to select the AMI you want to use.
2930

3031
Depending on the type of AMI, you select it a different way.
3132

32-
The latest version of Windows images are regionally published under labels,
33-
so you can select Windows images like this:
33+
The latest version of Amazon Linux and Microsoft Windows images are
34+
selectable by instantiating one of these classes:
3435

35-
new ec2.WindowsImage(WindowsVersion.WindowsServer2016EnglishNanoBase)
36+
[example of creating images](test/example.images.lit.ts)
3637

37-
You can select the latest Amazon Linux image like this:
38-
39-
new ec2.AmazonLinuxImage()
40-
41-
Other Linux images are unfortunately not currently published this way, so you have
42-
to supply a region-to-AMI map when creating a Linux image:
43-
44-
machineImage: new ec2.GenericLinuxImage({
45-
'us-east-1': 'ami-97785bed',
46-
'eu-west-1': 'ami-12345678',
47-
// ...
48-
})
49-
50-
> NOTE: Selecting Linux images will change when the information is published in an automatically
51-
> consumable way.
38+
> NOTE: The Amazon Linux images selected will be cached in your `cdk.json`, so that your
39+
> AutoScalingGroups don't automatically change out from under you when you're making unrelated
40+
> changes. To update to the latest version of Amazon Linux, remove the cache entry from the `context`
41+
> section of your `cdk.json`.
42+
>
43+
> We will add command-line options to make this step easier in the future.
5244
5345
### Allowing Connections
5446

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import ec2 = require("@aws-cdk/aws-ec2");
2+
3+
/// !show
4+
// Pick a Windows edition to use
5+
const windows = new ec2.WindowsImage(ec2.WindowsVersion.WindowsServer2016EnglishNanoBase);
6+
7+
// Pick the right Amazon Linux edition. All arguments shown are optional
8+
// and will default to these values when omitted.
9+
const amznLinux = new ec2.AmazonLinuxImage({
10+
generation: ec2.AmazonLinuxGeneration.AmazonLinux,
11+
edition: ec2.AmazonLinuxEdition.Standard,
12+
virtualization: ec2.AmazonLinuxVirt.HVM,
13+
storage: ec2.AmazonLinuxStorage.GeneralPurpose,
14+
});
15+
16+
// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
17+
// a map giving the AMI to in for each region:
18+
19+
const linux = new ec2.GenericLinuxImage({
20+
'us-east-1': 'ami-97785bed',
21+
'eu-west-1': 'ami-12345678',
22+
// ...
23+
});
24+
/// !hide
25+
26+
Array.isArray(windows);
27+
Array.isArray(amznLinux);
28+
Array.isArray(linux);

0 commit comments

Comments
 (0)