Skip to content

Commit

Permalink
Merge branch 'aws:main' into asset_support
Browse files Browse the repository at this point in the history
  • Loading branch information
wanjacki authored Dec 15, 2022
2 parents 85b3cd3 + 02d0876 commit 08f4947
Show file tree
Hide file tree
Showing 15 changed files with 516 additions and 34 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.55.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.54.0-alpha.0...v2.55.0-alpha.0) (2022-12-14)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **appsync:** `DataSource.createResolver`,
`DataSource.createFunction`, and `GraphQlApi.createResolver` now require
2 arguments instead of 1.
* **appsync:** Renames `Schema` to `SchemaFile` that implements `ISchema`. Removes all `addXxx` type methods from `GraphQlApi`.

### Features

* **aws-lambda-python:** add command hooks for bundling to allow for execution of custom commands in the build container ([#23330](https://github.com/aws/aws-cdk/issues/23330)) ([d3d071f](https://github.com/aws/aws-cdk/commit/d3d071f51fab61ae0e484f143e68e698bba48537))
* **gamelift:** add GameSessionQueue L2 Construct for GameLift ([#23266](https://github.com/aws/aws-cdk/issues/23266)) ([1ded644](https://github.com/aws/aws-cdk/commit/1ded64430d8258f6666743e245ef5ac31ed4bf0b))


### Bug Fixes

* **appsync:** unexpected resolver replacement ([#23322](https://github.com/aws/aws-cdk/issues/23322)) ([6dc15d4](https://github.com/aws/aws-cdk/commit/6dc15d40764dc71fe6a3b70691f586e96cdcf730)), closes [#13269](https://github.com/aws/aws-cdk/issues/13269)
* **servicecatalogappregistry:** synth error when associating a nested stack ([#23248](https://github.com/aws/aws-cdk/issues/23248)) ([30301d9](https://github.com/aws/aws-cdk/commit/30301d9e5ab4af86c5e48a5ad47013924acdfed7))


### Miscellaneous Chores

* **appsync:** removes codefirst schema generation ([#23250](https://github.com/aws/aws-cdk/issues/23250)) ([2bd1e41](https://github.com/aws/aws-cdk/commit/2bd1e4184aea054766f7872b300b960b2b83ef06))

## [2.54.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.53.0-alpha.0...v2.54.0-alpha.0) (2022-12-07)


Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.55.0](https://github.com/aws/aws-cdk/compare/v2.54.0...v2.55.0) (2022-12-14)


### Features

* **autoscaling:** support default instance warmup for Auto Scaling groups ([#23285](https://github.com/aws/aws-cdk/issues/23285)) ([3f706e2](https://github.com/aws/aws-cdk/commit/3f706e2210fb1ffe2b70e27862a17594c3337800))
* **cfnspec:** cloudformation spec v101.0.0 ([#23294](https://github.com/aws/aws-cdk/issues/23294)) ([3951f09](https://github.com/aws/aws-cdk/commit/3951f09fb370b74936f3fb45e7188ac6c7343b67))
* **cognito:** add new AdvancedSecurityMode property ([#23261](https://github.com/aws/aws-cdk/issues/23261)) ([9cc9bd3](https://github.com/aws/aws-cdk/commit/9cc9bd34a9d67e7e072292e20aeb9e003e55f158))
* **core:** add volumes-from option to docker run command for bundling ([#22829](https://github.com/aws/aws-cdk/issues/22829)) ([813c2f1](https://github.com/aws/aws-cdk/commit/813c2f17b6c0f1056ed43a8a93f4cffbe9ae9736)), closes [#8799](https://github.com/aws/aws-cdk/issues/8799) [#21660](https://github.com/aws/aws-cdk/issues/21660)
* **s3:** update runtime of notifications-handler to python3.9 ([#23209](https://github.com/aws/aws-cdk/issues/23209)) ([b2d293d](https://github.com/aws/aws-cdk/commit/b2d293d3f8d36547d8cfd7ff3957428718c3827f))
* **s3-deployment:** add additional sources with `addSource` ([#23321](https://github.com/aws/aws-cdk/issues/23321)) ([b34d0b7](https://github.com/aws/aws-cdk/commit/b34d0b7b0152dc5edb2f963054c6af273119006e)), closes [#22857](https://github.com/aws/aws-cdk/issues/22857)


### Bug Fixes

* **cloudwatch:** math expressions incorrectly warn about metricsinsights variable names ([#23316](https://github.com/aws/aws-cdk/issues/23316)) ([55108b9](https://github.com/aws/aws-cdk/commit/55108b969a94f671a492b4536d2ad9d13d11cf9d))
* **core:** cross stack references to string lists break ([#22873](https://github.com/aws/aws-cdk/issues/22873)) ([3ddb8cf](https://github.com/aws/aws-cdk/commit/3ddb8cf44f1e7a285b767f4f4540924a728083c4)), closes [/docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html#aws-resource-ec2](https://github.com/aws//docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html/issues/aws-resource-ec2) [#21682](https://github.com/aws/aws-cdk/issues/21682)
* **custom-resources:** inactive lambda functions fail on invoke ([#22612](https://github.com/aws/aws-cdk/issues/22612)) ([def2971](https://github.com/aws/aws-cdk/commit/def2971d91eedbd327d3acec201d902376129f25)), closes [#20123](https://github.com/aws/aws-cdk/issues/20123)
* **ec2:** Invalid security group ID ([#22859](https://github.com/aws/aws-cdk/issues/22859)) ([c2043c8](https://github.com/aws/aws-cdk/commit/c2043c8dfaaa3189f625dd93c94ee9139e5505e6)), closes [aws-cdk/aws-ec2/lib/peer.ts#L224](https://github.com/aws-cdk/aws-ec2/lib/peer.ts/issues/L224)
* **ecr:** grants for cross-account principals result in failed deployments ([#16376](https://github.com/aws/aws-cdk/issues/16376)) ([84e20f8](https://github.com/aws/aws-cdk/commit/84e20f8da37c22639c033f51c89ef608260e7578)), closes [#15070](https://github.com/aws/aws-cdk/issues/15070)
* **opensearch:** Don't throw a Az count mismatch for imported VPCs ([#22654](https://github.com/aws/aws-cdk/issues/22654)) ([6a28b7f](https://github.com/aws/aws-cdk/commit/6a28b7f0aecf0bc9c5876bf4c7df87d69f0af836)), closes [#22651](https://github.com/aws/aws-cdk/issues/22651)


### Reverts

* "chore: save exclusion rules when bumping the CFN spec ([#22788](https://github.com/aws/aws-cdk/issues/22788))" ([#23282](https://github.com/aws/aws-cdk/issues/23282)) ([cc76cfb](https://github.com/aws/aws-cdk/commit/cc76cfb124a59131996d75d05a82b7985c787ae0))

## [2.54.0](https://github.com/aws/aws-cdk/compare/v2.53.0...v2.54.0) (2022-12-07)


Expand Down
15 changes: 15 additions & 0 deletions packages/@aws-cdk/aws-lambda-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,21 @@ new go.GoFunction(this, 'GoFunction', {
});
```

You can set additional Docker options to configure the build environment:

```ts
new go.GoFunction(this, 'GoFunction', {
entry: 'app/cmd/api',
bundling: {
network: 'host',
securityOpt: 'no-new-privileges',
user: 'user:group',
volumesFrom: ['777f7dc92da7'],
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],
},
});
```

## Command hooks

It is possible to run additional commands by specifying the `commandHooks` prop:
Expand Down
23 changes: 22 additions & 1 deletion packages/@aws-cdk/aws-lambda-go/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export class Bundling implements cdk.BundlingOptions {
command: bundling.command,
environment: bundling.environment,
local: bundling.local,
entrypoint: bundling.entrypoint,
volumes: bundling.volumes,
volumesFrom: bundling.volumesFrom,
workingDirectory: bundling.workingDirectory,
user: bundling.user,
securityOpt: bundling.securityOpt,
network: bundling.network,
},
});
}
Expand All @@ -93,6 +100,13 @@ export class Bundling implements cdk.BundlingOptions {
public readonly command: string[];
public readonly environment?: { [key: string]: string };
public readonly local?: cdk.ILocalBundling;
public readonly entrypoint?: string[]
public readonly volumes?: cdk.DockerVolume[];
public readonly volumesFrom?: string[];
public readonly workingDirectory?: string;
public readonly user?: string;
public readonly securityOpt?: string;
public readonly network?: string;

private readonly relativeEntryPath: string;

Expand Down Expand Up @@ -131,8 +145,15 @@ export class Bundling implements cdk.BundlingOptions {
: cdk.DockerImage.fromRegistry('dummy'); // Do not build if we don't need to

const bundlingCommand = this.createBundlingCommand(cdk.AssetStaging.BUNDLING_INPUT_DIR, cdk.AssetStaging.BUNDLING_OUTPUT_DIR);
this.command = ['bash', '-c', bundlingCommand];
this.command = props.command ?? ['bash', '-c', bundlingCommand];
this.environment = environment;
this.entrypoint = props.entrypoint;
this.volumes = props.volumes;
this.volumesFrom = props.volumesFrom;
this.workingDirectory = props.workingDirectory;
this.user = props.user;
this.securityOpt = props.securityOpt;
this.network = props.network;

// Local bundling
if (!props.forcedDockerBundling) { // only if Docker is not forced
Expand Down
11 changes: 2 additions & 9 deletions packages/@aws-cdk/aws-lambda-go/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { AssetHashType, DockerImage } from '@aws-cdk/core';
import { AssetHashType, DockerImage, DockerRunOptions } from '@aws-cdk/core';

/**
* Bundling options
*/
export interface BundlingOptions {
/**
* Environment variables defined when go runs.
*
* @default - no environment variables are defined.
*/
readonly environment?: { [key: string]: string; };

export interface BundlingOptions extends DockerRunOptions {
/**
* Force bundling in a Docker container even if local bundling is
* possible.
Expand Down
126 changes: 126 additions & 0 deletions packages/@aws-cdk/aws-lambda-go/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,129 @@ test('with command hooks', () => {
}),
});
});

test('Custom bundling entrypoint', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
entrypoint: ['/cool/entrypoint', '--cool-entrypoint-arg'],
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
entrypoint: ['/cool/entrypoint', '--cool-entrypoint-arg'],
}),
});
});

test('Custom bundling volumes', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],
}),
});
});

test('Custom bundling volumesFrom', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
volumesFrom: ['777f7dc92da7'],
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
volumesFrom: ['777f7dc92da7'],
}),
});
});

test('Custom bundling workingDirectory', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
workingDirectory: '/working-directory',
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
workingDirectory: '/working-directory',
}),
});
});

test('Custom bundling user', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
user: 'user:group',
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
user: 'user:group',
}),
});
});

test('Custom bundling securityOpt', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
securityOpt: 'no-new-privileges',
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
securityOpt: 'no-new-privileges',
}),
});
});

test('Custom bundling network', () => {
Bundling.bundle({
entry,
moduleDir,
runtime: Runtime.GO_1_X,
architecture: Architecture.X86_64,
forcedDockerBundling: true,
network: 'host',
});

expect(Code.fromAsset).toHaveBeenCalledWith('/project', {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
network: 'host',
}),
});
});
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ should also have `npm`, `yarn` or `pnpm` depending on the lock file you're using
Use the [default image provided by `@aws-cdk/aws-lambda-nodejs`](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-lambda-nodejs/lib/Dockerfile)
as a source of inspiration.

You can set additional Docker options to configure the build environment:

```ts
new nodejs.NodejsFunction(this, 'my-handler', {
bundling: {
network: 'host',
securityOpt: 'no-new-privileges',
user: 'user:group',
volumesFrom: ['777f7dc92da7'],
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],
},
});
```

## Asset hash

By default the asset hash will be calculated based on the bundled output (`AssetHashType.OUTPUT`).
Expand Down
16 changes: 14 additions & 2 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ export class Bundling implements cdk.BundlingOptions {

// Core bundling options
public readonly image: cdk.DockerImage;
public readonly entrypoint?: string[]
public readonly command: string[];
public readonly volumes?: cdk.DockerVolume[];
public readonly volumesFrom?: string[];
public readonly environment?: { [key: string]: string };
public readonly workingDirectory: string;
public readonly user?: string;
public readonly securityOpt?: string;
public readonly network?: string;
public readonly local?: cdk.ILocalBundling;

private readonly projectRoot: string;
Expand Down Expand Up @@ -137,11 +143,17 @@ export class Bundling implements cdk.BundlingOptions {
tscRunner: 'tsc', // tsc is installed globally in the docker image
osPlatform: 'linux', // linux docker image
});
this.command = ['bash', '-c', bundlingCommand];
this.command = props.command ?? ['bash', '-c', bundlingCommand];
this.environment = props.environment;
// Bundling sets the working directory to cdk.AssetStaging.BUNDLING_INPUT_DIR
// and we want to force npx to use the globally installed esbuild.
this.workingDirectory = '/';
this.workingDirectory = props.workingDirectory ?? '/';
this.entrypoint = props.entrypoint;
this.volumes = props.volumes;
this.volumesFrom = props.volumesFrom;
this.user = props.user;
this.securityOpt = props.securityOpt;
this.network = props.network;

// Local bundling
if (!props.forceDockerBundling) { // only if Docker is not forced
Expand Down
11 changes: 2 additions & 9 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DockerImage } from '@aws-cdk/core';
import { DockerImage, DockerRunOptions } from '@aws-cdk/core';

/**
* Bundling options
*/
export interface BundlingOptions {
export interface BundlingOptions extends DockerRunOptions {
/**
* Whether to minify files when bundling.
*
Expand Down Expand Up @@ -161,13 +161,6 @@ export interface BundlingOptions {
*/
readonly charset?: Charset;

/**
* Environment variables defined when bundling runs.
*
* @default - no environment variables are defined.
*/
readonly environment?: { [key: string]: string; };

/**
* Replace global identifiers with constant expressions.
*
Expand Down
Loading

0 comments on commit 08f4947

Please sign in to comment.