Skip to content

Commit

Permalink
Merge branch 'master' into nija-at/apigwv2-integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Niranjan Jayakar authored Nov 26, 2021
2 parents cca8290 + 8191f1f commit f0288a6
Show file tree
Hide file tree
Showing 129 changed files with 2,327 additions and 295 deletions.
17 changes: 15 additions & 2 deletions packages/@aws-cdk/alexa-ask/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@

<!--END STABILITY BANNER-->

```ts
import * as alexaAsk from '@aws-cdk/alexa-ask';
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts nofixture
import * as alexa_ask from '@aws-cdk/alexa-ask';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for Alexa::ASK](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Alexa_ASK.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
93 changes: 36 additions & 57 deletions packages/@aws-cdk/assertions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The simplest assertion would be to assert that the template matches a given
template.

```ts
const expected = {
template.templateMatches({
Resources: {
BarLogicalId: {
Type: 'Foo::Bar',
Expand All @@ -46,9 +46,7 @@ const expected = {
},
},
},
};

template.templateMatches(expected);
});
```

By default, the `templateMatches()` API will use the an 'object-like' comparison,
Expand Down Expand Up @@ -84,23 +82,21 @@ The following code asserts that the `Properties` section of a resource of type
`Foo::Bar` contains the specified properties -

```ts
const expected = {
template.hasResourceProperties('Foo::Bar', {
Foo: 'Bar',
Baz: 5,
Qux: [ 'Waldo', 'Fred' ],
};
template.hasResourceProperties('Foo::Bar', expected);
});
```

Alternatively, if you would like to assert the entire resource definition, you
can use the `hasResource()` API.

```ts
const expected = {
template.hasResource('Foo::Bar', {
Properties: { Foo: 'Bar' },
DependsOn: [ 'Waldo', 'Fred' ],
};
template.hasResource('Foo::Bar', expected);
});
```

Beyond assertions, the module provides APIs to retrieve matching resources.
Expand Down Expand Up @@ -128,21 +124,17 @@ template.hasOutput('Foo', expected);
If you want to match against all Outputs in the template, use `*` as the `logicalId`.

```ts
const expected = {
template.hasOutput('*', {
Value: 'Bar',
Export: { Name: 'ExportBaz' },
};
template.hasOutput('*', expected);
});
```

`findOutputs()` will return a set of outputs that match the `logicalId` and `props`,
and you can use the `'*'` special case as well.

```ts
const expected = {
Value: 'Fred',
};
const result = template.findOutputs('*', expected);
const result = template.findOutputs('*', { Value: 'Fred' });
expect(result.Foo).toEqual({ Value: 'Fred', Description: 'FooFred' });
expect(result.Bar).toEqual({ Value: 'Fred', Description: 'BarFred' });
```
Expand Down Expand Up @@ -182,20 +174,18 @@ level, the list of keys in the target is a subset of the provided pattern.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Wobble: 'Flob',
}),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Brew: 'Coffee',
}),
}
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

The `Match.objectEquals()` API can be used to assert a target as a deep exact
Expand Down Expand Up @@ -223,20 +213,18 @@ or outside of any matchers.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Bob: Match.absent(),
}),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Wobble: Match.absent(),
}),
};
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

The `Match.anyValue()` matcher can be used to specify that a specific value should be found
Expand All @@ -261,20 +249,18 @@ This matcher can be combined with any of the other matchers.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wobble: [Match.anyValue(), "Flip"],
Wobble: [ Match.anyValue(), "Flip" ],
},
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wimble: Match.anyValue(),
},
};
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

### Array Matchers
Expand All @@ -297,16 +283,14 @@ This API will perform subset match on the target.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.arrayWith(['Flob']),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = Match.objectLike({
template.hasResourceProperties('Foo::Bar', Match.objectLike({
Fred: Match.arrayWith(['Wobble']),
});
template.hasResourceProperties('Foo::Bar', unexpected);
}));
```

