From 565dcce9574c60344d750b9ad6831731279acd8d Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Thu, 26 Sep 2024 23:57:44 +0900 Subject: [PATCH 1/7] feat(appsync): add `ownerContact` property to the `GraphqlApi` --- ...efaultTestDeployAssert018781F2.assets.json | 19 ++ ...aultTestDeployAssert018781F2.template.json | 36 +++ .../cdk.out | 1 + .../integ.json | 12 + .../manifest.json | 133 ++++++++++++ .../stack.assets.json | 19 ++ .../stack.template.json | 85 ++++++++ .../tree.json | 205 ++++++++++++++++++ .../test/integ.appsync-owner-contact.ts | 23 ++ packages/aws-cdk-lib/aws-appsync/README.md | 13 ++ .../aws-cdk-lib/aws-appsync/lib/graphqlapi.ts | 13 ++ .../aws-appsync/test/appsync.test.ts | 26 +++ 12 files changed, 585 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.assets.json new file mode 100644 index 0000000000000..184b507d439eb --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "apiDefaultTestDeployAssert018781F2.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/apiDefaultTestDeployAssert018781F2.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/integ.json new file mode 100644 index 0000000000000..d57db15bfe5ff --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "api/DefaultTest": { + "stacks": [ + "stack" + ], + "assertionStack": "api/DefaultTest/DeployAssert", + "assertionStackName": "apiDefaultTestDeployAssert018781F2" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/manifest.json new file mode 100644 index 0000000000000..81f3c66b0663f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/manifest.json @@ -0,0 +1,133 @@ +{ + "version": "38.0.1", + "artifacts": { + "stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "stack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/cd77d1891b0a8f735849dd17fc60557c01348da18e6cc1de251bd652c7f8a2cf.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "stack.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "stack.assets" + ], + "metadata": { + "/stack/OwnerContact/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "OwnerContactCA72337C" + } + ], + "/stack/OwnerContact/Schema": [ + { + "type": "aws:cdk:logicalId", + "data": "OwnerContactSchemaD692A0DE" + } + ], + "/stack/OwnerContact/DefaultApiKey": [ + { + "type": "aws:cdk:logicalId", + "data": "OwnerContactDefaultApiKeyF4AD6E80" + } + ], + "/stack/OwnerContact/NoneDS/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "OwnerContactNoneDS6E9204C8" + } + ], + "/stack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/stack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "stack" + }, + "apiDefaultTestDeployAssert018781F2.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "apiDefaultTestDeployAssert018781F2.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "apiDefaultTestDeployAssert018781F2": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "apiDefaultTestDeployAssert018781F2.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "apiDefaultTestDeployAssert018781F2.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "apiDefaultTestDeployAssert018781F2.assets" + ], + "metadata": { + "/api/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/api/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "api/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.assets.json new file mode 100644 index 0000000000000..d8ac151f7b1f9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "cd77d1891b0a8f735849dd17fc60557c01348da18e6cc1de251bd652c7f8a2cf": { + "source": { + "path": "stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "cd77d1891b0a8f735849dd17fc60557c01348da18e6cc1de251bd652c7f8a2cf.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.template.json new file mode 100644 index 0000000000000..6c58617cf0e20 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/stack.template.json @@ -0,0 +1,85 @@ +{ + "Resources": { + "OwnerContactCA72337C": { + "Type": "AWS::AppSync::GraphQLApi", + "Properties": { + "AuthenticationType": "API_KEY", + "Name": "OwnerContact", + "OwnerContact": "test-owner-contact" + } + }, + "OwnerContactSchemaD692A0DE": { + "Type": "AWS::AppSync::GraphQLSchema", + "Properties": { + "ApiId": { + "Fn::GetAtt": [ + "OwnerContactCA72337C", + "ApiId" + ] + }, + "Definition": "type test {\n version: String!\n}\ntype Query {\n getTests: [test]!\n}\ntype Mutation {\n addTest(version: String!): test\n}\n" + } + }, + "OwnerContactDefaultApiKeyF4AD6E80": { + "Type": "AWS::AppSync::ApiKey", + "Properties": { + "ApiId": { + "Fn::GetAtt": [ + "OwnerContactCA72337C", + "ApiId" + ] + } + }, + "DependsOn": [ + "OwnerContactSchemaD692A0DE" + ] + }, + "OwnerContactNoneDS6E9204C8": { + "Type": "AWS::AppSync::DataSource", + "Properties": { + "ApiId": { + "Fn::GetAtt": [ + "OwnerContactCA72337C", + "ApiId" + ] + }, + "Name": "NoneDS", + "Type": "NONE" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/tree.json new file mode 100644 index 0000000000000..314df83d740e5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.js.snapshot/tree.json @@ -0,0 +1,205 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "stack": { + "id": "stack", + "path": "stack", + "children": { + "OwnerContact": { + "id": "OwnerContact", + "path": "stack/OwnerContact", + "children": { + "Resource": { + "id": "Resource", + "path": "stack/OwnerContact/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::GraphQLApi", + "aws:cdk:cloudformation:props": { + "authenticationType": "API_KEY", + "name": "OwnerContact", + "ownerContact": "test-owner-contact" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnGraphQLApi", + "version": "0.0.0" + } + }, + "Schema": { + "id": "Schema", + "path": "stack/OwnerContact/Schema", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::GraphQLSchema", + "aws:cdk:cloudformation:props": { + "apiId": { + "Fn::GetAtt": [ + "OwnerContactCA72337C", + "ApiId" + ] + }, + "definition": "type test {\n version: String!\n}\ntype Query {\n getTests: [test]!\n}\ntype Mutation {\n addTest(version: String!): test\n}\n" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnGraphQLSchema", + "version": "0.0.0" + } + }, + "DefaultApiKey": { + "id": "DefaultApiKey", + "path": "stack/OwnerContact/DefaultApiKey", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::ApiKey", + "aws:cdk:cloudformation:props": { + "apiId": { + "Fn::GetAtt": [ + "OwnerContactCA72337C", + "ApiId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnApiKey", + "version": "0.0.0" + } + }, + "LogGroup": { + "id": "LogGroup", + "path": "stack/OwnerContact/LogGroup", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "NoneDS": { + "id": "NoneDS", + "path": "stack/OwnerContact/NoneDS", + "children": { + "Resource": { + "id": "Resource", + "path": "stack/OwnerContact/NoneDS/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::DataSource", + "aws:cdk:cloudformation:props": { + "apiId": { + "Fn::GetAtt": [ + "OwnerContactCA72337C", + "ApiId" + ] + }, + "name": "NoneDS", + "type": "NONE" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnDataSource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.NoneDataSource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.GraphqlApi", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "stack/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "stack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "api": { + "id": "api", + "path": "api", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "api/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "api/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "api/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "api/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "api/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts new file mode 100644 index 0000000000000..8be81d7d13bc2 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts @@ -0,0 +1,23 @@ +import * as path from 'path'; +import * as cdk from 'aws-cdk-lib'; +import * as appsync from 'aws-cdk-lib/aws-appsync'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'stack'); + +const api = new appsync.GraphqlApi(stack, 'OwnerContact', { + name: 'OwnerContact', + definition: appsync.Definition.fromSchema(appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql'))), + ownerContact: 'test-owner-contact', +}); + +api.addNoneDataSource('NoneDS', { + name: cdk.Lazy.string({ produce(): string { return 'NoneDS'; } }), +}); + +new IntegTest(app, 'api', { + testCases: [stack], +}); + +app.synth(); \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-appsync/README.md b/packages/aws-cdk-lib/aws-appsync/README.md index 40ba93f974350..245ebff324386 100644 --- a/packages/aws-cdk-lib/aws-appsync/README.md +++ b/packages/aws-cdk-lib/aws-appsync/README.md @@ -912,3 +912,16 @@ rule.addTarget(new targets.AppSync(api, { }), })); ``` + +## Owner Contact + +You can set the owner contact information for an API resource. +This field accepts any string input with a length of 0 - 256 characters. + +```ts +const api = new appsync.GraphqlApi(stack, 'OwnerContact', { + name: 'OwnerContact', + definition: appsync.Definition.fromSchema(appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql'))), + ownerContact: 'test-owner-contact', +}); +``` \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts index 9bf1bd3b1a8e9..4d386dd3abe02 100644 --- a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts +++ b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts @@ -439,6 +439,15 @@ export interface GraphqlApiProps { * @default - No environment variables. */ readonly environmentVariables?: { [key: string]: string }; + + /** + * The owner contact information for an API resource. + * + * This field accepts any string input with a length of 0 - 256 characters. + * + * @default -No owner contact. + */ + readonly ownerContact?: string; } /** @@ -621,6 +630,9 @@ export class GraphqlApi extends GraphqlApiBase { if (props.resolverCountLimit !== undefined && (props.resolverCountLimit < 0 || props.resolverCountLimit > 10000)) { throw new Error('You must specify a resolver count limit between 0 and 10000.'); } + if (props.ownerContact !== undefined && (props.ownerContact.length > 256)) { + throw new Error('You must specify a owner contact as a string of 256 characters or less.'); + } this.definition = props.schema ? Definition.fromSchema(props.schema) : props.definition!; @@ -653,6 +665,7 @@ export class GraphqlApi extends GraphqlApiBase { queryDepthLimit: props.queryDepthLimit, resolverCountLimit: props.resolverCountLimit, environmentVariables: Lazy.any({ produce: () => this.renderEnvironmentVariables() }), + ownerContact: props.ownerContact, }); this.apiId = this.api.attrApiId; diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts index 87950c2d6c827..4830b571d1e1b 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts @@ -395,3 +395,29 @@ test.each([ }, }); }); + +test('when owner contact is set, they should be used on API', () => { + // WHEN + new appsync.GraphqlApi(stack, 'owner-contact', { + name: 'owner-contact', + definition: appsync.Definition.fromSchema(appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql'))), + ownerContact: 'test', + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::AppSync::GraphQLApi', { + OwnerContact: 'test', + }); +}); + +test('when owner contact exceeds 256 characters, it throws an error', () => { + const buildWithOwnerContact = () => { + new appsync.GraphqlApi(stack, 'owner-contact-length-exceeded', { + name: 'owner-contact', + definition: appsync.Definition.fromSchema(appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql'))), + ownerContact: 'a'.repeat(256 + 1), + }); + }; + + expect(() => buildWithOwnerContact()).toThrow('You must specify a owner contact as a string of 256 characters or less.'); +}); \ No newline at end of file From 11b6267dc7d1a1dc262c51334ef1c840bb7eda8b Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Sat, 28 Sep 2024 10:13:48 +0900 Subject: [PATCH 2/7] feat(appsync): fix readme lint --- packages/aws-cdk-lib/aws-appsync/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-appsync/README.md b/packages/aws-cdk-lib/aws-appsync/README.md index 245ebff324386..f0ab40d93b3c8 100644 --- a/packages/aws-cdk-lib/aws-appsync/README.md +++ b/packages/aws-cdk-lib/aws-appsync/README.md @@ -919,7 +919,7 @@ You can set the owner contact information for an API resource. This field accepts any string input with a length of 0 - 256 characters. ```ts -const api = new appsync.GraphqlApi(stack, 'OwnerContact', { +const api = new appsync.GraphqlApi(this, 'OwnerContact', { name: 'OwnerContact', definition: appsync.Definition.fromSchema(appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql'))), ownerContact: 'test-owner-contact', From 63877f223d1f707cad205aac562d9bce7c995047 Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Sat, 28 Sep 2024 20:45:39 +0900 Subject: [PATCH 3/7] Update packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts Co-authored-by: mazyu36 --- .../test/aws-appsync/test/integ.appsync-owner-contact.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts index 8be81d7d13bc2..730c488e33caa 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-owner-contact.ts @@ -19,5 +19,3 @@ api.addNoneDataSource('NoneDS', { new IntegTest(app, 'api', { testCases: [stack], }); - -app.synth(); \ No newline at end of file From 09a3f532a5ec2ffe9462255c284cf1ce33facd63 Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Sat, 28 Sep 2024 20:45:46 +0900 Subject: [PATCH 4/7] Update packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts Co-authored-by: mazyu36 --- packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts index 5746d7226e8e7..da421567ee46d 100644 --- a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts +++ b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts @@ -445,7 +445,7 @@ export interface GraphqlApiProps { * * This field accepts any string input with a length of 0 - 256 characters. * - * @default -No owner contact. + * @default - No owner contact. */ readonly ownerContact?: string; } From 841dd9df42d76adf255dee82877bbe1f1ac2cf6e Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Sat, 28 Sep 2024 20:46:09 +0900 Subject: [PATCH 5/7] Update packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts Co-authored-by: mazyu36 --- packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts index da421567ee46d..f1519db2a3ea4 100644 --- a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts +++ b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts @@ -631,7 +631,7 @@ export class GraphqlApi extends GraphqlApiBase { throw new Error('You must specify a resolver count limit between 0 and 10000.'); } if (props.ownerContact !== undefined && (props.ownerContact.length > 256)) { - throw new Error('You must specify a owner contact as a string of 256 characters or less.'); + throw new Error('You must specify `ownerContact` as a string of 256 characters or less.'); } this.definition = props.schema ? Definition.fromSchema(props.schema) : props.definition!; From 245d681ef887fe47c623ebaec34a131d41654a20 Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Sat, 28 Sep 2024 20:46:16 +0900 Subject: [PATCH 6/7] Update packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts Co-authored-by: mazyu36 --- packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts index 4830b571d1e1b..a597d96a9c7eb 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts @@ -419,5 +419,5 @@ test('when owner contact exceeds 256 characters, it throws an error', () => { }); }; - expect(() => buildWithOwnerContact()).toThrow('You must specify a owner contact as a string of 256 characters or less.'); + expect(() => buildWithOwnerContact()).toThrow('You must specify `ownerContact` as a string of 256 characters or less.'); }); \ No newline at end of file From 23f0ac5df5834251f7c73ef296b5a36312619588 Mon Sep 17 00:00:00 2001 From: yasuaki640 Date: Sat, 28 Sep 2024 21:16:53 +0900 Subject: [PATCH 7/7] feat(appsync): use token unresolved check --- packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts index f1519db2a3ea4..54785e32e739e 100644 --- a/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts +++ b/packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts @@ -630,7 +630,7 @@ export class GraphqlApi extends GraphqlApiBase { if (props.resolverCountLimit !== undefined && (props.resolverCountLimit < 0 || props.resolverCountLimit > 10000)) { throw new Error('You must specify a resolver count limit between 0 and 10000.'); } - if (props.ownerContact !== undefined && (props.ownerContact.length > 256)) { + if (!Token.isUnresolved(props.ownerContact) && props.ownerContact !== undefined && (props.ownerContact.length > 256)) { throw new Error('You must specify `ownerContact` as a string of 256 characters or less.'); }