Skip to content

Commit

Permalink
Merge pull request #5825 from aws/v1.21.0
Browse files Browse the repository at this point in the history
v1.21.0

See CHANGELOG
  • Loading branch information
MrArnoldPalmer authored Jan 16, 2020
2 parents 1e146e7 + 0e44e2a commit bf6ab14
Show file tree
Hide file tree
Showing 269 changed files with 5,253 additions and 2,162 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

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.21.0](https://github.com/aws/aws-cdk/compare/v1.20.0...v1.21.0) (2020-01-15)


### Features

* **assert:** cdk assert: implement 'haveOutput' assertion ([#5366](https://github.com/aws/aws-cdk/issues/5366)) ([ee6decb](https://github.com/aws/aws-cdk/commit/ee6decbb4f2b90454777632f8750eae8674b1be2)), closes [#1906](https://github.com/aws/aws-cdk/issues/1906)
* **cli:** run cdk from inner directories ([#5772](https://github.com/aws/aws-cdk/issues/5772)) ([a54630d](https://github.com/aws/aws-cdk/commit/a54630db99716e1a7a19e4320fa4c55a42e5ea68))
* **codepipeline:** add CannedACL and CacheControl to S3 deploy action ([#5698](https://github.com/aws/aws-cdk/issues/5698)) ([b3e7978](https://github.com/aws/aws-cdk/commit/b3e7978dff2ce20d8e0327db13186922205a1b4c))
* **codepipeline:** add support for externalEntityLink in the manual approval action ([#5558](https://github.com/aws/aws-cdk/issues/5558)) ([be2e3e3](https://github.com/aws/aws-cdk/commit/be2e3e305eee5d90552c08512a4d476db74b91d0))
* **codepipeline:** Pipeline Variables ([#5604](https://github.com/aws/aws-cdk/issues/5604)) ([34d3e7d](https://github.com/aws/aws-cdk/commit/34d3e7de39dc197510013f6e4f91170b4c2e29f7)), closes [#5219](https://github.com/aws/aws-cdk/issues/5219)
* **ec2:** `VpcEndpointService` construct ([#5498](https://github.com/aws/aws-cdk/issues/5498)) ([a2713f3](https://github.com/aws/aws-cdk/commit/a2713f35d65bd26fb9ff878c6daed072ffed5f15))
* recommend matching commands ([#5668](https://github.com/aws/aws-cdk/issues/5668)) ([6108b91](https://github.com/aws/aws-cdk/commit/6108b91d6d3c087a61ac9b3990030a5a52a08808))
* **elbv2:** default config for internal load balancer will fall back to Isolated subnets ([#5696](https://github.com/aws/aws-cdk/pull/5696)) ([8b9c1fc](https://github.com/aws/aws-cdk/commit/8b9c1fc652673083ffd92f58a97931c1bbb834c9))
* **iam:** `Role.withoutPolicyUpdates()` ([#5569](https://github.com/aws/aws-cdk/issues/5569)) ([ea4ca3e](https://github.com/aws/aws-cdk/commit/ea4ca3ea251e54921c39ee79f321cae2701837ad)), closes [#2985](https://github.com/aws/aws-cdk/issues/2985) [#4465](https://github.com/aws/aws-cdk/issues/4465) [#4501](https://github.com/aws/aws-cdk/issues/4501)
* **iam:** support importing service roles ([#5701](https://github.com/aws/aws-cdk/issues/5701)) ([0f02dad](https://github.com/aws/aws-cdk/commit/0f02dad9ffa9d01912f29edc0c8d91869a6c4824)), closes [#2651](https://github.com/aws/aws-cdk/issues/2651)
* **s3:** server access logs ([#5072](https://github.com/aws/aws-cdk/issues/5072)) ([c9b074b](https://github.com/aws/aws-cdk/commit/c9b074b28b26a537fb81b9a4a431df6412964c59))


### Bug Fixes

* **acm:** `DnsValidatedCertificate` in non-aws partitions ([#5771](https://github.com/aws/aws-cdk/issues/5771)) ([e3305d8](https://github.com/aws/aws-cdk/commit/e3305d8d09b3fd87a0609606c3638332c4eeef33))
* **apigateway:** authorizer name is not optional ([#5731](https://github.com/aws/aws-cdk/issues/5731)) ([21c425e](https://github.com/aws/aws-cdk/commit/21c425e066dec3ec44daedfa980f9e4d96488755)), closes [#5678](https://github.com/aws/aws-cdk/issues/5678)
* **apigateway:** unable to associate RestApi as a route53 target for late bound domains ([#5555](https://github.com/aws/aws-cdk/issues/5555)) ([c02741e](https://github.com/aws/aws-cdk/commit/c02741ed53ecc834acfb5c3c4d5fc0deab6f2726))
* **cli:** Fix various init templates & their tests ([#5693](https://github.com/aws/aws-cdk/issues/5693)) ([a85da79](https://github.com/aws/aws-cdk/commit/a85da79c0da05f57af84d388efe7775502cf0039))
* **cli:** proxy support is broken ([#5803](https://github.com/aws/aws-cdk/issues/5803)) ([3a63f57](https://github.com/aws/aws-cdk/commit/3a63f57b3f36f914ac086d9bfe08274f0ddec574)), closes [#5743](https://github.com/aws/aws-cdk/issues/5743) [#5791](https://github.com/aws/aws-cdk/issues/5791)
* **cloudformation:** nested stack example in readme is broken ([#5729](https://github.com/aws/aws-cdk/issues/5729)) ([c53356a](https://github.com/aws/aws-cdk/commit/c53356a3cc4c4a96d326d73bfa28d791100391bc)), closes [#5686](https://github.com/aws/aws-cdk/issues/5686)
* **cloudwatch:** cross-account metrics in env-agnostic stack ([#5775](https://github.com/aws/aws-cdk/issues/5775)) ([5292bd5](https://github.com/aws/aws-cdk/commit/5292bd56ad4f7c2bf68767861c5e252b13282f34)), closes [aws/aws-cdk#5628](https://github.com/aws/aws-cdk/issues/5628)
* **codepipeline:** Action.onStateChange() has wrong detail type ([#5721](https://github.com/aws/aws-cdk/issues/5721)) ([8686dd5](https://github.com/aws/aws-cdk/commit/8686dd5bae583df08f2b25a8133c7e9296f7a643)), closes [#3614](https://github.com/aws/aws-cdk/issues/3614)
* **custom-resources:** missing physical resource id for delete calls ([#5805](https://github.com/aws/aws-cdk/issues/5805)) ([9b7236a](https://github.com/aws/aws-cdk/commit/9b7236abb4b08c2d080858059dc2b531031da6fe)), closes [#5796](https://github.com/aws/aws-cdk/issues/5796)
* **ecr-assets:** unable to use one Dockerfile to build multiple images ([#5705](https://github.com/aws/aws-cdk/issues/5705)) ([ff3f27f](https://github.com/aws/aws-cdk/commit/ff3f27fe56dc2300032c307cf09f50a3cd7a997e)), closes [#5683](https://github.com/aws/aws-cdk/issues/5683)
* **ecs:** cannot separate `Cluster` and `Ec2Service` behind ALB ([#5813](https://github.com/aws/aws-cdk/issues/5813)) ([eb3c517](https://github.com/aws/aws-cdk/commit/eb3c5170e1c3f5243ee437ab7627dd84d68d5740))
* **glue:** empty string in Table.s3prefix is not undefined ([#5783](https://github.com/aws/aws-cdk/issues/5783)) ([18e15de](https://github.com/aws/aws-cdk/commit/18e15de64dfcadd9b5cacef54ed5d93a9a91189a)), closes [#5763](https://github.com/aws/aws-cdk/issues/5763)
* **iam:** can't use `OrganizationPrincipal` for assuming Role ([#5746](https://github.com/aws/aws-cdk/issues/5746)) ([6c3d4c4](https://github.com/aws/aws-cdk/commit/6c3d4c40b7f4cef1c3d484bf9b3409ee6f33cc27)), closes [#5732](https://github.com/aws/aws-cdk/issues/5732)
* **rds:** pass the ARN of master instead of its ID in DatabaseInstanceReadReplica ([#5702](https://github.com/aws/aws-cdk/issues/5702)) ([d323c0c](https://github.com/aws/aws-cdk/commit/d323c0c13aaf475f59615a41969bb60cbb678be8)), closes [#5530](https://github.com/aws/aws-cdk/issues/5530)

## [1.20.0](https://github.com/aws/aws-cdk/compare/v1.19.0...v1.20.0) (2020-01-07)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"tools/*"
],
"rejectCycles": "true",
"version": "1.20.0"
"version": "1.21.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-cdk",
"version": "1.20.0",
"version": "1.21.0",
"private": true,
"pkglint": {
"include": "dependencies/node-version"
Expand Down
14 changes: 7 additions & 7 deletions packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-cdk/alexa-ask",
"version": "1.20.0",
"version": "1.21.0",
"description": "The CDK Construct Library for Alexa::ASK",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -80,16 +80,16 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "1.20.0",
"cdk-build-tools": "1.20.0",
"cfn2ts": "1.20.0",
"pkglint": "1.20.0"
"@aws-cdk/assert": "1.21.0",
"cdk-build-tools": "1.21.0",
"cfn2ts": "1.21.0",
"pkglint": "1.21.0"
},
"dependencies": {
"@aws-cdk/core": "1.20.0"
"@aws-cdk/core": "1.21.0"
},
"peerDependencies": {
"@aws-cdk/core": "1.20.0"
"@aws-cdk/core": "1.21.0"
},
"engines": {
"node": ">= 10.3.0"
Expand Down
44 changes: 22 additions & 22 deletions packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aws-cdk/app-delivery",
"description": "Continuous Integration / Continuous Delivery for CDK Applications",
"version": "1.20.0",
"version": "1.21.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"jsii": {
Expand Down Expand Up @@ -40,24 +40,24 @@
"compat": "cdk-compat"
},
"dependencies": {
"@aws-cdk/aws-cloudformation": "1.20.0",
"@aws-cdk/aws-codebuild": "1.20.0",
"@aws-cdk/aws-codepipeline": "1.20.0",
"@aws-cdk/aws-codepipeline-actions": "1.20.0",
"@aws-cdk/aws-events": "1.20.0",
"@aws-cdk/aws-iam": "1.20.0",
"@aws-cdk/core": "1.20.0",
"@aws-cdk/cx-api": "1.20.0"
"@aws-cdk/aws-cloudformation": "1.21.0",
"@aws-cdk/aws-codebuild": "1.21.0",
"@aws-cdk/aws-codepipeline": "1.21.0",
"@aws-cdk/aws-codepipeline-actions": "1.21.0",
"@aws-cdk/aws-events": "1.21.0",
"@aws-cdk/aws-iam": "1.21.0",
"@aws-cdk/core": "1.21.0",
"@aws-cdk/cx-api": "1.21.0"
},
"devDependencies": {
"@aws-cdk/assert": "1.20.0",
"@aws-cdk/aws-s3": "1.20.0",
"@aws-cdk/assert": "1.21.0",
"@aws-cdk/aws-s3": "1.21.0",
"@types/nodeunit": "^0.0.30",
"cdk-build-tools": "1.20.0",
"cdk-integ-tools": "1.20.0",
"cdk-build-tools": "1.21.0",
"cdk-integ-tools": "1.21.0",
"fast-check": "^1.21.0",
"nodeunit": "^0.11.3",
"pkglint": "1.20.0"
"pkglint": "1.21.0"
},
"repository": {
"type": "git",
Expand All @@ -76,14 +76,14 @@
"cdk"
],
"peerDependencies": {
"@aws-cdk/aws-cloudformation": "1.20.0",
"@aws-cdk/aws-codebuild": "1.20.0",
"@aws-cdk/aws-codepipeline": "1.20.0",
"@aws-cdk/aws-codepipeline-actions": "1.20.0",
"@aws-cdk/aws-events": "1.20.0",
"@aws-cdk/aws-iam": "1.20.0",
"@aws-cdk/core": "1.20.0",
"@aws-cdk/cx-api": "1.20.0"
"@aws-cdk/aws-cloudformation": "1.21.0",
"@aws-cdk/aws-codebuild": "1.21.0",
"@aws-cdk/aws-codepipeline": "1.21.0",
"@aws-cdk/aws-codepipeline-actions": "1.21.0",
"@aws-cdk/aws-events": "1.21.0",
"@aws-cdk/aws-iam": "1.21.0",
"@aws-cdk/core": "1.21.0",
"@aws-cdk/cx-api": "1.21.0"
},
"engines": {
"node": ">= 10.3.0"
Expand Down
22 changes: 22 additions & 0 deletions packages/@aws-cdk/assert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,25 @@ expect(stack).to(haveResource('AWS::CertificateManager::Certificate', {
// Note: some properties omitted here
}));
```
### Check existence of an output
`haveOutput` assertion can be used to check that a stack contains specific output.
Parameters to check against can be:
- `outputName`
- `outputValue`
- `exportName`

If `outputValue` is provided, at least one of `outputName`, `exportName` should be provided as well

Example
```ts
expect(synthStack).to(haveOutput({
outputName: 'TestOutputName',
exportName: 'TestOutputExportName',
outputValue: {
'Fn::GetAtt': [
'TestResource',
'Arn'
]
}
}));
```
25 changes: 19 additions & 6 deletions packages/@aws-cdk/assert/jest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Stack } from "@aws-cdk/core";
import { Stack } from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { HaveResourceAssertion, ResourcePart } from "./lib/assertions/have-resource";
import { MatchStyle, matchTemplate } from "./lib/assertions/match-template";
import { JestFriendlyAssertion } from './lib/assertion';
import { haveOutput, HaveOutputProperties } from './lib/assertions/have-output';
import { HaveResourceAssertion, ResourcePart } from './lib/assertions/have-resource';
import { MatchStyle, matchTemplate } from './lib/assertions/match-template';
import { expect as ourExpect } from './lib/expect';
import { StackInspector } from './lib/inspector';

declare global {
namespace jest {
Expand All @@ -17,6 +20,8 @@ declare global {
toHaveResourceLike(resourceType: string,
properties?: any,
comparison?: ResourcePart): R;

toHaveOutput(props: HaveOutputProperties): R;
}
}
}
Expand Down Expand Up @@ -50,20 +55,28 @@ expect.extend({
comparison?: ResourcePart) {

const assertion = new HaveResourceAssertion(resourceType, properties, comparison, false);
return assertHaveResource(assertion, actual);
return applyAssertion(assertion, actual);
},

toHaveResourceLike(
actual: cxapi.CloudFormationStackArtifact | Stack,
resourceType: string,
properties?: any,
comparison?: ResourcePart) {

const assertion = new HaveResourceAssertion(resourceType, properties, comparison, true);
return assertHaveResource(assertion, actual);
return applyAssertion(assertion, actual);
},

toHaveOutput(
actual: cxapi.CloudFormationStackArtifact | Stack,
props: HaveOutputProperties) {

return applyAssertion(haveOutput(props), actual);
}
});

function assertHaveResource(assertion: HaveResourceAssertion, actual: cxapi.CloudFormationStackArtifact | Stack) {
function applyAssertion(assertion: JestFriendlyAssertion<StackInspector>, actual: cxapi.CloudFormationStackArtifact | Stack) {
const inspector = ourExpect(actual);
const pass = assertion.assertUsing(inspector);
if (pass) {
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/assert/lib/assertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export abstract class Assertion<InspectorClass extends Inspector> {
}
}

export abstract class JestFriendlyAssertion<InspectorClass extends Inspector> extends Assertion<InspectorClass> {
/**
* Generates an error message that can be used by Jest.
*/
public abstract generateErrorMessage(): string;
}

import { AndAssertion } from "./assertions/and-assertion";

function and<I extends Inspector>(left: Assertion<I>, right: Assertion<I>): Assertion<I> {
Expand Down
116 changes: 116 additions & 0 deletions packages/@aws-cdk/assert/lib/assertions/have-output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { JestFriendlyAssertion } from '../assertion';
import { StackInspector } from '../inspector';

class HaveOutputAssertion extends JestFriendlyAssertion<StackInspector> {
private readonly inspected: InspectionFailure[] = [];

constructor(private readonly outputName?: string, private readonly exportName?: any, private outputValue?: any) {
super();
if (!this.outputName && !this.exportName) {
throw new Error('At least one of [outputName, exportName] should be provided');
}
}

public get description(): string {
const descriptionPartsArray = new Array<string>();

if (this.outputName) {
descriptionPartsArray.push(`name '${this.outputName}'`);
}
if (this.exportName) {
descriptionPartsArray.push(`export name ${JSON.stringify(this.exportName)}`);
}
if (this.outputValue) {
descriptionPartsArray.push(`value ${JSON.stringify(this.outputValue)}`);
}

return 'output with ' + descriptionPartsArray.join(', ');
}

public assertUsing(inspector: StackInspector): boolean {
if (!('Outputs' in inspector.value)) {
return false;
}

for (const [name, props] of Object.entries(inspector.value.Outputs as Record<string, any>)) {
const mismatchedFields = new Array<string>();

if (this.outputName && name !== this.outputName) {
mismatchedFields.push('name');
}

if (this.exportName && JSON.stringify(this.exportName) !== JSON.stringify(props.Export?.Name)) {
mismatchedFields.push('export name');
}

if (this.outputValue && JSON.stringify(this.outputValue) !== JSON.stringify(props.Value)) {
mismatchedFields.push('value');
}

if (mismatchedFields.length === 0) {
return true;
}

this.inspected.push({
output: { [name]: props },
failureReason: `mismatched ${mismatchedFields.join(', ')}`,
});
}

return false;
}

public generateErrorMessage() {
const lines = new Array<string>();

lines.push(`None of ${this.inspected.length} outputs matches ${this.description}.`);

for (const inspected of this.inspected) {
lines.push(`- ${inspected.failureReason} in:`);
lines.push(indent(4, JSON.stringify(inspected.output, null, 2)));
}

return lines.join('\n');
}
}

/**
* Interface for haveOutput function properties
* NOTE that at least one of [outputName, exportName] should be provided
*/
export interface HaveOutputProperties {
/**
* Logical ID of the output
* @default - the logical ID of the output will not be checked
*/
outputName?: string;
/**
* Export name of the output, when it's exported for cross-stack referencing
* @default - the export name is not required and will not be checked
*/
exportName?: any;
/**
* Value of the output;
* @default - the value will not be checked
*/
outputValue?: any;
}

interface InspectionFailure {
output: any;
failureReason: string;
}

/**
* An assertion to check whether Output with particular properties is present in a stack
* @param props properties of the Output that is being asserted against.
* Check ``HaveOutputProperties`` interface to get full list of available parameters
*/
export function haveOutput(props: HaveOutputProperties): JestFriendlyAssertion<StackInspector> {
return new HaveOutputAssertion(props.outputName, props.exportName, props.outputValue);
}

function indent(n: number, s: string) {
const prefix = ' '.repeat(n);
return prefix + s.replace(/\n/g, '\n' + prefix);
}
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assert/lib/assertions/have-resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Assertion } from "../assertion";
import { Assertion, JestFriendlyAssertion } from "../assertion";
import { StackInspector } from "../inspector";

/**
Expand Down Expand Up @@ -30,8 +30,8 @@ export function haveResourceLike(resourceType: string,

type PropertyPredicate = (props: any, inspection: InspectionFailure) => boolean;

export class HaveResourceAssertion extends Assertion<StackInspector> {
private inspected: InspectionFailure[] = [];
export class HaveResourceAssertion extends JestFriendlyAssertion<StackInspector> {
private readonly inspected: InspectionFailure[] = [];
private readonly part: ResourcePart;
private readonly predicate: PropertyPredicate;

Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/assert/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './inspector';
export * from './synth-utils';

export * from './assertions/exist';
export * from './assertions/have-output';
export * from './assertions/have-resource';
export * from './assertions/have-type';
export * from './assertions/match-template';
Expand Down
Loading

0 comments on commit bf6ab14

Please sign in to comment.