diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/appsyncdomainnameDefaultTestDeployAssert6D41B82A.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/appsyncdomainnameDefaultTestDeployAssert6D41B82A.assets.json new file mode 100644 index 0000000000000..e75afcce8b80b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/appsyncdomainnameDefaultTestDeployAssert6D41B82A.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "appsyncdomainnameDefaultTestDeployAssert6D41B82A.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-route53-targets/test/integ.appsync-target.js.snapshot/appsyncdomainnameDefaultTestDeployAssert6D41B82A.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/appsyncdomainnameDefaultTestDeployAssert6D41B82A.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/appsyncdomainnameDefaultTestDeployAssert6D41B82A.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-route53-targets/test/integ.appsync-target.js.snapshot/aws-cdk-appsync-alias-integ.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/aws-cdk-appsync-alias-integ.assets.json new file mode 100644 index 0000000000000..efdd71a86a077 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/aws-cdk-appsync-alias-integ.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "c593cb22174c1c4d68553e7d6feb8961dce6f29331738530e334d3595a58e935": { + "source": { + "path": "aws-cdk-appsync-alias-integ.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "c593cb22174c1c4d68553e7d6feb8961dce6f29331738530e334d3595a58e935.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-route53-targets/test/integ.appsync-target.js.snapshot/aws-cdk-appsync-alias-integ.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/aws-cdk-appsync-alias-integ.template.json new file mode 100644 index 0000000000000..79f830860e6fc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/aws-cdk-appsync-alias-integ.template.json @@ -0,0 +1,142 @@ +{ + "Resources": { + "apiC8550315": { + "Type": "AWS::AppSync::GraphQLApi", + "Properties": { + "AuthenticationType": "API_KEY", + "Name": "api" + } + }, + "apiSchema0EA92056": { + "Type": "AWS::AppSync::GraphQLSchema", + "Properties": { + "ApiId": { + "Fn::GetAtt": [ + "apiC8550315", + "ApiId" + ] + }, + "Definition": "type test {\n version: String!\n}\ntype Query {\n getTests: [test]!\n}\ntype Mutation {\n addTest(version: String!): test\n}\n" + } + }, + "apiDomainNameBBFE36A4": { + "Type": "AWS::AppSync::DomainName", + "Properties": { + "CertificateArn": "arn:aws:acm:test-region:12345678:certificate/86468209-a272-595d-b831-0efb6421265z", + "Description": { + "Fn::Join": [ + "", + [ + "domain for api at ", + { + "Fn::GetAtt": [ + "apiC8550315", + "GraphQLUrl" + ] + } + ] + ] + }, + "DomainName": "*.example.com" + } + }, + "apiDomainAssociation1CF2F52A": { + "Type": "AWS::AppSync::DomainNameApiAssociation", + "Properties": { + "ApiId": { + "Fn::GetAtt": [ + "apiC8550315", + "ApiId" + ] + }, + "DomainName": "*.example.com" + }, + "DependsOn": [ + "apiDomainNameBBFE36A4" + ] + }, + "apiDefaultApiKey6AB8D7C4": { + "Type": "AWS::AppSync::ApiKey", + "Properties": { + "ApiId": { + "Fn::GetAtt": [ + "apiC8550315", + "ApiId" + ] + } + }, + "DependsOn": [ + "apiSchema0EA92056" + ] + }, + "Alias325C5727": { + "Type": "AWS::Route53::RecordSet", + "Properties": { + "AliasTarget": { + "DNSName": { + "Fn::GetAtt": [ + "apiDomainNameBBFE36A4", + "AppSyncDomainName" + ] + }, + "HostedZoneId": { + "Fn::FindInMap": [ + "AWSCloudFrontPartitionHostedZoneIdMap", + { + "Ref": "AWS::Partition" + }, + "zoneId" + ] + } + }, + "HostedZoneId": "Z23ABC4XYZL05B", + "Name": "*.example.com.", + "Type": "A" + } + } + }, + "Mappings": { + "AWSCloudFrontPartitionHostedZoneIdMap": { + "aws": { + "zoneId": "Z2FDTNDATAQYW2" + }, + "aws-cn": { + "zoneId": "Z3RFFRIM2A3IF5" + } + } + }, + "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-route53-targets/test/integ.appsync-target.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.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-route53-targets/test/integ.appsync-target.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/integ.json new file mode 100644 index 0000000000000..09c1cc6db76c4 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/integ.json @@ -0,0 +1,17 @@ +{ + "enableLookups": true, + "version": "38.0.1", + "testCases": { + "appsync-domain-name/DefaultTest": { + "stacks": [ + "aws-cdk-appsync-alias-integ" + ], + "regions": [ + "us-east-1" + ], + "stackUpdateWorkflow": false, + "assertionStack": "appsync-domain-name/DefaultTest/DeployAssert", + "assertionStackName": "appsyncdomainnameDefaultTestDeployAssert6D41B82A" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/manifest.json new file mode 100644 index 0000000000000..48429de33a0b7 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/manifest.json @@ -0,0 +1,160 @@ +{ + "version": "38.0.1", + "artifacts": { + "aws-cdk-appsync-alias-integ.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-appsync-alias-integ.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-appsync-alias-integ": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-cdk-appsync-alias-integ.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}/c593cb22174c1c4d68553e7d6feb8961dce6f29331738530e334d3595a58e935.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-appsync-alias-integ.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": [ + "aws-cdk-appsync-alias-integ.assets" + ], + "metadata": { + "/aws-cdk-appsync-alias-integ/api/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "apiC8550315" + } + ], + "/aws-cdk-appsync-alias-integ/api/Schema": [ + { + "type": "aws:cdk:logicalId", + "data": "apiSchema0EA92056" + } + ], + "/aws-cdk-appsync-alias-integ/api/DomainName": [ + { + "type": "aws:cdk:logicalId", + "data": "apiDomainNameBBFE36A4", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] + } + ], + "/aws-cdk-appsync-alias-integ/api/DomainAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "apiDomainAssociation1CF2F52A", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] + } + ], + "/aws-cdk-appsync-alias-integ/api/DefaultApiKey": [ + { + "type": "aws:cdk:logicalId", + "data": "apiDefaultApiKey6AB8D7C4" + } + ], + "/aws-cdk-appsync-alias-integ/Alias/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Alias325C5727", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] + } + ], + "/aws-cdk-appsync-alias-integ/AWSCloudFrontPartitionHostedZoneIdMap": [ + { + "type": "aws:cdk:logicalId", + "data": "AWSCloudFrontPartitionHostedZoneIdMap" + } + ], + "/aws-cdk-appsync-alias-integ/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-appsync-alias-integ/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-appsync-alias-integ" + }, + "appsyncdomainnameDefaultTestDeployAssert6D41B82A.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "appsyncdomainnameDefaultTestDeployAssert6D41B82A.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "appsyncdomainnameDefaultTestDeployAssert6D41B82A": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "appsyncdomainnameDefaultTestDeployAssert6D41B82A.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": [ + "appsyncdomainnameDefaultTestDeployAssert6D41B82A.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": [ + "appsyncdomainnameDefaultTestDeployAssert6D41B82A.assets" + ], + "metadata": { + "/appsync-domain-name/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/appsync-domain-name/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "appsync-domain-name/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-route53-targets/test/integ.appsync-target.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/tree.json new file mode 100644 index 0000000000000..cad511d1aad69 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.js.snapshot/tree.json @@ -0,0 +1,289 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-cdk-appsync-alias-integ": { + "id": "aws-cdk-appsync-alias-integ", + "path": "aws-cdk-appsync-alias-integ", + "children": { + "cert": { + "id": "cert", + "path": "aws-cdk-appsync-alias-integ/cert", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "api": { + "id": "api", + "path": "aws-cdk-appsync-alias-integ/api", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-appsync-alias-integ/api/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::GraphQLApi", + "aws:cdk:cloudformation:props": { + "authenticationType": "API_KEY", + "name": "api" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnGraphQLApi", + "version": "0.0.0" + } + }, + "Schema": { + "id": "Schema", + "path": "aws-cdk-appsync-alias-integ/api/Schema", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::GraphQLSchema", + "aws:cdk:cloudformation:props": { + "apiId": { + "Fn::GetAtt": [ + "apiC8550315", + "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" + } + }, + "DomainName": { + "id": "DomainName", + "path": "aws-cdk-appsync-alias-integ/api/DomainName", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::DomainName", + "aws:cdk:cloudformation:props": { + "certificateArn": "arn:aws:acm:test-region:12345678:certificate/86468209-a272-595d-b831-0efb6421265z", + "description": { + "Fn::Join": [ + "", + [ + "domain for api at ", + { + "Fn::GetAtt": [ + "apiC8550315", + "GraphQLUrl" + ] + } + ] + ] + }, + "domainName": "*.example.com" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnDomainName", + "version": "0.0.0" + } + }, + "DomainAssociation": { + "id": "DomainAssociation", + "path": "aws-cdk-appsync-alias-integ/api/DomainAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::DomainNameApiAssociation", + "aws:cdk:cloudformation:props": { + "apiId": { + "Fn::GetAtt": [ + "apiC8550315", + "ApiId" + ] + }, + "domainName": "*.example.com" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnDomainNameApiAssociation", + "version": "0.0.0" + } + }, + "DefaultApiKey": { + "id": "DefaultApiKey", + "path": "aws-cdk-appsync-alias-integ/api/DefaultApiKey", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppSync::ApiKey", + "aws:cdk:cloudformation:props": { + "apiId": { + "Fn::GetAtt": [ + "apiC8550315", + "ApiId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.CfnApiKey", + "version": "0.0.0" + } + }, + "LogGroup": { + "id": "LogGroup", + "path": "aws-cdk-appsync-alias-integ/api/LogGroup", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_appsync.GraphqlApi", + "version": "0.0.0" + } + }, + "hosted-zone": { + "id": "hosted-zone", + "path": "aws-cdk-appsync-alias-integ/hosted-zone", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Alias": { + "id": "Alias", + "path": "aws-cdk-appsync-alias-integ/Alias", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-appsync-alias-integ/Alias/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Route53::RecordSet", + "aws:cdk:cloudformation:props": { + "aliasTarget": { + "dnsName": { + "Fn::GetAtt": [ + "apiDomainNameBBFE36A4", + "AppSyncDomainName" + ] + }, + "hostedZoneId": { + "Fn::FindInMap": [ + "AWSCloudFrontPartitionHostedZoneIdMap", + { + "Ref": "AWS::Partition" + }, + "zoneId" + ] + } + }, + "hostedZoneId": "Z23ABC4XYZL05B", + "name": "*.example.com.", + "type": "A" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_route53.CfnRecordSet", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_route53.ARecord", + "version": "0.0.0" + } + }, + "AWSCloudFrontPartitionHostedZoneIdMap": { + "id": "AWSCloudFrontPartitionHostedZoneIdMap", + "path": "aws-cdk-appsync-alias-integ/AWSCloudFrontPartitionHostedZoneIdMap", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnMapping", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-appsync-alias-integ/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-appsync-alias-integ/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "appsync-domain-name": { + "id": "appsync-domain-name", + "path": "appsync-domain-name", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "appsync-domain-name/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "appsync-domain-name/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "appsync-domain-name/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "appsync-domain-name/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "appsync-domain-name/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.4.2" + } + } + }, + "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-route53-targets/test/integ.appsync-target.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.ts new file mode 100644 index 0000000000000..a299651f771c0 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53-targets/test/integ.appsync-target.ts @@ -0,0 +1,60 @@ +#!/usr/bin/env node +import * as appsync from 'aws-cdk-lib/aws-appsync'; +import * as acm from 'aws-cdk-lib/aws-certificatemanager'; +import * as route53 from 'aws-cdk-lib/aws-route53'; +import { App, Stack } from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { Construct } from 'constructs'; +import * as targets from 'aws-cdk-lib/aws-route53-targets'; +import { join } from 'path'; + +type TestStackProps = { + certificateArn: string; + domainName: string; + hostedZoneId: string; +} + +class TestStack extends Stack { + constructor(scope: Construct, id: string, props: TestStackProps) { + super(scope, id); + + const { domainName, certificateArn, hostedZoneId } = props; + + const certificate = acm.Certificate.fromCertificateArn(this, 'cert', certificateArn); + + const api = new appsync.GraphqlApi(this, 'api', { + definition: appsync.Definition.fromFile(join(__dirname, '..', '..', 'aws-appsync', 'test', 'appsync.test.graphql')), + domainName: { + certificate, + domainName, + }, + name: 'api', + }); + + const zone = route53.HostedZone.fromHostedZoneAttributes(this, 'hosted-zone', { + zoneName: domainName, + hostedZoneId, + }); + + new route53.ARecord(this, 'Alias', { + zone, + target: route53.RecordTarget.fromAlias(new targets.AppSyncTarget(api)), + }); + } +} + +const certificateArn = process.env.CDK_INTEG_CERT_ARN ?? process.env.CERT_ARN; +if (!certificateArn) throw new Error('For this test you must provide your own CertificateArn as an env var "CERT_ARN". See framework-integ/README.md for details.'); +const domainName = process.env.CDK_INTEG_DOMAIN_NAME ?? process.env.DOMAIN_NAME; +if (!domainName) throw new Error('For this test you must provide your own DomainName as an env var "DOMAIN_NAME". See framework-integ/README.md for details.'); +const hostedZoneId = process.env.CDK_INTEG_HOSTED_ZONE_ID ?? process.env.HOSTED_ZONE_ID; +if (!hostedZoneId) throw new Error('For this test you must provide your own HostedZoneId as an env var "HOSTED_ZONE_ID". See framework-integ/README.md for details.'); + +const app = new App(); +const testCase = new TestStack(app, 'aws-cdk-appsync-alias-integ', { certificateArn, domainName, hostedZoneId }); +new IntegTest(app, 'appsync-domain-name', { + enableLookups: true, + regions: ['us-east-1'], + stackUpdateWorkflow: false, + testCases: [testCase], +}); diff --git a/packages/aws-cdk-lib/aws-route53-targets/README.md b/packages/aws-cdk-lib/aws-route53-targets/README.md index 032fbe1da54b2..b2ccf73d0ccd2 100644 --- a/packages/aws-cdk-lib/aws-route53-targets/README.md +++ b/packages/aws-cdk-lib/aws-route53-targets/README.md @@ -32,6 +32,20 @@ This library contains Route53 Alias Record targets for: }); ``` +* AppSync custom domains + + ```ts + import * as appsync from 'aws-cdk-lib/aws-appsync'; + + declare const zone: route53.HostedZone; + declare const graphqlApi: appsync.GraphqlApi; + + new route53.ARecord(this, 'AliasRecord', { + zone, + target: route53.RecordTarget.fromAlias(new targets.AppSyncTarget(graphqlApi)) + }); + ``` + * CloudFront distributions ```ts diff --git a/packages/aws-cdk-lib/aws-route53-targets/lib/appsync-target.ts b/packages/aws-cdk-lib/aws-route53-targets/lib/appsync-target.ts new file mode 100644 index 0000000000000..ff6582edccade --- /dev/null +++ b/packages/aws-cdk-lib/aws-route53-targets/lib/appsync-target.ts @@ -0,0 +1,23 @@ +import { CloudFrontTarget } from './cloudfront-target'; +import { GraphqlApi } from '../../aws-appsync'; +import { + AliasRecordTargetConfig, + IAliasRecordTarget, + IHostedZone, + IRecordSet, +} from '../../aws-route53'; + +/** + * Defines an AppSync Graphql API as the alias target. Requires that the domain + * name will be defined through `GraphqlApiProps.domainName`. + */ +export class AppSyncTarget implements IAliasRecordTarget { + constructor(private readonly graphqlApi: GraphqlApi) {} + + public bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfig { + return { + dnsName: this.graphqlApi.appSyncDomainName, + hostedZoneId: CloudFrontTarget.getHostedZoneId(this.graphqlApi), + }; + } +} diff --git a/packages/aws-cdk-lib/aws-route53-targets/lib/index.ts b/packages/aws-cdk-lib/aws-route53-targets/lib/index.ts index 714719322b883..e92d2592acc76 100644 --- a/packages/aws-cdk-lib/aws-route53-targets/lib/index.ts +++ b/packages/aws-cdk-lib/aws-route53-targets/lib/index.ts @@ -1,5 +1,6 @@ export * from './api-gateway-domain-name'; export * from './api-gatewayv2-domain-name'; +export * from './appsync-target'; export * from './bucket-website-target'; export * from './elastic-beanstalk-environment-target'; export * from './classic-load-balancer-target'; diff --git a/packages/aws-cdk-lib/aws-route53-targets/test/appsync-target.test.ts b/packages/aws-cdk-lib/aws-route53-targets/test/appsync-target.test.ts new file mode 100644 index 0000000000000..e08a46c51bd13 --- /dev/null +++ b/packages/aws-cdk-lib/aws-route53-targets/test/appsync-target.test.ts @@ -0,0 +1,54 @@ +import { join } from 'path'; +import { Template } from '../../assertions'; +import * as appsync from '../../aws-appsync'; +import * as acm from '../../aws-certificatemanager'; +import * as route53 from '../../aws-route53'; +import { Stack } from '../../core'; +import * as targets from '../lib'; + +test('targets.AppSyncTarget can be used to the default domain of an AppSync GraphqlApi', () => { + // GIVEN + const stack = new Stack(); + const cert = new acm.Certificate(stack, 'cert', { domainName: 'example.com' }); + const api = new appsync.GraphqlApi(stack, 'api', { + definition: appsync.Definition.fromFile(join(__dirname, '..', '..', 'aws-appsync', 'test', 'appsync.test.graphql')), + domainName: { + domainName: 'example.com', + certificate: cert, + }, + name: 'api', + }); + const zone = new route53.HostedZone(stack, 'zone', { + zoneName: 'example.com', + }); + + // WHEN + new route53.ARecord(stack, 'A', { + zone, + target: route53.RecordTarget.fromAlias(new targets.AppSyncTarget(api)), + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Route53::RecordSet', { + Name: 'example.com.', + Type: 'A', + AliasTarget: { + DNSName: { + 'Fn::GetAtt': [ + 'apiDomainNameBBFE36A4', + 'AppSyncDomainName', + ], + }, + HostedZoneId: { + 'Fn::FindInMap': [ + 'AWSCloudFrontPartitionHostedZoneIdMap', + { Ref: 'AWS::Partition' }, + 'zoneId', + ], + }, + }, + HostedZoneId: { + Ref: 'zoneEB40FF1E', + }, + }); +});