Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Feb 5, 2021
2 parents f682747 + 32c0de7 commit fee2e4d
Show file tree
Hide file tree
Showing 7 changed files with 1,419 additions and 35 deletions.
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,24 @@ const subnet = Subnet.fromSubnetAttributes(this, 'SubnetFromAttributes', {
// Supply only subnet id
const subnet = Subnet.fromSubnetId(this, 'SubnetFromId', 's-1234');
```

## Launch Templates

A Launch Template is a standardized template that contains the configuration information to launch an instance.
They can be used when launching instances on their own, through Amazon EC2 Auto Scaling, EC2 Fleet, and Spot Fleet.
Launch templates enable you to store launch parameters so that you do not have to specify them every time you launch
an instance. For information on Launch Templates please see the
[official documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html).

The following demonstrates how to create a launch template with an Amazon Machine Image, and security group.

```ts
const vpc = new ec2.Vpc(...);
// ...
const template = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
machineImage: new ec2.AmazonMachineImage(),
securityGroup: new ec2.SecurityGroup(this, 'LaunchTemplateSG', {
vpc: vpc,
}),
});
```
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './cfn-init';
export * from './cfn-init-elements';
export * from './instance-types';
export * from './instance';
export * from './launch-template';
export * from './machine-image';
export * from './nat';
export * from './network-acl';
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-ec2/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { Connections, IConnectable } from './connections';
import { CfnInstance } from './ec2.generated';
import { InstanceType } from './instance-types';
import { IMachineImage, OperatingSystemType } from './machine-image';
import { instanceBlockDeviceMappings } from './private/ebs-util';
import { ISecurityGroup, SecurityGroup } from './security-group';
import { UserData } from './user-data';
import { BlockDevice, synthesizeBlockDeviceMappings } from './volume';
import { BlockDevice } from './volume';
import { IVpc, Subnet, SubnetSelection } from './vpc';

/**
Expand Down Expand Up @@ -362,7 +363,7 @@ export class Instance extends Resource implements IInstance {
subnetId: subnet.subnetId,
availabilityZone: subnet.availabilityZone,
sourceDestCheck: props.sourceDestCheck,
blockDeviceMappings: props.blockDevices !== undefined ? synthesizeBlockDeviceMappings(this, props.blockDevices) : undefined,
blockDeviceMappings: props.blockDevices !== undefined ? instanceBlockDeviceMappings(this, props.blockDevices) : undefined,
privateIpAddress: props.privateIpAddress,
});
this.instance.node.addDependency(this.role);
Expand Down
Loading

0 comments on commit fee2e4d

Please sign in to comment.