Skip to content

Commit 5e91fca

Browse files
authored
Merge branch 'master' into huijbers/stacks-outside-stages-dont-count
2 parents 228be06 + 35b23a0 commit 5e91fca

File tree

138 files changed

+5318
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+5318
-814
lines changed

CHANGELOG.md

+62
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,68 @@
22

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.
44

5+
## [1.62.0](https://github.com/aws/aws-cdk/compare/v1.61.1...v1.62.0) (2020-09-03)
6+
7+
8+
### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES
9+
10+
* **eks:** when importing EKS clusters using `eks.Cluster.fromClusterAttributes`, the `clusterArn` attribute is not supported anymore, and will always be derived from `clusterName`.
11+
* **eks**: Only a single `eks.Cluster` is allowed per CloudFormation stack.
12+
* **eks**: The `securityGroups` attribute of `ClusterAttributes` is now `securityGroupIds`.
13+
* **cli**: `--qualifier` must be alphanumeric and not longer than 10 characters when bootstrapping using `newStyleStackSynthesis`.
14+
15+
### Features
16+
17+
* **appsync:** support Input Types for code-first approach ([#10024](https://github.com/aws/aws-cdk/issues/10024)) ([3f80ae6](https://github.com/aws/aws-cdk/commit/3f80ae6c7886c1bac1cefa5f613962e17a34cc54))
18+
* **appsync:** support query & mutation generation for code-first approach ([#9992](https://github.com/aws/aws-cdk/issues/9992)) ([1ed119e](https://github.com/aws/aws-cdk/commit/1ed119e2cdbc37666616f6666b0edb12c2c9ea89)), closes [#9308](https://github.com/aws/aws-cdk/issues/9308) [#9310](https://github.com/aws/aws-cdk/issues/9310)
19+
* **aws-chatbot:** Support L2 construct for SlackChannelConfiguration of chatbot. ([#9702](https://github.com/aws/aws-cdk/issues/9702)) ([05f5e62](https://github.com/aws/aws-cdk/commit/05f5e621d82bc4c32fba954820276e8c40381d9b)), closes [#9679](https://github.com/aws/aws-cdk/issues/9679)
20+
* **bootstrap:** customizable bootstrap template ([#9886](https://github.com/aws/aws-cdk/issues/9886)) ([2596ef7](https://github.com/aws/aws-cdk/commit/2596ef7a99c8eeba79609d60144842f5d33fdf9b)), closes [#9256](https://github.com/aws/aws-cdk/issues/9256) [#8724](https://github.com/aws/aws-cdk/issues/8724) [#3684](https://github.com/aws/aws-cdk/issues/3684) [#1528](https://github.com/aws/aws-cdk/issues/1528) [#9681](https://github.com/aws/aws-cdk/issues/9681)
21+
* **cli:** control progress output style with --progress=bar|events ([#9623](https://github.com/aws/aws-cdk/issues/9623)) ([56de5e1](https://github.com/aws/aws-cdk/commit/56de5e15e52768a5c63c02e7101b95a95f7cbc94)), closes [#8696](https://github.com/aws/aws-cdk/issues/8696)
22+
* **cloudfront:** import existing CloudFrontWebDistributions ([#10007](https://github.com/aws/aws-cdk/issues/10007)) ([ff33b54](https://github.com/aws/aws-cdk/commit/ff33b5416116fd23cf160078bf53651096bde284)), closes [#5607](https://github.com/aws/aws-cdk/issues/5607)
23+
* **cloudfront:** support includeBody for Lambda@Edge ([#10008](https://github.com/aws/aws-cdk/issues/10008)) ([9ffb268](https://github.com/aws/aws-cdk/commit/9ffb2682c167fe92e302bc322d60b9ae37de934a)), closes [#7085](https://github.com/aws/aws-cdk/issues/7085)
24+
* **ecs:** bottlerocket support ([#10097](https://github.com/aws/aws-cdk/issues/10097)) ([088abec](https://github.com/aws/aws-cdk/commit/088abec6513d8ae665a3a10bee5c5b5fe61a48b9)), closes [#10085](https://github.com/aws/aws-cdk/issues/10085)
25+
* **eks:** kubectl layer customization ([#10090](https://github.com/aws/aws-cdk/issues/10090)) ([0aa7ada](https://github.com/aws/aws-cdk/commit/0aa7adac958fb7997b64eba8c7fc3008e8557480)), closes [#7992](https://github.com/aws/aws-cdk/issues/7992)
26+
* **eks:** support adding k8s resources to imported clusters ([#9802](https://github.com/aws/aws-cdk/issues/9802)) ([4439481](https://github.com/aws/aws-cdk/commit/443948164e09aaa81c094c013b32aa1f67b69570)), closes [#5383](https://github.com/aws/aws-cdk/issues/5383)
27+
* **logs:** specify log group's region for LogRetention ([#9804](https://github.com/aws/aws-cdk/issues/9804)) ([0ccbc5d](https://github.com/aws/aws-cdk/commit/0ccbc5dfe5c841ec821ac98ac219e98984237cba))
28+
* **pipelines:** `SimpleSynthAction` takes array of build commands ([#10152](https://github.com/aws/aws-cdk/issues/10152)) ([44fcb4e](https://github.com/aws/aws-cdk/commit/44fcb4e65219b48aa9e186d1d6c10ca632e9658d)), closes [#9357](https://github.com/aws/aws-cdk/issues/9357)
29+
* **pipelines:** add control over underlying CodePipeline ([#10148](https://github.com/aws/aws-cdk/issues/10148)) ([41531b5](https://github.com/aws/aws-cdk/commit/41531b57ae1b19087399018b063da45356bf07bb)), closes [#9021](https://github.com/aws/aws-cdk/issues/9021)
30+
* **rds:** add support for joining instance to domain ([#9943](https://github.com/aws/aws-cdk/issues/9943)) ([f2d77d1](https://github.com/aws/aws-cdk/commit/f2d77d16d62e80d23c200ea94e4181660d953ca2)), closes [#9869](https://github.com/aws/aws-cdk/issues/9869)
31+
* **rds:** custom security groups for OptionGroups ([ea1072d](https://github.com/aws/aws-cdk/commit/ea1072d3baa50d8a722795557765360286195b79)), closes [#9240](https://github.com/aws/aws-cdk/issues/9240)
32+
* **rds:** custom security groups for OptionGroups ([#10011](https://github.com/aws/aws-cdk/issues/10011)) ([5738dc1](https://github.com/aws/aws-cdk/commit/5738dc17025355e3f94edc4af242253ebb3409f6)), closes [#9240](https://github.com/aws/aws-cdk/issues/9240)
33+
* **rds:** performance insights for DatabaseCluster instances ([#10092](https://github.com/aws/aws-cdk/issues/10092)) ([9c1b0c1](https://github.com/aws/aws-cdk/commit/9c1b0c1b27ba4680a1e15cbd6a30a8f10dfe6313)), closes [#7957](https://github.com/aws/aws-cdk/issues/7957)
34+
* **rds:** rename DatabaseInstanceNewProps.vpcPlacement to vpcSubnets ([#10093](https://github.com/aws/aws-cdk/issues/10093)) ([ec423ef](https://github.com/aws/aws-cdk/commit/ec423eff18809173a01d0c15e02ed4f042061310)), closes [#9776](https://github.com/aws/aws-cdk/issues/9776)
35+
* **elasticloadbalancingv2:** convenience method for ALB redirects ([#9913](https://github.com/aws/aws-cdk/issues/9913)) ([5bed08a](https://github.com/aws/aws-cdk/commit/5bed08a30880652a5113245bd455228bd8bf32a2))
36+
37+
38+
### Bug Fixes
39+
40+
* **apigateway:** burst and rate limits are set to unlimited when configured to 0 ([#10088](https://github.com/aws/aws-cdk/issues/10088)) ([96f1772](https://github.com/aws/aws-cdk/commit/96f1772ab861015f24703a1315538d37ae9529ad)), closes [#10071](https://github.com/aws/aws-cdk/issues/10071)
41+
* **appsync:** `GraphQLApi.UserPoolConfig` requires `DefaultAction` ([#10031](https://github.com/aws/aws-cdk/issues/10031)) ([6114045](https://github.com/aws/aws-cdk/commit/6114045a4861efc7364f94490b734df5cf019726)), closes [#10028](https://github.com/aws/aws-cdk/issues/10028)
42+
* **aws-elasticloadbalancingv2:** fix load balancer deletion protection to properly update when set to false ([#9986](https://github.com/aws/aws-cdk/issues/9986)) ([a65dd19](https://github.com/aws/aws-cdk/commit/a65dd190b0856db7880177910d4096a799791ee1))
43+
* **aws-sns:** enable topic encryption with cross account keys ([#10056](https://github.com/aws/aws-cdk/issues/10056)) ([327b72a](https://github.com/aws/aws-cdk/commit/327b72a0f4778318a937a069a5169c2174179dc0)), closes [#10055](https://github.com/aws/aws-cdk/issues/10055)
44+
* **aws-stepfunctions-tasks:** missing permission to get build status ([#10081](https://github.com/aws/aws-cdk/issues/10081)) ([cbdd084](https://github.com/aws/aws-cdk/commit/cbdd084d7b3eb92a311da48c279b5423e1ae22a2)), closes [#8043](https://github.com/aws/aws-cdk/issues/8043)
45+
* **aws-stepfunctions-tasks:** SageMaker create training job has incorrect property name for AttributeNames ([#10026](https://github.com/aws/aws-cdk/issues/10026)) ([ba51ea3](https://github.com/aws/aws-cdk/commit/ba51ea34e5b3f3c3cf337754d339f724b395211e)), closes [#10014](https://github.com/aws/aws-cdk/issues/10014)
46+
* **cfn-include:** allow Conditions to reference Mappings in their definitions ([#10105](https://github.com/aws/aws-cdk/issues/10105)) ([aa2068f](https://github.com/aws/aws-cdk/commit/aa2068f0d560de5737bd0a3df8089f8af2128e09)), closes [#10099](https://github.com/aws/aws-cdk/issues/10099)
47+
* **cfn-include:** allow parameters to be replaced across nested stacks ([#9842](https://github.com/aws/aws-cdk/issues/9842)) ([9ea8d5c](https://github.com/aws/aws-cdk/commit/9ea8d5c2d638bdf1f5bc63be197ecefc775d6539)), closes [#9838](https://github.com/aws/aws-cdk/issues/9838)
48+
* **cli:** AssumeRole profiles require a [default] profile ([#10032](https://github.com/aws/aws-cdk/issues/10032)) ([95c0332](https://github.com/aws/aws-cdk/commit/95c0332395d1203e8b00fda153fe08e70d0387c5)), closes [#9937](https://github.com/aws/aws-cdk/issues/9937)
49+
* **cli:** bootstrapping qualifier length not validated ([#10121](https://github.com/aws/aws-cdk/issues/10121)) ([e069263](https://github.com/aws/aws-cdk/commit/e0692636571eec76068e4cec0a87f13fc292fea0)), closes [#9255](https://github.com/aws/aws-cdk/issues/9255)
50+
* **cli:** Linux browser not supported for `cdk docs` ([#9549](https://github.com/aws/aws-cdk/issues/9549)) ([663913f](https://github.com/aws/aws-cdk/commit/663913f061f0fa3e2bed11b8cea763b12a3061f2)), closes [#2847](https://github.com/aws/aws-cdk/issues/2847)
51+
* **cli:** re-bootstrapping loses previous configuration ([#10120](https://github.com/aws/aws-cdk/issues/10120)) ([4e5829a](https://github.com/aws/aws-cdk/commit/4e5829ac5bb55533435772c3f2f294394ab2c973)), closes [#10091](https://github.com/aws/aws-cdk/issues/10091)
52+
* **cli:** unable to upgrade new style bootstrap to version ([#10030](https://github.com/aws/aws-cdk/issues/10030)) ([c5bb55c](https://github.com/aws/aws-cdk/commit/c5bb55c37c03597139522e0bb42f094c1f6b647e)), closes [#10016](https://github.com/aws/aws-cdk/issues/10016)
53+
* **cloudfront:** Distribution does not add edgelambda trust policy ([#10006](https://github.com/aws/aws-cdk/issues/10006)) ([9098e29](https://github.com/aws/aws-cdk/commit/9098e295826c09ef568bb8fc03c217ce8a15b822)), closes [#9998](https://github.com/aws/aws-cdk/issues/9998)
54+
* **custom-resources:** buffers returned by AwsCustomResource are unusable ([#9977](https://github.com/aws/aws-cdk/issues/9977)) ([7f351ff](https://github.com/aws/aws-cdk/commit/7f351ffeee30e1a2451e9b456c0d0a21002397da)), closes [#9969](https://github.com/aws/aws-cdk/issues/9969) [#10017](https://github.com/aws/aws-cdk/issues/10017)
55+
* **eks:** creating a `ServiceAccount` in a different stack than the `Cluster` creates circular dependency between the two stacks ([#9701](https://github.com/aws/aws-cdk/issues/9701)) ([1e96ebc](https://github.com/aws/aws-cdk/commit/1e96ebc29e1db251a1dc1e046c302943e7556c9a)), closes [40aws-cdk/aws-eks/lib/service-account.ts#L81-L95](https://github.com/40aws-cdk/aws-eks/lib/service-account.ts/issues/L81-L95) [40aws-cdk/aws-eks/lib/cluster.ts#L914-L923](https://github.com/40aws-cdk/aws-eks/lib/cluster.ts/issues/L914-L923) [40aws-cdk/aws-eks/lib/cluster.ts#L907-L909](https://github.com/40aws-cdk/aws-eks/lib/cluster.ts/issues/L907-L909)
56+
* **eks:** README.md grammar ([#10072](https://github.com/aws/aws-cdk/issues/10072)) ([454cdc6](https://github.com/aws/aws-cdk/commit/454cdc6106bee1ec23e8e9f390c03ebf6fcf2957))
57+
* **elbv2:** add protocol to AddNetworkTargetsProps ([#10054](https://github.com/aws/aws-cdk/issues/10054)) ([c7c00e7](https://github.com/aws/aws-cdk/commit/c7c00e73e5e9be5b5fa65394f80eb5fb47fe4153)), closes [aws/aws-cdk#10044](https://github.com/aws/aws-cdk/issues/10044)
58+
* **elbv2:** consider default protocol when validating redirectHTTP ([#10100](https://github.com/aws/aws-cdk/issues/10100)) ([9e4c6d2](https://github.com/aws/aws-cdk/commit/9e4c6d22890125328d26923e44c4885ae7daecbf))
59+
* **glue:** tables not including classification ([#9923](https://github.com/aws/aws-cdk/issues/9923)) ([61b45f3](https://github.com/aws/aws-cdk/commit/61b45f30f8aefef8e8989b597d4cf32ea731f324)), closes [#9902](https://github.com/aws/aws-cdk/issues/9902)
60+
* **lamba:** Add Java 8 Corretto Runtime support ([77f9703](https://github.com/aws/aws-cdk/commit/77f97039221981aea980b583e56ac88ed854a8e4))
61+
* **lambda:** grantInvoke fails for imported IAM identities ([#9957](https://github.com/aws/aws-cdk/issues/9957)) ([d748f44](https://github.com/aws/aws-cdk/commit/d748f4400e28fcb0933df6c57df36740381deff3)), closes [#9883](https://github.com/aws/aws-cdk/issues/9883)
62+
* **lambda-nodejs:** cannot stat error with jsx/tsx handler ([#9958](https://github.com/aws/aws-cdk/issues/9958)) ([25cfc18](https://github.com/aws/aws-cdk/commit/25cfc18f116e9ae3861de52af9f81fcec8454ae2))
63+
* **lambda-python:** allowPublicSubnet and filesystem not supported ([#10022](https://github.com/aws/aws-cdk/issues/10022)) ([745922a](https://github.com/aws/aws-cdk/commit/745922aa5a5a0195869830b54d7e529bec83e37c)), closes [#10018](https://github.com/aws/aws-cdk/issues/10018) [#10027](https://github.com/aws/aws-cdk/issues/10027)
64+
* **redshift:** single-node clusters fail with node count error ([#9961](https://github.com/aws/aws-cdk/issues/9961)) ([2cd3ea2](https://github.com/aws/aws-cdk/commit/2cd3ea21a92e624c3d07f7f4cb46391ef33e756e)), closes [#9856](https://github.com/aws/aws-cdk/issues/9856)
65+
* **route53:** value is too long error for TXT records ([#9984](https://github.com/aws/aws-cdk/issues/9984)) ([fd4be21](https://github.com/aws/aws-cdk/commit/fd4be21112ecd0cf3fd7ddfe005968507a5d18d4)), closes [#8244](https://github.com/aws/aws-cdk/issues/8244)
66+
567
## [1.61.1](https://github.com/aws/aws-cdk/compare/v1.61.0...v1.61.1) (2020-08-28)
668

769

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"tools/*"
1111
],
1212
"rejectCycles": "true",
13-
"version": "1.61.1"
13+
"version": "1.62.0"
1414
}

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@
6969
"@aws-cdk/core/minimatch/**",
7070
"@aws-cdk/cx-api/semver",
7171
"@aws-cdk/cx-api/semver/**",
72+
"aws-cdk-lib/case",
73+
"aws-cdk-lib/case/**",
74+
"aws-cdk-lib/fs-extra",
75+
"aws-cdk-lib/fs-extra/**",
76+
"aws-cdk-lib/jsonschema",
77+
"aws-cdk-lib/jsonschema/**",
78+
"aws-cdk-lib/minimatch",
79+
"aws-cdk-lib/minimatch/**",
80+
"aws-cdk-lib/semver",
81+
"aws-cdk-lib/semver/**",
82+
"aws-cdk-lib/yaml",
83+
"aws-cdk-lib/yaml/**",
7284
"monocdk-experiment/case",
7385
"monocdk-experiment/case/**",
7486
"monocdk-experiment/fs-extra",

packages/@aws-cdk/aws-appsync/README.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,21 @@ More concretely, GraphQL Types are simply the types appended to variables.
367367
Referencing the object type `Demo` in the previous example, the GraphQL Types
368368
is `String!` and is applied to both the names `id` and `version`.
369369

370+
#### Directives
371+
372+
`Directives` are attached to a field or type and affect the execution of queries,
373+
mutations, and types. With AppSync, we use `Directives` to configure authorization.
374+
CDK provides static functions to add directives to your Schema.
375+
376+
- `Directive.iam()` sets a type or field's authorization to be validated through `Iam`
377+
- `Directive.apiKey()` sets a type or field's authorization to be validated through a `Api Key`
378+
- `Directive.oidc()` sets a type or field's authorization to be validated through `OpenID Connect`
379+
- `Directive.cognito(...groups: string[])` sets a type or field's authorization to be validated
380+
through `Cognito User Pools`
381+
- `groups` the name of the cognito groups to give access
382+
383+
To learn more about authorization and directives, read these docs [here](https://docs.aws.amazon.com/appsync/latest/devguide/security.html).
384+
370385
#### Field and Resolvable Fields
371386

372387
While `GraphqlType` is a base implementation for GraphQL fields, we have abstractions
@@ -548,21 +563,7 @@ You can create Object Types in three ways:
548563
},
549564
});
550565
```
551-
> This method allows for reusability and modularity, ideal for reducing code duplication.
552-
553-
3. Object Types can be created ***internally*** within the GraphQL API.
554-
```ts
555-
const api = new appsync.GraphqlApi(stack, 'Api', {
556-
name: 'demo',
557-
});
558-
api.addType('Demo', {
559-
defintion: {
560-
id: appsync.GraphqlType.string({ isRequired: true }),
561-
version: appsync.GraphqlType.string({ isRequired: true }),
562-
},
563-
});
564-
```
565-
> This method provides easy use and is ideal for smaller projects.
566+
> This method allows for reusability and modularity, ideal for reducing code duplication.
566567

567568
##### Input Types
568569

packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts

+7
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ export class GraphqlApi extends GraphqlApiBase {
376376
*/
377377
public readonly schema: Schema;
378378

379+
/**
380+
* The Authorization Types for this GraphQL Api
381+
*/
382+
public readonly modes: AuthorizationType[];
383+
379384
/**
380385
* the configured API key, if present
381386
*
@@ -395,6 +400,8 @@ export class GraphqlApi extends GraphqlApiBase {
395400
const additionalModes = props.authorizationConfig?.additionalAuthorizationModes ?? [];
396401
const modes = [defaultMode, ...additionalModes];
397402

403+
this.modes = modes.map((mode) => mode.authorizationType );
404+
398405
this.validateAuthorizationProps(modes);
399406

400407
this.api = new CfnGraphQLApi(this, 'Resource', {

packages/@aws-cdk/aws-appsync/lib/private.ts

+35-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AuthorizationType } from './graphqlapi';
12
import { Directive } from './schema-base';
23
import { InterfaceType } from './schema-intermediate';
34

@@ -47,6 +48,10 @@ export interface SchemaAdditionOptions {
4748
* the fields to reduce onto the addition
4849
*/
4950
readonly fields: string[];
51+
/**
52+
* the authorization modes for this graphql type
53+
*/
54+
readonly modes?: AuthorizationType[];
5055
}
5156

5257
/**
@@ -67,7 +72,10 @@ export interface SchemaAdditionOptions {
6772
export function shapeAddition(options: SchemaAdditionOptions): string {
6873
const typeName = (): string => { return options.name ? ` ${options.name}` : ''; };
6974
const interfaces = generateInterfaces(options.interfaceTypes);
70-
const directives = generateDirectives(options.directives);
75+
const directives = generateDirectives({
76+
directives: options.directives,
77+
modes: options.modes,
78+
});
7179
return options.fields.reduce((acc, field) =>
7280
`${acc} ${field}\n`, `${options.prefix}${typeName()}${interfaces}${directives} {\n`) + '}';
7381
}
@@ -197,14 +205,33 @@ function generateInterfaces(interfaceTypes?: InterfaceType[]): string {
197205
`${acc} ${interfaceType.name},`, ' implements').slice(0, -1);
198206
}
199207

208+
/**
209+
* options to generate directives
210+
*/
211+
interface generateDirectivesOptions {
212+
/**
213+
* the directives of a given type
214+
*/
215+
readonly directives?: Directive[];
216+
/**
217+
* thee separator betweeen directives
218+
*
219+
* @default - a space
220+
*/
221+
readonly delimiter?: string;
222+
/**
223+
* the authorization modes
224+
*/
225+
readonly modes?: AuthorizationType[];
226+
}
227+
200228
/**
201229
* Utility function to generate directives
202-
*
203-
* @param directives the directives of a given type
204-
* @param delimiter the separator betweeen directives (by default we will add a space)
205230
*/
206-
function generateDirectives(directives?: Directive[], delimiter?: string): string {
207-
if (!directives || directives.length === 0) return '';
208-
return directives.reduce((acc, directive) =>
209-
`${acc}${directive.statement}${delimiter ?? ' '}`, ' ').slice(0, -1);
231+
function generateDirectives(options: generateDirectivesOptions): string {
232+
if (!options.directives || options.directives.length === 0) return '';
233+
// reduce over all directives and get string version of the directive
234+
// pass in the auth modes for checks to happen on compile time
235+
return options.directives.reduce((acc, directive) =>
236+
`${acc}${directive._bindToAuthModes(options.modes).toString()}${options.delimiter ?? ' '}`, ' ').slice(0, -1);
210237
}

0 commit comments

Comments
 (0)