Skip to content

Commit

Permalink
chore(release): 1.116.0 (#15797)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller authored Jul 28, 2021
2 parents f0ca40f + 527cbee commit d04661d
Show file tree
Hide file tree
Showing 137 changed files with 7,887 additions and 684 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/yarn-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Node
uses: actions/setup-node@v2.2.0
uses: actions/setup-node@v2.3.0
with:
node-version: 10

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

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.116.0](https://github.com/aws/aws-cdk/compare/v1.115.0...v1.116.0) (2021-07-28)


### Features

* **assertions:** retrieve matching resources from the template ([#15642](https://github.com/aws/aws-cdk/issues/15642)) ([a8b1c47](https://github.com/aws/aws-cdk/commit/a8b1c471b7058bbf739a1d4f5b4860656ebd5432))
* **aws-kinesisfirehose:** DeliveryStream API and basic S3 destination ([#15544](https://github.com/aws/aws-cdk/issues/15544)) ([1b5d525](https://github.com/aws/aws-cdk/commit/1b5d525cef8ef4209074156c56077eebaa38d57c)), closes [#10810](https://github.com/aws/aws-cdk/issues/10810) [#15499](https://github.com/aws/aws-cdk/issues/15499)
* **cfnspec:** cloudformation spec v39.7.0 ([#15719](https://github.com/aws/aws-cdk/issues/15719)) ([2c4ef01](https://github.com/aws/aws-cdk/commit/2c4ef0131893e77d373c52b41c62d31847023446))
* **cfnspec:** cloudformation spec v39.7.0 ([#15796](https://github.com/aws/aws-cdk/issues/15796)) ([dbe4641](https://github.com/aws/aws-cdk/commit/dbe4641666c918c7bba36010fb4656d050ef5556))
* **codebuild:** add support for setting a BuildEnvironment Certificate ([#15738](https://github.com/aws/aws-cdk/issues/15738)) ([76fb481](https://github.com/aws/aws-cdk/commit/76fb4811bb9f5d5fc1bd340954840032cb23698b)), closes [#15701](https://github.com/aws/aws-cdk/issues/15701)
* **core:** lazy mappings will only synthesize if keys are unresolved ([#15617](https://github.com/aws/aws-cdk/issues/15617)) ([32ed229](https://github.com/aws/aws-cdk/commit/32ed2290f8efb27bf622998f98808ff18a8cdef1))
* **pipelines:** CDK Pipelines is now Generally Available ([#15667](https://github.com/aws/aws-cdk/issues/15667)) ([2e4cfae](https://github.com/aws/aws-cdk/commit/2e4cfaeb8612179c79e293ba52a8afcdcfd6ef52))
* **servicecatalog:** add ability to set launch Role and deploy with StackSets ([#15678](https://github.com/aws/aws-cdk/issues/15678)) ([c92548b](https://github.com/aws/aws-cdk/commit/c92548b2242478d22db030842014e7646715c2ef))
* **stepfunctions:** allow intrinsic functions for json path ([#15320](https://github.com/aws/aws-cdk/issues/15320)) ([d9285cb](https://github.com/aws/aws-cdk/commit/d9285cb75745028ede8c36afcee34f7a53d27993))


### Bug Fixes

* **aws-cloudwatch:** unable to use generic extended statistics for cloudwatch alarms ([#15720](https://github.com/aws/aws-cdk/issues/15720)) ([f593311](https://github.com/aws/aws-cdk/commit/f59331193b5a2cc4a33d71d775f6650d66bb1bf8))
* **elasticsearch:** advancedOptions in domain has no effect ([#15330](https://github.com/aws/aws-cdk/issues/15330)) ([81cbfec](https://github.com/aws/aws-cdk/commit/81cbfec5ddf065aac442d925484a358ee8cd26a1)), closes [#14067](https://github.com/aws/aws-cdk/issues/14067)
* **elasticsearch:** slow logs incorrectly disabled for Elasticsearch versions lower than 5.1 ([#15714](https://github.com/aws/aws-cdk/issues/15714)) ([91cf79b](https://github.com/aws/aws-cdk/commit/91cf79bc55ffd72b1c79e2218eb76921fbac32b4)), closes [#15532](https://github.com/aws/aws-cdk/issues/15532) [#15532](https://github.com/aws/aws-cdk/issues/15532)
* **pipelines:** Secrets Manager permissions not added to asset projects ([#15718](https://github.com/aws/aws-cdk/issues/15718)) ([7668400](https://github.com/aws/aws-cdk/commit/7668400ec8d4e6ee042c05976f95e42147993375)), closes [#15628](https://github.com/aws/aws-cdk/issues/15628)
* **stepfunctions:** non-object arguments to recurseObject are incorrectly treated as objects ([#14631](https://github.com/aws/aws-cdk/issues/14631)) ([e133bca](https://github.com/aws/aws-cdk/commit/e133bca61b95b71d51b509b646ff1720099ee31e)), closes [#12935](https://github.com/aws/aws-cdk/issues/12935) [aws-cdk/aws-stepfunctions/lib/input.ts#L65](https://github.com/aws-cdk/aws-stepfunctions/lib/input.ts/issues/L65)
* **stepfunctions-tasks:** instance type cannot be provided to SageMakerCreateTransformJob as input path ([#15726](https://github.com/aws/aws-cdk/issues/15726)) ([6f2384d](https://github.com/aws/aws-cdk/commit/6f2384ddc180e944c9564a543351b8df2f75c1a7))

## [1.115.0](https://github.com/aws/aws-cdk/compare/v1.114.0...v1.115.0) (2021-07-21)


Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ The steps here are usually AWS CLI commands but they need not be.

Examples:
* [integ.destinations.ts](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-lambda-destinations/test/integ.destinations.ts#L7)
* [integ.token-authorizer.ts](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.ts#L6)
* [integ.token-authorizer.lit.ts](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.lit.ts#L7-L12)

#### yarn watch (Optional)

Expand Down
6 changes: 3 additions & 3 deletions docs/DESIGN_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,14 @@ A pattern for an "Enum-like Class" should be used in such cases:

```ts
export interface MyProps {
option: MyOption;
readonly option: MyOption;
}

export class MyOption {
public static COMMON_OPTION_1 = new MyOption('common.option-1');
public static COMMON_OPTION_2 = new MyOption('common.option-2');

public MyOption(public readonly customValue: string) { }
public constructor(public readonly customValue: string) { }
}
```

Expand All @@ -644,7 +644,7 @@ export class MyOption {

// 'protected' iso. 'private' so that someone that really wants to can still
// do subclassing. But maybe might as well be private.
protected MyOption(public readonly value: string) { }
protected constructor(public readonly value: string) { }
}

// Usage
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"jsii-rosetta": "^1.31.0",
"lerna": "^4.0.0",
"patch-package": "^6.4.7",
"standard-version": "^9.3.0",
"standard-version": "^9.3.1",
"typescript": "~3.9.10"
},
"tap-mocha-reporter-resolutions-comment": "should be removed or reviewed when nodeunit dependency is dropped or adjusted",
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/assertions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ in a template.
assert.resourceCountIs('Foo::Bar', 2);
```

## Resource Matching
## Resource Matching & Retrieval

Beyond resource counting, the module also allows asserting that a resource with
specific properties are present.
Expand All @@ -88,6 +88,10 @@ assert.hasResource('Foo::Bar', {
});
```

Beyond assertions, the module provides APIs to retrieve matching resources.
The `findResources()` API is complementary to the `hasResource()` API, except,
instead of asserting its presence, it returns the set of matching resources.

By default, the `hasResource()` and `hasResourceProperties()` APIs perform deep
partial object matching. This behavior can be configured using matchers.
See subsequent section on [special matchers](#special-matchers).
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assertions/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './assertions';
export * from './template';
export * from './match';
export * from './matcher';
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
import { Match } from './match';
import { Matcher, MatchResult } from './matcher';
import { StackInspector } from './vendored/assert';
import { Match } from '../match';
import { Matcher, MatchResult } from '../matcher';
import { StackInspector } from '../vendored/assert';

export function findResources(inspector: StackInspector, type: string, props: any = {}): { [key: string]: any }[] {
const matcher = Matcher.isMatcher(props) ? props : Match.objectLike(props);
let results: { [key: string]: any }[] = [];

eachResourceWithType(inspector, type, (resource) => {
const result = matcher.test(resource);
if (!result.hasFailed()) {
results.push(resource);
}
});

return results;
}

export function hasResource(inspector: StackInspector, type: string, props: any): string | void {
const matcher = Matcher.isMatcher(props) ? props : Match.objectLike(props);
let closestResult: MatchResult | undefined = undefined;
let closestResource: { [key: string]: any } | undefined = undefined;
let count: number = 0;

for (const logicalId of Object.keys(inspector.value.Resources ?? {})) {
const resource: { [key: string]: any } = inspector.value.Resources[logicalId];
if (resource.Type === type) {
count++;
const result = matcher.test(resource);
if (!result.hasFailed()) {
return;
}
if (closestResult === undefined || closestResult.failCount > result.failCount) {
closestResult = result;
closestResource = resource;
}
let match = false;
eachResourceWithType(inspector, type, (resource) => {
if (match) { return; }
count++;
const result = matcher.test(resource);
if (!result.hasFailed()) {
match = true;
}
if (closestResult === undefined || closestResult.failCount > result.failCount) {
closestResult = result;
closestResource = resource;
}
});

if (match) {
return;
}

if (closestResult === undefined) {
Expand All @@ -37,6 +54,19 @@ export function hasResource(inspector: StackInspector, type: string, props: any)
].join('\n');
}

function eachResourceWithType(
inspector: StackInspector,
type: string,
cb: (resource: {[key: string]: any}) => void): void {

for (const logicalId of Object.keys(inspector.value.Resources ?? {})) {
const resource: { [key: string]: any } = inspector.value.Resources[logicalId];
if (resource.Type === type) {
cb(resource);
}
}
}

function formatMessage(closestResult: MatchResult, closestResource: {}): string {
return [
'The closest result is:',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stack, Stage } from '@aws-cdk/core';
import { hasResource } from './has-resource';
import { Match } from './match';
import { Matcher } from './matcher';
import { findResources, hasResource } from './private/resource';
import * as assert from './vendored/assert';

/**
Expand Down Expand Up @@ -82,6 +82,17 @@ export class TemplateAssertions {
}
}

/**
* Get the set of matching resources of a given type and properties in the CloudFormation template.
* @param type the type to match in the CloudFormation template
* @param props by default, matches all resources with the given type.
* When a literal is provided, performs a partial match via `Match.objectLike()`.
* Use the `Match` APIs to configure a different behaviour.
*/
public findResources(type: string, props: any = {}): { [key: string]: any }[] {
return findResources(this.inspector, type, props);
}

/**
* Assert that the CloudFormation template matches the given value
* @param expected the expected CloudFormation template as key-value pairs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,68 @@ describe('TemplateAssertions', () => {
})).toThrow(/No resource/);
});
});

describe('getResources', () => {
test('matching resource type', () => {
const stack = new Stack();
new CfnResource(stack, 'Foo', {
type: 'Foo::Bar',
properties: { baz: 'qux', fred: 'waldo' },
});

const inspect = TemplateAssertions.fromStack(stack);
expect(inspect.findResources('Foo::Bar')).toEqual([{
Type: 'Foo::Bar',
Properties: { baz: 'qux', fred: 'waldo' },
}]);
});

test('no matching resource type', () => {
const stack = new Stack();
new CfnResource(stack, 'Foo', {
type: 'Foo::Bar',
properties: { baz: 'qux', fred: 'waldo' },
});

const inspect = TemplateAssertions.fromStack(stack);
expect(inspect.findResources('Foo::Baz')).toEqual([]);
});

test('matching resource props', () => {
const stack = new Stack();
new CfnResource(stack, 'Foo', {
type: 'Foo::Bar',
properties: { baz: 'qux', fred: 'waldo' },
});

const inspect = TemplateAssertions.fromStack(stack);
expect(inspect.findResources('Foo::Bar', {
Properties: { baz: 'qux' },
}).length).toEqual(1);
});

test('no matching resource props', () => {
const stack = new Stack();
new CfnResource(stack, 'Foo', {
type: 'Foo::Bar',
properties: { baz: 'qux', fred: 'waldo' },
});

const inspect = TemplateAssertions.fromStack(stack);
expect(inspect.findResources('Foo::Bar', {
Properties: { baz: 'waldo' },
})).toEqual([]);
});

test('multiple matching resources', () => {
const stack = new Stack();
new CfnResource(stack, 'Foo', { type: 'Foo::Bar' });
new CfnResource(stack, 'Bar', { type: 'Foo::Bar' });

const inspect = TemplateAssertions.fromStack(stack);
expect(inspect.findResources('Foo::Bar').length).toEqual(2);
});
});
});

function expectToThrow(fn: () => void, msgs: (RegExp | string)[], done: jest.DoneCallback): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "^26.0.24",
"@types/aws-lambda": "^8.10.78",
"@types/aws-lambda": "^8.10.79",
"@aws-cdk/aws-apigatewayv2-integrations": "0.0.0",
"@aws-cdk/aws-lambda": "0.0.0",
"cdk-build-tools": "0.0.0",
Expand Down
Loading

0 comments on commit d04661d

Please sign in to comment.