*Note:* The list of items in the pattern array should be in order as they appear in the
Expand Down Expand Up @@ -334,16 +318,14 @@ not match the pattern specified.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.not(['Flob']),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = Match.objectLike({
template.hasResourceProperties('Foo::Bar', Match.objectLike({
Fred: Match.not(['Flob', 'Cat']),
});
template.hasResourceProperties('Foo::Bar', unexpected);
}));
```

### Serialized JSON
Expand All @@ -370,20 +352,18 @@ The `Match.serializedJson()` matcher allows deep matching within a stringified J
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Baz: Match.serializedJson({
Fred: Match.arrayWith(["Waldo"]),
}),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Baz: Match.serializedJson({
Fred: ["Waldo", "Johnny"],
}),
};
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

[Pipeline BuildSpec]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html#cfn-codebuild-project-source-buildspec
Expand Down Expand Up @@ -411,11 +391,10 @@ matching resource.

const fredCapture = new Capture();
const waldoCapture = new Capture();
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: fredCapture,
Waldo: ["Qix", waldoCapture],
}
template.hasResourceProperties('Foo::Bar', expected);
});

fredCapture.asArray(); // returns ["Flob", "Cat"]
waldoCapture.asString(); // returns "Qux"
Expand Down
13 changes: 12 additions & 1 deletion packages/@aws-cdk/aws-accessanalyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts
```ts nofixture
import * as accessanalyzer from '@aws-cdk/aws-accessanalyzer';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AccessAnalyzer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AccessAnalyzer.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
15 changes: 14 additions & 1 deletion packages/@aws-cdk/aws-amazonmq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@

<!--END STABILITY BANNER-->

```ts
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts nofixture
import * as amazonmq from '@aws-cdk/aws-amazonmq';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AmazonMQ](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AmazonMQ.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
17 changes: 6 additions & 11 deletions packages/@aws-cdk/aws-apigatewayv2/lib/common/api-mapping.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IResource, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApiMapping, CfnApiMappingProps } from '../apigatewayv2.generated';
import { HttpApi } from '../http/api';
import { IApi } from './api';
import { IDomainName } from './domain-name';
import { IStage } from './stage';
Expand Down Expand Up @@ -90,17 +89,13 @@ export class ApiMapping extends Resource implements IApiMapping {
constructor(scope: Construct, id: string, props: ApiMappingProps) {
super(scope, id);

let stage = props.stage;
// defaultStage is present in IHttpStage.
// However, importing "http" or "websocket" must import "common", but creating dependencies
// the other way will cause potential cycles.
// So casting to 'any'
let stage = props.stage ?? (props.api as any).defaultStage;
if (!stage) {
if (props.api instanceof HttpApi) {
if (props.api.defaultStage) {
stage = props.api.defaultStage;
} else {
throw new Error('stage is required if default stage is not available');
}
} else {
throw new Error('stage is required for WebSocket API');
}
throw new Error('stage property must be specified');
}

if (props.apiMappingKey === '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('ApiMapping', () => {
api,
domainName: dn,
});
}).toThrow(/stage is required if default stage is not available/);
}).toThrow(/stage property must be specified/);
});

test('stage validation - throws if stage not provided for WebSocketApi', () => {
Expand All @@ -138,6 +138,6 @@ describe('ApiMapping', () => {
api,
domainName: dn,
});
}).toThrow(/stage is required for WebSocket API/);
}).toThrow(/stage property must be specified/);
});
});
13 changes: 12 additions & 1 deletion packages/@aws-cdk/aws-appconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts
```ts nofixture
import * as appconfig from '@aws-cdk/aws-appconfig';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AppConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AppConfig.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
15 changes: 13 additions & 2 deletions packages/@aws-cdk/aws-appflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts
import appflow = require('@aws-cdk/aws-appflow');
```ts nofixture
import * as appflow from '@aws-cdk/aws-appflow';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AppFlow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AppFlow.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
15 changes: 13 additions & 2 deletions packages/@aws-cdk/aws-appintegrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts
import appintegrations = require('@aws-cdk/aws-appintegrations');
```ts nofixture
import * as appintegrations from '@aws-cdk/aws-appintegrations';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AppIntegrations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AppIntegrations.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
Loading

0 comments on commit f0288a6

Please sign in to comment.