Skip to content

Commit

Permalink
Merge branch 'master' into feature/object-lambda-l2
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 4, 2022
2 parents 006b146 + 364b0ce commit 79e2e63
Show file tree
Hide file tree
Showing 220 changed files with 920 additions and 467 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

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.

## [1.147.0](https://github.com/aws/aws-cdk/compare/v1.146.0...v1.147.0) (2022-03-01)


### Features

* **cfnspec:** cloudformation spec v58.0.0 ([#19153](https://github.com/aws/aws-cdk/issues/19153)) ([a6b0a10](https://github.com/aws/aws-cdk/commit/a6b0a1018694a0696ed27635d4def5d1630b8f9a))
* **cli:** hotswap support for resources in nested stacks ([#18950](https://github.com/aws/aws-cdk/issues/18950)) ([2ea9da1](https://github.com/aws/aws-cdk/commit/2ea9da118794809265d215e3d2f554bbcb91b271))
* **ec2:** add c6a instances ([#19113](https://github.com/aws/aws-cdk/issues/19113)) ([427cdfd](https://github.com/aws/aws-cdk/commit/427cdfde5e8c48ed7c1f86b275ccb2516a901239))


### Bug Fixes

* **apigateway:** fix strange vtl template for cors preflight request ([#19104](https://github.com/aws/aws-cdk/issues/19104)) ([59ef06a](https://github.com/aws/aws-cdk/commit/59ef06ae2a70fcb1800fcc1f40eec671c77440f0)), closes [/datatracker.ietf.org/doc/html/rfc6454#section-7](https://github.com/aws//datatracker.ietf.org/doc/html/rfc6454/issues/section-7)
* **aws-apigateway:** api gateway usage plan ([#19023](https://github.com/aws/aws-cdk/issues/19023)) ([5b764cc](https://github.com/aws/aws-cdk/commit/5b764cc397de4f4b203f5c69fa0128c6dced49f9)), closes [#18994](https://github.com/aws/aws-cdk/issues/18994)
* **aws-lambda-python:** skip default docker build when image passed ([#19143](https://github.com/aws/aws-cdk/issues/19143)) ([7300f2e](https://github.com/aws/aws-cdk/commit/7300f2eee9e1593eef271d7a953edf80a8962e08)), closes [#18082](https://github.com/aws/aws-cdk/issues/18082)
* **cli:** cdk version displays notices ([#19181](https://github.com/aws/aws-cdk/issues/19181)) ([fa16f7a](https://github.com/aws/aws-cdk/commit/fa16f7a9c11981da75e44ffc83adcdc6edad94fc))
* **cli:** long connection timeout slows the CLI down ([#19187](https://github.com/aws/aws-cdk/issues/19187)) ([6595d04](https://github.com/aws/aws-cdk/commit/6595d044e29fb262fb62430783ad08359e16bc30))
* **custom-resources:** physical resource id must be determined before isComplete ([#18630](https://github.com/aws/aws-cdk/issues/18630)) ([c190367](https://github.com/aws/aws-cdk/commit/c1903678aba31ca5b23a3bebb84249921e15dd5c))
* **dynamodb:** `grant*Data()` methods are missing the `dynamodb:DescribeTable` permission ([#19129](https://github.com/aws/aws-cdk/issues/19129)) ([4a44a65](https://github.com/aws/aws-cdk/commit/4a44a65bb4634081e04811966d5f4e2fd49bc7c6)), closes [#18773](https://github.com/aws/aws-cdk/issues/18773)
* **dynamodb:** `Table.grantWriteData()` doesn't include enough KMS permissions ([#19102](https://github.com/aws/aws-cdk/issues/19102)) ([77f1e0b](https://github.com/aws/aws-cdk/commit/77f1e0b57bd4508ade86be7733e71e94a47d7f4c)), closes [#10010](https://github.com/aws/aws-cdk/issues/10010)
* **ec2:** invalid volume type check for iops ([#19073](https://github.com/aws/aws-cdk/issues/19073)) ([3f49f02](https://github.com/aws/aws-cdk/commit/3f49f020090142c77feb892894c54e62dc4de7ae))
* **eks:** Helm charts fail to install when provided as an asset ([#19180](https://github.com/aws/aws-cdk/issues/19180)) ([9961257](https://github.com/aws/aws-cdk/commit/99612574bbaf97379482e9e424e1d1115809d74b))
* **lambda-nodejs:** `logLevel` property of `BundlingOptions` is ignored when `nodeModules` are defined ([#18456](https://github.com/aws/aws-cdk/issues/18456)) ([5c40b90](https://github.com/aws/aws-cdk/commit/5c40b90707b869f62e59613d50d5deaafbaa52f1)), closes [#18383](https://github.com/aws/aws-cdk/issues/18383)
* **stepfunctions-tasks:** RUN_JOB integration pattern not supported for CallAwsService ([#19186](https://github.com/aws/aws-cdk/issues/19186)) ([4b134b7](https://github.com/aws/aws-cdk/commit/4b134b785115f026a0eaa37b699cd32c85ff8e73)), closes [#19174](https://github.com/aws/aws-cdk/issues/19174)
* apply tags to nested stack ([#19128](https://github.com/aws/aws-cdk/issues/19128)) ([3af329b](https://github.com/aws/aws-cdk/commit/3af329bcb66b9dffce0c03f0816b33e91e901808)), closes [#17463](https://github.com/aws/aws-cdk/issues/17463)
* **triggers:** not published as part of v2 ([#19168](https://github.com/aws/aws-cdk/issues/19168)) ([8f727d1](https://github.com/aws/aws-cdk/commit/8f727d15f8f87d4ca323fee449826908db7971a4)), closes [#19164](https://github.com/aws/aws-cdk/issues/19164)
* construct paths are not printed for nested stacks in CLI output ([#18725](https://github.com/aws/aws-cdk/issues/18725)) ([b0e0155](https://github.com/aws/aws-cdk/commit/b0e0155f87a65c34a75e11776f98d55b83d2b220))
* **rds:** MySQL Cluster version 8.0 uses wrong Parameter for S3 import ([#19145](https://github.com/aws/aws-cdk/issues/19145)) ([96b2034](https://github.com/aws/aws-cdk/commit/96b2034c44b441a96cfe19855d343b0f983c8772)), closes [#19126](https://github.com/aws/aws-cdk/issues/19126)

## [1.146.0](https://github.com/aws/aws-cdk/compare/v1.145.0...v1.146.0) (2022-02-24)


Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-ec2/lib/private/ebs-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ function synthesizeBlockDeviceMappings<RT, NDT>(construct: Construct, blockDevic
const { iops, volumeType, kmsKey, ...rest } = ebs;

if (!iops) {
if (volumeType === EbsDeviceVolumeType.IO1) {
throw new Error('iops property is required with volumeType: EbsDeviceVolumeType.IO1');
if (volumeType === EbsDeviceVolumeType.IO1 || volumeType === EbsDeviceVolumeType.IO2) {
throw new Error('iops property is required with volumeType: EbsDeviceVolumeType.IO1 and EbsDeviceVolumeType.IO2');
}
} else if (volumeType !== EbsDeviceVolumeType.IO1) {
Annotations.of(construct).addWarning('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');
} else if (volumeType !== EbsDeviceVolumeType.IO1 && volumeType !== EbsDeviceVolumeType.IO2 && volumeType !== EbsDeviceVolumeType.GP3) {
Annotations.of(construct).addWarning('iops will be ignored without volumeType: IO1, IO2, or GP3');
}

/**
Expand Down
48 changes: 40 additions & 8 deletions packages/@aws-cdk/aws-ec2/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ describe('instance', () => {
volumeType: EbsDeviceVolumeType.IO1,
iops: 5000,
}),
}, {
deviceName: 'ebs-gp3',
mappingEnabled: true,
volume: BlockDeviceVolume.ebs(15, {
deleteOnTermination: true,
encrypted: true,
volumeType: EbsDeviceVolumeType.GP3,
iops: 5000,
}),
}, {
deviceName: 'ebs-cmk',
mappingEnabled: true,
Expand Down Expand Up @@ -236,6 +245,16 @@ describe('instance', () => {
VolumeType: 'io1',
},
},
{
DeviceName: 'ebs-gp3',
Ebs: {
DeleteOnTermination: true,
Encrypted: true,
Iops: 5000,
VolumeSize: 15,
VolumeType: 'gp3',
},
},
{
DeviceName: 'ebs-cmk',
Ebs: {
Expand Down Expand Up @@ -306,8 +325,25 @@ describe('instance', () => {
}],
});
}).toThrow(/ops property is required with volumeType: EbsDeviceVolumeType.IO1/);
});


test('throws if volumeType === IO2 without iops', () => {
// THEN
expect(() => {
new Instance(stack, 'Instance', {
vpc,
machineImage: new AmazonLinuxImage(),
instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
blockDevices: [{
deviceName: 'ebs',
volume: BlockDeviceVolume.ebs(15, {
deleteOnTermination: true,
encrypted: true,
volumeType: EbsDeviceVolumeType.IO2,
}),
}],
});
}).toThrow(/ops property is required with volumeType: EbsDeviceVolumeType.IO1 and EbsDeviceVolumeType.IO2/);
});

test('warning if iops without volumeType', () => {
Expand All @@ -327,12 +363,10 @@ describe('instance', () => {

// THEN
expect(instance.node.metadataEntry[0].type).toEqual(cxschema.ArtifactMetadataEntryType.WARN);
expect(instance.node.metadataEntry[0].data).toEqual('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');


expect(instance.node.metadataEntry[0].data).toEqual('iops will be ignored without volumeType: IO1, IO2, or GP3');
});

test('warning if iops and volumeType !== IO1', () => {
test('warning if iops and invalid volumeType', () => {
const instance = new Instance(stack, 'Instance', {
vpc,
machineImage: new AmazonLinuxImage(),
Expand All @@ -350,9 +384,7 @@ describe('instance', () => {

// THEN
expect(instance.node.metadataEntry[0].type).toEqual(cxschema.ArtifactMetadataEntryType.WARN);
expect(instance.node.metadataEntry[0].data).toEqual('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');


expect(instance.node.metadataEntry[0].data).toEqual('iops will be ignored without volumeType: IO1, IO2, or GP3');
});
});

Expand Down
18 changes: 12 additions & 6 deletions packages/@aws-cdk/aws-efs/lib/efs-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,21 @@ export class FileSystem extends FileSystemBase {
const encrypted = props.encrypted ?? (FeatureFlags.of(this).isEnabled(
cxapi.EFS_DEFAULT_ENCRYPTION_AT_REST) ? true : undefined);

// LifecyclePolicies is an array of lists containing a single policy
let lifecyclePolicies = [];

if (props.lifecyclePolicy) {
lifecyclePolicies.push({ transitionToIa: props.lifecyclePolicy });
}

if (props.outOfInfrequentAccessPolicy) {
lifecyclePolicies.push({ transitionToPrimaryStorageClass: props.outOfInfrequentAccessPolicy });
}

const filesystem = new CfnFileSystem(this, 'Resource', {
encrypted: encrypted,
kmsKeyId: props.kmsKey?.keyArn,
lifecyclePolicies: (
(props.lifecyclePolicy || props.outOfInfrequentAccessPolicy) ?
[{
transitionToIa: props.lifecyclePolicy,
transitionToPrimaryStorageClass: props.outOfInfrequentAccessPolicy,
}] : undefined),
lifecyclePolicies: lifecyclePolicies.length > 0 ? lifecyclePolicies : undefined,
performanceMode: props.performanceMode,
throughputMode: props.throughputMode,
provisionedThroughputInMibps: props.provisionedThroughputPerSecond?.toMebibytes(),
Expand Down
12 changes: 8 additions & 4 deletions packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,14 @@ test('file system is created correctly with a life cycle property and out of inf
});
// THEN
Template.fromStack(stack).hasResourceProperties('AWS::EFS::FileSystem', {
LifecyclePolicies: [{
TransitionToIA: 'AFTER_7_DAYS',
TransitionToPrimaryStorageClass: 'AFTER_1_ACCESS',
}],
LifecyclePolicies: [
{
TransitionToIA: 'AFTER_7_DAYS',
},
{
TransitionToPrimaryStorageClass: 'AFTER_1_ACCESS',
},
],
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ export interface AddApplicationTargetsProps extends AddRuleProps {
/**
* Health check configuration
*
* @default No health check
* @default - The default value for each property in this configuration varies depending on the target.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#aws-resource-elasticloadbalancingv2-targetgroup-properties
*/
readonly healthCheck?: HealthCheck;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ export interface AddNetworkTargetsProps {
/**
* Health check configuration
*
* @default No health check
* @default - The default value for each property in this configuration varies depending on the target.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#aws-resource-elasticloadbalancingv2-targetgroup-properties
*/
readonly healthCheck?: HealthCheck;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export interface BaseTargetGroupProps {
/**
* Health check configuration
*
* @default - None.
* @default - The default value for each property in this configuration varies depending on the target.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#aws-resource-elasticloadbalancingv2-targetgroup-properties
*/
readonly healthCheck?: HealthCheck;

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Bundling implements cdk.BundlingOptions {
private readonly packageManager: PackageManager;

constructor(private readonly props: BundlingProps) {
this.packageManager = PackageManager.fromLockFile(props.depsLockFilePath);
this.packageManager = PackageManager.fromLockFile(props.depsLockFilePath, props.logLevel);

Bundling.esbuildInstallation = Bundling.esbuildInstallation ?? PackageInstallation.detect('esbuild');
Bundling.tscInstallation = Bundling.tscInstallation ?? PackageInstallation.detect('tsc');
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';
import * as lambda from '@aws-cdk/aws-lambda';
import { Architecture } from '@aws-cdk/aws-lambda';
import { Bundling } from './bundling';
import { PackageManager } from './package-manager';
import { LockFile } from './package-manager';
import { BundlingOptions } from './types';
import { callsites, findUpMultiple } from './util';

Expand Down Expand Up @@ -138,9 +138,9 @@ function findLockFile(depsLockFilePath?: string): string {
}

const lockFiles = findUpMultiple([
PackageManager.PNPM.lockFile,
PackageManager.YARN.lockFile,
PackageManager.NPM.lockFile,
LockFile.PNPM,
LockFile.YARN,
LockFile.NPM,
]);

if (lockFiles.length === 0) {
Expand Down
62 changes: 34 additions & 28 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/package-manager.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,54 @@
import * as os from 'os';
import * as path from 'path';
import { LogLevel } from './types';

interface PackageManagerProps {
readonly lockFile: string;
readonly installCommand: string[];
readonly runCommand: string[];
readonly argsSeparator?: string
readonly argsSeparator?: string;
}

export enum LockFile {
NPM = 'package-lock.json',
YARN = 'yarn.lock',
PNPM = 'pnpm-lock.yaml',
}

/**
* A node package manager
*/
export class PackageManager {
public static NPM = new PackageManager({
lockFile: 'package-lock.json',
installCommand: ['npm', 'ci'],
runCommand: ['npx', '--no-install'],
});

public static YARN = new PackageManager({
lockFile: 'yarn.lock',
installCommand: ['yarn', 'install', '--no-immutable'],
runCommand: ['yarn', 'run'],
});

public static PNPM = new PackageManager({
lockFile: 'pnpm-lock.yaml',
installCommand: ['pnpm', 'install'],
runCommand: ['pnpm', 'exec'],
argsSeparator: '--',
});

public static fromLockFile(lockFilePath: string): PackageManager {
/**
* Use a lock file path to determine the package manager to use. Optionally, specify a log level to
* control its verbosity.
* @param lockFilePath Path of the lock file
* @param logLevel optional log level @default LogLevel.INFO
* @returns the right PackageManager for that lock file
*/
public static fromLockFile(lockFilePath: string, logLevel?: LogLevel): PackageManager {
const lockFile = path.basename(lockFilePath);

switch (lockFile) {
case PackageManager.NPM.lockFile:
return PackageManager.NPM;
case PackageManager.YARN.lockFile:
return PackageManager.YARN;
case PackageManager.PNPM.lockFile:
return PackageManager.PNPM;
case LockFile.YARN:
return new PackageManager({
lockFile: LockFile.YARN,
installCommand: logLevel && logLevel !== LogLevel.INFO ? ['yarn', 'install', '--no-immutable', '--silent'] : ['yarn', 'install', '--no-immutable'],
runCommand: ['yarn', 'run'],
});
case LockFile.PNPM:
return new PackageManager({
lockFile: LockFile.PNPM,
installCommand: logLevel && logLevel !== LogLevel.INFO ? ['pnpm', 'install', '--reporter', 'silent'] : ['pnpm', 'install'],
runCommand: ['pnpm', 'exec'],
argsSeparator: '--',
});
default:
return PackageManager.NPM;
return new PackageManager({
lockFile: LockFile.NPM,
installCommand: logLevel ? ['npm', 'ci', '--loglevel', logLevel] : ['npm', 'ci'],
runCommand: ['npx', '--no-install'],
});
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export interface BundlingOptions {
readonly loader?: { [ext: string]: string };

/**
* Log level for esbuild
* Log level for esbuild. This is also propagated to the package manager and
* applies to its specific install command.
*
* @default LogLevel.WARNING
*/
Expand Down Expand Up @@ -340,7 +341,7 @@ export interface ICommandHooks {
}

/**
* Log level for esbuild
* Log levels for esbuild and package managers' install commands.
*/
export enum LogLevel {
/** Show everything */
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ test('Local bundling', () => {
environment: {
KEY: 'value',
},
logLevel: LogLevel.ERROR,
});

expect(bundler.local).toBeDefined();
Expand Down
Loading

0 comments on commit 79e2e63

Please sign in to comment.