Skip to content

Commit da4352d

Browse files
authored
Merge branch 'master' into userpool-ses
2 parents 70807f7 + eed70a0 commit da4352d

19 files changed

+308
-75
lines changed

packages/@aws-cdk/aws-ec2/lib/instance-types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,16 @@ export enum InstanceClass {
466466
*/
467467
G4DN = 'g4dn',
468468

469+
/**
470+
* Graphics-optimized instances, 5th generation
471+
*/
472+
GRAPHICS5 = 'g5',
473+
474+
/**
475+
* Graphics-optimized instances, 5th generation
476+
*/
477+
G5 = 'g5',
478+
469479
/**
470480
* Parallel-processing optimized instances, 2nd generation
471481
*/
@@ -666,6 +676,11 @@ export enum InstanceSize {
666676
*/
667677
XLARGE32 = '32xlarge',
668678

679+
/**
680+
* Instance size XLARGE48 (48xlarge)
681+
*/
682+
XLARGE48 = '48xlarge',
683+
669684
/**
670685
* Instance size METAL (metal)
671686
*/

packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
33
import * as ecr from '@aws-cdk/aws-ecr';
4-
import { Annotations, AssetStaging, FeatureFlags, FileFingerprintOptions, IgnoreMode, Stack, SymlinkFollowMode, Token, Stage } from '@aws-cdk/core';
4+
import { Annotations, AssetStaging, FeatureFlags, FileFingerprintOptions, IgnoreMode, Stack, SymlinkFollowMode, Token, Stage, CfnResource } from '@aws-cdk/core';
55
import * as cxapi from '@aws-cdk/cx-api';
66
import { Construct } from 'constructs';
77

@@ -147,6 +147,30 @@ export class DockerImageAsset extends CoreConstruct implements IAsset {
147147
*/
148148
public readonly assetHash: string;
149149

150+
/**
151+
* The path to the asset, relative to the current Cloud Assembly
152+
*
153+
* If asset staging is disabled, this will just be the original path.
154+
*
155+
* If asset staging is enabled it will be the staged path.
156+
*/
157+
private readonly assetPath: string;
158+
159+
/**
160+
* The path to the Dockerfile, relative to the assetPath
161+
*/
162+
private readonly dockerfilePath?: string;
163+
164+
/**
165+
* Build args to pass to the `docker build` command.
166+
*/
167+
private readonly dockerBuildArgs?: { [key: string]: string };
168+
169+
/**
170+
* Docker target to build to
171+
*/
172+
private readonly dockerBuildTarget?: string;
173+
150174
constructor(scope: Construct, id: string, props: DockerImageAssetProps) {
151175
super(scope, id);
152176

@@ -160,7 +184,8 @@ export class DockerImageAsset extends CoreConstruct implements IAsset {
160184
}
161185

162186
// validate the docker file exists
163-
const file = path.join(dir, props.file || 'Dockerfile');
187+
this.dockerfilePath = props.file || 'Dockerfile';
188+
const file = path.join(dir, this.dockerfilePath);
164189
if (!fs.existsSync(file)) {
165190
throw new Error(`Cannot find file at ${file}`);
166191
}
@@ -223,17 +248,53 @@ export class DockerImageAsset extends CoreConstruct implements IAsset {
223248
this.assetHash = staging.assetHash;
224249

225250
const stack = Stack.of(this);
251+
this.assetPath = staging.relativeStagedPath(stack);
252+
this.dockerBuildArgs = props.buildArgs;
253+
this.dockerBuildTarget = props.target;
254+
226255
const location = stack.synthesizer.addDockerImageAsset({
227-
directoryName: staging.relativeStagedPath(stack),
228-
dockerBuildArgs: props.buildArgs,
229-
dockerBuildTarget: props.target,
256+
directoryName: this.assetPath,
257+
dockerBuildArgs: this.dockerBuildArgs,
258+
dockerBuildTarget: this.dockerBuildTarget,
230259
dockerFile: props.file,
231260
sourceHash: staging.assetHash,
232261
});
233262

234263
this.repository = ecr.Repository.fromRepositoryName(this, 'Repository', location.repositoryName);
235264
this.imageUri = location.imageUri;
236265
}
266+
267+
/**
268+
* Adds CloudFormation template metadata to the specified resource with
269+
* information that indicates which resource property is mapped to this local
270+
* asset. This can be used by tools such as SAM CLI to provide local
271+
* experience such as local invocation and debugging of Lambda functions.
272+
*
273+
* Asset metadata will only be included if the stack is synthesized with the
274+
* "aws:cdk:enable-asset-metadata" context key defined, which is the default
275+
* behavior when synthesizing via the CDK Toolkit.
276+
*
277+
* @see https://github.com/aws/aws-cdk/issues/1432
278+
*
279+
* @param resource The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface]
280+
* @param resourceProperty The property name where this asset is referenced
281+
*/
282+
public addResourceMetadata(resource: CfnResource, resourceProperty: string) {
283+
if (!this.node.tryGetContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT)) {
284+
return; // not enabled
285+
}
286+
287+
// tell tools such as SAM CLI that the resourceProperty of this resource
288+
// points to a local path and include the path to de dockerfile, docker build args, and target,
289+
// in order to enable local invocation of this function.
290+
resource.cfnOptions.metadata = resource.cfnOptions.metadata || { };
291+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY] = this.assetPath;
292+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_DOCKERFILE_PATH_KEY] = this.dockerfilePath;
293+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_ARGS_KEY] = this.dockerBuildArgs;
294+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_TARGET_KEY] = this.dockerBuildTarget;
295+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY] = resourceProperty;
296+
}
297+
237298
}
238299

