Skip to content

Commit

Permalink
feat(aws-ec2): AmazonLinuxImage supports AL2 (#1081)
Browse files Browse the repository at this point in the history
Add support for Amazon Linux 2 to AmazonLinuxImage, by supplying a
new `generation: AmazonLinuxGeneration.AmazonLinux2` parameter.

Fixes #1062.
  • Loading branch information
rix0rrr committed Nov 6, 2018
1 parent 8a0b693 commit 97b57a5
Show file tree
Hide file tree
Showing 9 changed files with 563 additions and 27 deletions.
12 changes: 12 additions & 0 deletions docs/pack-docs.sh
@@ -0,0 +1,12 @@
#!/bin/bash
# Development script to build all docs packages and rsync them into $root/dist so that build-docs.sh can work.
set -euo pipefail
cd ..

dist=$(pwd)/dist
pacmak=$(pwd)/tools/cdk-build-tools/node_modules/.bin/jsii-pacmak
scopes=$(lerna ls 2>/dev/null | grep -v "(private)" | cut -d" " -f1 | xargs -n1 -I{} echo "--scope {}" | tr "\n" " ")

mkdir -p $dist
node_modules/.bin/lerna exec --no-bail ${scopes} -- $pacmak -t sphinx -o dist/sphinx || echo 'Swallowing error'
node_modules/.bin/lerna exec --no-bail ${scopes} -- rsync -av dist/ $dist/ || echo 'Swallowing error'
32 changes: 12 additions & 20 deletions packages/@aws-cdk/aws-autoscaling/README.md
Expand Up @@ -23,32 +23,24 @@ new autoscaling.AutoScalingGroup(stack, 'ASG', {
> 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
### Machine Images (AMIs)

AMIs control the OS that gets launched when you start your instance.
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 Windows images are regionally published under labels,
so you can select Windows images like this:
The latest version of Amazon Linux and Microsoft Windows images are
selectable by instantiating one of these classes:

new ec2.WindowsImage(WindowsVersion.WindowsServer2016EnglishNanoBase)
[example of creating images](test/example.images.lit.ts)

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.
> 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

Expand Down
28 changes: 28 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/test/example.images.lit.ts
@@ -0,0 +1,28 @@
import ec2 = require("@aws-cdk/aws-ec2");

/// !show
// Pick a Windows edition to use
const windows = new ec2.WindowsImage(ec2.WindowsVersion.WindowsServer2016EnglishNanoBase);

// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
const amznLinux = new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AmazonLinux,
edition: ec2.AmazonLinuxEdition.Standard,
virtualization: ec2.AmazonLinuxVirt.HVM,
storage: ec2.AmazonLinuxStorage.GeneralPurpose,
});

// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:

const linux = new ec2.GenericLinuxImage({
'us-east-1': 'ami-97785bed',
'eu-west-1': 'ami-12345678',
// ...
});
/// !hide

Array.isArray(windows);
Array.isArray(amznLinux);
Array.isArray(linux);

0 comments on commit 97b57a5

Please sign in to comment.