From 6775110dd05a78eefe1b85fba46915f6163e7a01 Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Sat, 1 Aug 2020 11:40:34 +0000 Subject: [PATCH 1/8] feat(appsync):xray-add --- .../@aws-cdk/aws-appsync/lib/graphqlapi.ts | 7 +++++++ .../@aws-cdk/aws-appsync/test/appsync.test.ts | 18 ++++++++++++++++++ .../test/integ.graphql-iam.expected.json | 3 ++- .../test/integ.graphql.expected.json | 3 ++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts b/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts index 9678c0dd3fee9..ba7fd69749187 100644 --- a/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts +++ b/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts @@ -238,6 +238,12 @@ export interface GraphQLApiProps { * @default - Use schemaDefinition */ readonly schemaDefinitionFile?: string; + /** + * A flag indicating whether or not X-Ray tracing is enabled for the GraphQL API. + * + * @default - false + */ + readonly xrayEnabled?: boolean; } @@ -383,6 +389,7 @@ export class GraphQLApi extends Construct { ) : undefined, additionalAuthenticationProviders: this.formatAdditionalAuthenticationProviders(props), + xrayEnabled: props.xrayEnabled || false, }); this.apiId = this.api.attrApiId; diff --git a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts index bc37922c85f82..afb5870e9dcfd 100644 --- a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts +++ b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts @@ -90,4 +90,22 @@ test('appsync should configure resolver as unit when pipelineConfig is empty arr expect(stack).toHaveResourceLike('AWS::AppSync::Resolver', { Kind: 'UNIT', }); +}); + +test('when xray is enabled should not throw an Error', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + new appsync.GraphQLApi(stack, 'api', { + authorizationConfig: {}, + name: 'api', + schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'), + xrayEnabled: true, + }); + + // THEN + expect(stack).toHaveResourceLike('AWS::AppSync::GraphQLApi', { + XrayEnabled: true, + }); }); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json b/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json index e83e633d67676..410d32864b75b 100644 --- a/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json +++ b/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json @@ -94,7 +94,8 @@ "UserPoolId": { "Ref": "PoolD3F588B8" } - } + }, + "XrayEnabled": false } }, "ApiSchema510EECD7": { diff --git a/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json b/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json index dc19df3e4c395..94eae0cdf96d6 100644 --- a/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json +++ b/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json @@ -94,7 +94,8 @@ "UserPoolId": { "Ref": "PoolD3F588B8" } - } + }, + "XrayEnabled": false } }, "ApiDefaultAPIKeyApiKey74F5313B": { From aaf8a7b8de0a40fc6dd8b6cc4a58ee0c8ac8bbc2 Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Sat, 1 Aug 2020 12:27:45 +0000 Subject: [PATCH 2/8] add to readme --- packages/@aws-cdk/aws-appsync/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-appsync/README.md b/packages/@aws-cdk/aws-appsync/README.md index f9811ddd9c1be..e6f3ad8417e41 100644 --- a/packages/@aws-cdk/aws-appsync/README.md +++ b/packages/@aws-cdk/aws-appsync/README.md @@ -158,4 +158,16 @@ api.grantMutation(role, 'updateExample'); // For custom types and granular design api.grant(role, appsync.IamResource.ofType('Mutation', 'updateExample'), 'appsync:GraphQL'); -``` \ No newline at end of file +``` + +## AppSync with X-Ray Tracing + +```ts +const api = new appsync.GraphQLApi(stack, 'Api', { + name: 'demo', + schemaDefinitionFile: join(__dirname, 'schema.graphql'), + xrayEnabled: true, +}); +``` + +See the [the AWS documentation](https://docs.aws.amazon.com/appsync/latest/devguide/x-ray-tracing.html) to learn more about AWS AppSync's X-Ray support. \ No newline at end of file From 3ec3a514b7a4969b7d0d5b1f4dd09b0cdfa2e935 Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Tue, 4 Aug 2020 13:21:01 +0000 Subject: [PATCH 3/8] fix x-ray property --- packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts b/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts index ba7fd69749187..b34b18dea6268 100644 --- a/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts +++ b/packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts @@ -389,7 +389,7 @@ export class GraphQLApi extends Construct { ) : undefined, additionalAuthenticationProviders: this.formatAdditionalAuthenticationProviders(props), - xrayEnabled: props.xrayEnabled || false, + xrayEnabled: props.xrayEnabled, }); this.apiId = this.api.attrApiId; From 2ae78369a5fff713d128599ace0334016d57ce96 Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Tue, 4 Aug 2020 13:21:33 +0000 Subject: [PATCH 4/8] fix integration test --- .../@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json | 3 +-- packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json b/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json index 410d32864b75b..e83e633d67676 100644 --- a/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json +++ b/packages/@aws-cdk/aws-appsync/test/integ.graphql-iam.expected.json @@ -94,8 +94,7 @@ "UserPoolId": { "Ref": "PoolD3F588B8" } - }, - "XrayEnabled": false + } } }, "ApiSchema510EECD7": { diff --git a/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json b/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json index 94eae0cdf96d6..dc19df3e4c395 100644 --- a/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json +++ b/packages/@aws-cdk/aws-appsync/test/integ.graphql.expected.json @@ -94,8 +94,7 @@ "UserPoolId": { "Ref": "PoolD3F588B8" } - }, - "XrayEnabled": false + } } }, "ApiDefaultAPIKeyApiKey74F5313B": { From ac4c152536c93ebb46d60dc8b1e1414f1f48f710 Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Tue, 4 Aug 2020 13:27:52 +0000 Subject: [PATCH 5/8] fix description of xray --- packages/@aws-cdk/aws-appsync/README.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/@aws-cdk/aws-appsync/README.md b/packages/@aws-cdk/aws-appsync/README.md index e6f3ad8417e41..23db6765831f3 100644 --- a/packages/@aws-cdk/aws-appsync/README.md +++ b/packages/@aws-cdk/aws-appsync/README.md @@ -53,6 +53,7 @@ const api = new appsync.GraphQLApi(stack, 'Api', { authorizationType: appsync.AuthorizationType.IAM }, }, + xrayEnabled: true, }); const demoTable = new db.Table(stack, 'DemoTable', { @@ -159,15 +160,3 @@ api.grantMutation(role, 'updateExample'); // For custom types and granular design api.grant(role, appsync.IamResource.ofType('Mutation', 'updateExample'), 'appsync:GraphQL'); ``` - -## AppSync with X-Ray Tracing - -```ts -const api = new appsync.GraphQLApi(stack, 'Api', { - name: 'demo', - schemaDefinitionFile: join(__dirname, 'schema.graphql'), - xrayEnabled: true, -}); -``` - -See the [the AWS documentation](https://docs.aws.amazon.com/appsync/latest/devguide/x-ray-tracing.html) to learn more about AWS AppSync's X-Ray support. \ No newline at end of file From ec0c3bf48234b07caa73bfae94a2e506b30bba21 Mon Sep 17 00:00:00 2001 From: Bryan Pan Date: Thu, 6 Aug 2020 10:29:48 -0700 Subject: [PATCH 6/8] fix merge bug --- packages/@aws-cdk/aws-appsync/test/appsync.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts index 995b71c41dc2d..76433ca4a18b2 100644 --- a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts +++ b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts @@ -10,7 +10,8 @@ test('should not throw an Error', () => { // WHEN const when = () => { new appsync.GraphQLApi(stack, 'api', { - authorizationConfig: {}, + authorizationConfig: {}, + schemaDefinition: appsync.SchemaDefinition.FILE, schemaDefinition: appsync.SchemaDefinition.FILE, name: 'api', schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'), @@ -112,4 +113,4 @@ test('when xray is enabled should not throw an Error', () => { expect(stack).toHaveResourceLike('AWS::AppSync::GraphQLApi', { XrayEnabled: true, }); -}); \ No newline at end of file +}); From 136cad8c83f8c1491477a66a10d882152cbcdbff Mon Sep 17 00:00:00 2001 From: Bryan Pan Date: Thu, 6 Aug 2020 10:30:26 -0700 Subject: [PATCH 7/8] wrong spot :-( --- packages/@aws-cdk/aws-appsync/test/appsync.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts index 76433ca4a18b2..29db6df288c5b 100644 --- a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts +++ b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts @@ -10,8 +10,7 @@ test('should not throw an Error', () => { // WHEN const when = () => { new appsync.GraphQLApi(stack, 'api', { - authorizationConfig: {}, - schemaDefinition: appsync.SchemaDefinition.FILE, + authorizationConfig: {}, schemaDefinition: appsync.SchemaDefinition.FILE, name: 'api', schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'), @@ -105,6 +104,7 @@ test('when xray is enabled should not throw an Error', () => { new appsync.GraphQLApi(stack, 'api', { authorizationConfig: {}, name: 'api', + schemaDefinition: appsync.SchemaDefinition.FILE, schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'), xrayEnabled: true, }); From fecdc62927abb8f1c617f0984f67afb9fa1ac804 Mon Sep 17 00:00:00 2001 From: Bryan Pan Date: Thu, 6 Aug 2020 10:43:35 -0700 Subject: [PATCH 8/8] ugh cant tell spacing on github edit --- packages/@aws-cdk/aws-appsync/test/appsync.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts index 29db6df288c5b..3c1ee1a71f1f2 100644 --- a/packages/@aws-cdk/aws-appsync/test/appsync.test.ts +++ b/packages/@aws-cdk/aws-appsync/test/appsync.test.ts @@ -104,7 +104,7 @@ test('when xray is enabled should not throw an Error', () => { new appsync.GraphQLApi(stack, 'api', { authorizationConfig: {}, name: 'api', - schemaDefinition: appsync.SchemaDefinition.FILE, + schemaDefinition: appsync.SchemaDefinition.FILE, schemaDefinitionFile: path.join(__dirname, 'appsync.test.graphql'), xrayEnabled: true, });