239300
function validateProps(props: DockerImageAssetProps) {

packages/@aws-cdk/aws-iot-actions/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ import * as s3 from '@aws-cdk/aws-s3';
136136
import * as firehose from '@aws-cdk/aws-kinesisfirehose';
137137
import * as destinations from '@aws-cdk/aws-kinesisfirehose-destinations';
138138

139-
const bucket = new s3.Bucket(this, 'MyBucket', {
140-
removalPolicy: cdk.RemovalPolicy.DESTROY,
141-
});
139+
const bucket = new s3.Bucket(this, 'MyBucket');
142140
const stream = new firehose.DeliveryStream(this, 'MyStream', {
143141
destinations: [new destinations.S3Bucket(bucket)],
144142
});
@@ -149,7 +147,7 @@ const topicRule = new iot.TopicRule(this, 'TopicRule', {
149147
new actions.FirehoseStreamAction(stream, {
150148
batchMode: true,
151149
recordSeparator: actions.FirehoseStreamRecordSeparator.NEWLINE,
152-
})
150+
}),
153151
],
154152
});
155153
```

packages/@aws-cdk/aws-iot-actions/lib/firehose-stream-action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export enum FirehoseStreamRecordSeparator {
3232
/**
3333
* Configuration properties of an action for the Kinesis Data Firehose stream.
3434
*/
35-
export interface FirehoseStreamProps extends CommonActionProps {
35+
export interface FirehoseStreamActionProps extends CommonActionProps {
3636
/**
3737
* Whether to deliver the Kinesis Data Firehose stream as a batch by using `PutRecordBatch`.
3838
* When batchMode is true and the rule's SQL statement evaluates to an Array, each Array
@@ -64,7 +64,7 @@ export class FirehoseStreamAction implements iot.IAction {
6464
* @param stream The Kinesis Data Firehose stream to which to put records.
6565
* @param props Optional properties to not use default
6666
*/
67-
constructor(private readonly stream: firehose.IDeliveryStream, props: FirehoseStreamProps = {}) {
67+
constructor(private readonly stream: firehose.IDeliveryStream, props: FirehoseStreamActionProps = {}) {
6868
this.batchMode = props.batchMode;
6969
this.recordSeparator = props.recordSeparator;
7070
this.role = props.role;

0 commit comments

Comments
 (0)