From 9d8e92f5d199933c35ab0d02f7a2cad4e93e3085 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:46:38 +0900 Subject: [PATCH 01/23] feat(cloudfront): support gRPC for distribution --- packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 8 ++++++++ .../aws-cloudfront/lib/private/cache-behavior.ts | 3 +++ 2 files changed, 11 insertions(+) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 35f081faafc6b..1785b65fa4432 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -1068,6 +1068,14 @@ export interface AddBehaviorOptions { * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html */ readonly trustedKeyGroups?: IKeyGroup[]; + + /** + * Enables your CloudFront distribution to receive gRPC requests and to proxy them directly to your origins. + * + * @default false + * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-using-grpc.html + */ + readonly enableGrpc?: boolean; } /** diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index b4a7e8bd4c483..43987b2c98457 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -47,6 +47,9 @@ export class CacheBehavior { cachedMethods: this.props.cachedMethods?.methods, cachePolicyId: (this.props.cachePolicy ?? CachePolicy.CACHING_OPTIMIZED).cachePolicyId, compress: this.props.compress ?? true, + grpcConfig: { + enabled: this.props.enableGrpc, + }, originRequestPolicyId: this.props.originRequestPolicy?.originRequestPolicyId, realtimeLogConfigArn: this.props?.realtimeLogConfig?.realtimeLogConfigArn, responseHeadersPolicyId: this.props.responseHeadersPolicy?.responseHeadersPolicyId, From 00a200357504ed122dd5d85ece89958541ff2a74 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:01:30 +0900 Subject: [PATCH 02/23] unit test --- .../aws-cloudfront/lib/private/cache-behavior.ts | 6 +++--- .../aws-cloudfront/test/private/cache-behavior.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index 43987b2c98457..4596b6792e5a1 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -47,9 +47,6 @@ export class CacheBehavior { cachedMethods: this.props.cachedMethods?.methods, cachePolicyId: (this.props.cachePolicy ?? CachePolicy.CACHING_OPTIMIZED).cachePolicyId, compress: this.props.compress ?? true, - grpcConfig: { - enabled: this.props.enableGrpc, - }, originRequestPolicyId: this.props.originRequestPolicy?.originRequestPolicyId, realtimeLogConfigArn: this.props?.realtimeLogConfig?.realtimeLogConfigArn, responseHeadersPolicyId: this.props.responseHeadersPolicy?.responseHeadersPolicyId, @@ -65,6 +62,9 @@ export class CacheBehavior { includeBody: edgeLambda.includeBody, })), trustedKeyGroups: this.props.trustedKeyGroups?.map(keyGroup => keyGroup.keyGroupId), + grpcConfig: { + enabled: this.props.enableGrpc, + }, }; } diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index 71741d3e838e7..fdecac30d031b 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -62,6 +62,7 @@ test('renders with all properties specified', () => { functionVersion: fnVersion, }], trustedKeyGroups: [keyGroup], + enableGrpc: true, }); expect(behavior._renderBehavior()).toEqual({ @@ -82,6 +83,9 @@ test('renders with all properties specified', () => { trustedKeyGroups: [ keyGroup.keyGroupId, ], + grpcConfig: { + enabled: true, + }, }); }); From 633ac50eff3d06f6e0efe26fa4bacfa8946911c1 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:20:51 +0900 Subject: [PATCH 03/23] README --- packages/aws-cdk-lib/aws-cloudfront/README.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/aws-cdk-lib/aws-cloudfront/README.md b/packages/aws-cdk-lib/aws-cloudfront/README.md index 07c37adb03cf9..28294119833d6 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/README.md +++ b/packages/aws-cdk-lib/aws-cloudfront/README.md @@ -792,6 +792,28 @@ new cloudfront.Distribution(this, 'myCdn', { }); ``` +### gRPC + +CloudFront supports gRPC, an open-source remote procedure call (RPC) framework built on HTTP/2. gRPC offers bi-directional streaming and +binary protocol that buffers payloads, making it suitable for applications that require low latency communications. + +To enable your distribution to handle gRPC requests, you must include HTTP/2 as one of the supported HTTP versions and allow HTTP methods, +including POST. + +See [Using gRPC with CloudFront distributions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-using-grpc.html) +in the CloudFront User Guide. + +Example: + +```ts +new cloudfront.Distribution(this, 'myCdn', { + defaultBehavior: { + origin: new origins.HttpOrigin('www.example.com'), + enableGrpc: true, + }, +}); +``` + ## Migrating from the original CloudFrontWebDistribution to the newer Distribution construct It's possible to migrate a distribution from the original to the modern API. From e736d8f74f884b17e1849104a3f0588ae063429d Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:25:59 +0900 Subject: [PATCH 04/23] integ without snapshots --- .../test/integ.distribution-grpc.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts new file mode 100644 index 0000000000000..b6c39ff290283 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts @@ -0,0 +1,22 @@ +import * as cdk from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { TestOrigin } from './test-origin'; +import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'integ-distribution-grpc'); + +const origin = new TestOrigin('www.example.com'); + +const distribution = new cloudfront.Distribution(stack, 'TestDistribution', { + defaultBehavior: { + origin, + enableGrpc: true, + }, +}); +distribution.addBehavior('/second', origin); +distribution.addBehavior('/third', origin); + +new IntegTest(app, 'DistributionGrpc', { + testCases: [stack], +}); From dca03fe86fa7d751001fe63cb4ec505a726cc50f Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:33:13 +0900 Subject: [PATCH 05/23] fix code and add tests --- .../lib/private/cache-behavior.ts | 8 +++++--- .../test/private/cache-behavior.test.ts | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index 4596b6792e5a1..80531ff086584 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -62,9 +62,11 @@ export class CacheBehavior { includeBody: edgeLambda.includeBody, })), trustedKeyGroups: this.props.trustedKeyGroups?.map(keyGroup => keyGroup.keyGroupId), - grpcConfig: { - enabled: this.props.enableGrpc, - }, + grpcConfig: this.props.enableGrpc !== undefined + ? { + enabled: this.props.enableGrpc, + } + : undefined, }; } diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index fdecac30d031b..259a88e922a16 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -101,3 +101,23 @@ test('throws if edgeLambda includeBody is set for wrong event type', () => { }], })).toThrow(/'includeBody' can only be true for ORIGIN_REQUEST or VIEWER_REQUEST event types./); }); + +test.each([true, false, undefined])('enableGrpc is %s', (enableGrpc) => { + const behavior = new CacheBehavior('origin_id', { + pathPattern: '*', + enableGrpc, + }); + + expect(behavior._renderBehavior()).toEqual({ + targetOriginId: 'origin_id', + cachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6', + compress: true, + pathPattern: '*', + viewerProtocolPolicy: 'allow-all', + grpcConfig: enableGrpc !== undefined + ? { + enabled: enableGrpc, + } + : undefined, + }); +}); From e2288f79712e6e05f52fb54abd5fe3b04a4ef2f0 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:34:59 +0900 Subject: [PATCH 06/23] default label --- packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 7a79ff4dab609..36e462b77ab57 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -1086,7 +1086,7 @@ export interface AddBehaviorOptions { /** * Enables your CloudFront distribution to receive gRPC requests and to proxy them directly to your origins. * - * @default false + * @default - gRPC will be disabled * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-using-grpc.html */ readonly enableGrpc?: boolean; From a018a4f22e11fd64f3d054921b434edde102776d Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:18:58 +0900 Subject: [PATCH 07/23] snapshots --- ...efaultTestDeployAssertE740300C.assets.json | 19 ++ ...aultTestDeployAssertE740300C.template.json | 36 ++++ .../cdk.out | 1 + .../integ-distribution-grpc.assets.json | 19 ++ .../integ-distribution-grpc.template.json | 91 +++++++++ .../integ.json | 12 ++ .../manifest.json | 113 +++++++++++ .../tree.json | 181 ++++++++++++++++++ .../test/integ.distribution-grpc.ts | 1 + 9 files changed, 473 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/tree.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.assets.json new file mode 100644 index 0000000000000..6fa597d223ea8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "DistributionGrpcDefaultTestDeployAssertE740300C.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-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/DistributionGrpcDefaultTestDeployAssertE740300C.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-cloudfront/test/integ.distribution-grpc.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.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-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.assets.json new file mode 100644 index 0000000000000..5356bef4c69b9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "e92efb368ead4669dc674d1d7d93a51366b7ca4d9527f3521f8f4c890fd96824": { + "source": { + "path": "integ-distribution-grpc.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "e92efb368ead4669dc674d1d7d93a51366b7ca4d9527f3521f8f4c890fd96824.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-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.template.json new file mode 100644 index 0000000000000..ca5d14c0bcf54 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ-distribution-grpc.template.json @@ -0,0 +1,91 @@ +{ + "Resources": { + "TestDistribution94EC811C": { + "Type": "AWS::CloudFront::Distribution", + "Properties": { + "DistributionConfig": { + "CacheBehaviors": [ + { + "CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", + "Compress": true, + "PathPattern": "/second", + "TargetOriginId": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "ViewerProtocolPolicy": "allow-all" + }, + { + "CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", + "Compress": true, + "PathPattern": "/third", + "TargetOriginId": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "ViewerProtocolPolicy": "allow-all" + } + ], + "DefaultCacheBehavior": { + "AllowedMethods": [ + "GET", + "HEAD", + "OPTIONS", + "PUT", + "PATCH", + "POST", + "DELETE" + ], + "CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", + "Compress": true, + "GrpcConfig": { + "Enabled": true + }, + "TargetOriginId": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "ViewerProtocolPolicy": "allow-all" + }, + "Enabled": true, + "HttpVersion": "http2", + "IPV6Enabled": true, + "Origins": [ + { + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only" + }, + "DomainName": "www.example.com", + "Id": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4" + } + ] + } + } + } + }, + "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-cloudfront/test/integ.distribution-grpc.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ.json new file mode 100644 index 0000000000000..416c058187293 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "DistributionGrpc/DefaultTest": { + "stacks": [ + "integ-distribution-grpc" + ], + "assertionStack": "DistributionGrpc/DefaultTest/DeployAssert", + "assertionStackName": "DistributionGrpcDefaultTestDeployAssertE740300C" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/manifest.json new file mode 100644 index 0000000000000..5adc0ae7e0e13 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/manifest.json @@ -0,0 +1,113 @@ +{ + "version": "38.0.1", + "artifacts": { + "integ-distribution-grpc.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-distribution-grpc.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-distribution-grpc": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integ-distribution-grpc.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "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}/e92efb368ead4669dc674d1d7d93a51366b7ca4d9527f3521f8f4c890fd96824.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-distribution-grpc.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": [ + "integ-distribution-grpc.assets" + ], + "metadata": { + "/integ-distribution-grpc/TestDistribution/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TestDistribution94EC811C" + } + ], + "/integ-distribution-grpc/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-distribution-grpc/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-distribution-grpc" + }, + "DistributionGrpcDefaultTestDeployAssertE740300C.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "DistributionGrpcDefaultTestDeployAssertE740300C.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "DistributionGrpcDefaultTestDeployAssertE740300C": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "DistributionGrpcDefaultTestDeployAssertE740300C.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "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": [ + "DistributionGrpcDefaultTestDeployAssertE740300C.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": [ + "DistributionGrpcDefaultTestDeployAssertE740300C.assets" + ], + "metadata": { + "/DistributionGrpc/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/DistributionGrpc/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "DistributionGrpc/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-cloudfront/test/integ.distribution-grpc.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/tree.json new file mode 100644 index 0000000000000..45da45df27be9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.js.snapshot/tree.json @@ -0,0 +1,181 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-distribution-grpc": { + "id": "integ-distribution-grpc", + "path": "integ-distribution-grpc", + "children": { + "TestDistribution": { + "id": "TestDistribution", + "path": "integ-distribution-grpc/TestDistribution", + "children": { + "Origin1": { + "id": "Origin1", + "path": "integ-distribution-grpc/TestDistribution/Origin1", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-distribution-grpc/TestDistribution/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Distribution", + "aws:cdk:cloudformation:props": { + "distributionConfig": { + "enabled": true, + "origins": [ + { + "domainName": "www.example.com", + "id": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "customOriginConfig": { + "originProtocolPolicy": "https-only" + } + } + ], + "defaultCacheBehavior": { + "pathPattern": "*", + "targetOriginId": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "allowedMethods": [ + "GET", + "HEAD", + "OPTIONS", + "PUT", + "PATCH", + "POST", + "DELETE" + ], + "cachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", + "compress": true, + "viewerProtocolPolicy": "allow-all", + "grpcConfig": { + "enabled": true + } + }, + "cacheBehaviors": [ + { + "pathPattern": "/second", + "targetOriginId": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "cachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", + "compress": true, + "viewerProtocolPolicy": "allow-all" + }, + { + "pathPattern": "/third", + "targetOriginId": "integdistributiongrpcTestDistributionOrigin1C4AE5CE4", + "cachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", + "compress": true, + "viewerProtocolPolicy": "allow-all" + } + ], + "httpVersion": "http2", + "ipv6Enabled": true + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-distribution-grpc/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-distribution-grpc/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DistributionGrpc": { + "id": "DistributionGrpc", + "path": "DistributionGrpc", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "DistributionGrpc/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "DistributionGrpc/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "DistributionGrpc/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "DistributionGrpc/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "DistributionGrpc/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "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": "constructs.Construct", + "version": "10.4.2" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts index b6c39ff290283..9c8b89503a894 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-grpc.ts @@ -11,6 +11,7 @@ const origin = new TestOrigin('www.example.com'); const distribution = new cloudfront.Distribution(stack, 'TestDistribution', { defaultBehavior: { origin, + allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL, enableGrpc: true, }, }); From 05a803f5eefdeba7aa0a6aac48bf1ae9b042ed21 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:33:02 +0900 Subject: [PATCH 08/23] add validation --- .../aws-cloudfront/lib/distribution.ts | 3 ++ .../lib/private/cache-behavior.ts | 6 ++- .../test/private/cache-behavior.test.ts | 48 ++++++++++++------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 36e462b77ab57..d85bb423c11f9 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -1086,6 +1086,9 @@ export interface AddBehaviorOptions { /** * Enables your CloudFront distribution to receive gRPC requests and to proxy them directly to your origins. * + * You must specify `AllowedMethods.ALLOW_ALL` including POST method to `allowedMethods` property if you set + * `enableGrpc` to true because gRPC only supports POST method. + * * @default - gRPC will be disabled * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-using-grpc.html */ diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index 80531ff086584..ab0ec5619e97d 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -1,7 +1,7 @@ import * as iam from '../../../aws-iam'; import { CachePolicy } from '../cache-policy'; import { CfnDistribution } from '../cloudfront.generated'; -import { AddBehaviorOptions, EdgeLambda, LambdaEdgeEventType, ViewerProtocolPolicy } from '../distribution'; +import { AddBehaviorOptions, AllowedMethods, EdgeLambda, LambdaEdgeEventType, ViewerProtocolPolicy } from '../distribution'; /** * Properties for specifying custom behaviors for origins. @@ -27,6 +27,10 @@ export class CacheBehavior { constructor(originId: string, private readonly props: CacheBehaviorProps) { this.originId = originId; + if (props.enableGrpc && props.allowedMethods !== AllowedMethods.ALLOW_ALL) { + throw new Error(`'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true, got: ${props.allowedMethods?.methods}`); + } + this.validateEdgeLambdas(props.edgeLambdas); this.grantEdgeLambdaFunctionExecutionRole(props.edgeLambdas); } diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index 259a88e922a16..c20f847baf1df 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -102,22 +102,38 @@ test('throws if edgeLambda includeBody is set for wrong event type', () => { })).toThrow(/'includeBody' can only be true for ORIGIN_REQUEST or VIEWER_REQUEST event types./); }); -test.each([true, false, undefined])('enableGrpc is %s', (enableGrpc) => { - const behavior = new CacheBehavior('origin_id', { - pathPattern: '*', - enableGrpc, +describe('gRPC config', () => { + test.each([true, false, undefined])('enableGrpc is %s', (enableGrpc) => { + const behavior = new CacheBehavior('origin_id', { + pathPattern: '*', + allowedMethods: AllowedMethods.ALLOW_ALL, + enableGrpc, + }); + + expect(behavior._renderBehavior()).toEqual({ + targetOriginId: 'origin_id', + cachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6', + compress: true, + pathPattern: '*', + allowedMethods: ['GET', 'HEAD', 'OPTIONS', 'PUT', 'PATCH', 'POST', 'DELETE'], + viewerProtocolPolicy: 'allow-all', + grpcConfig: enableGrpc !== undefined + ? { + enabled: enableGrpc, + } + : undefined, + }); }); - expect(behavior._renderBehavior()).toEqual({ - targetOriginId: 'origin_id', - cachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6', - compress: true, - pathPattern: '*', - viewerProtocolPolicy: 'allow-all', - grpcConfig: enableGrpc !== undefined - ? { - enabled: enableGrpc, - } - : undefined, + test.each([ + [AllowedMethods.ALLOW_GET_HEAD, ['GET', 'HEAD']], + [AllowedMethods.ALLOW_GET_HEAD_OPTIONS, ['GET', 'HEAD', 'OPTIONS']], + [undefined, undefined], + ])('throws if allowedMethods is not ALLOW_GET_HEAD but %s and enableGrpc is true', (allowedMethods, methods) => { + expect(() => new CacheBehavior('origin_id', { + pathPattern: '*', + allowedMethods, + enableGrpc: true, + })).toThrow(`'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true, got: ${methods?.join(',')}`); }); -}); +}); \ No newline at end of file From b29265c0008bbb7204cceb7ac13065e19edd1bfc Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:35:15 +0900 Subject: [PATCH 09/23] typo in tests --- .../aws-cloudfront/test/private/cache-behavior.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index c20f847baf1df..c2178e7be692b 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -129,7 +129,7 @@ describe('gRPC config', () => { [AllowedMethods.ALLOW_GET_HEAD, ['GET', 'HEAD']], [AllowedMethods.ALLOW_GET_HEAD_OPTIONS, ['GET', 'HEAD', 'OPTIONS']], [undefined, undefined], - ])('throws if allowedMethods is not ALLOW_GET_HEAD but %s and enableGrpc is true', (allowedMethods, methods) => { + ])('throws if allowedMethods is not ALLOW_ALL but %s and enableGrpc is true', (allowedMethods, methods) => { expect(() => new CacheBehavior('origin_id', { pathPattern: '*', allowedMethods, From 1321702557b2e2f7299dee475392b58c89ece85d Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:39:31 +0900 Subject: [PATCH 10/23] improve --- .../aws-cloudfront/lib/private/cache-behavior.ts | 2 +- .../aws-cloudfront/test/private/cache-behavior.test.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index ab0ec5619e97d..819ddd494f0c1 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -28,7 +28,7 @@ export class CacheBehavior { this.originId = originId; if (props.enableGrpc && props.allowedMethods !== AllowedMethods.ALLOW_ALL) { - throw new Error(`'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true, got: ${props.allowedMethods?.methods}`); + throw new Error('\'allowedMethods\' can only be AllowedMethods.ALLOW_ALL if you set \'enableGrpc\' to true'); } this.validateEdgeLambdas(props.edgeLambdas); diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index c2178e7be692b..730d2eeac485f 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -126,14 +126,14 @@ describe('gRPC config', () => { }); test.each([ - [AllowedMethods.ALLOW_GET_HEAD, ['GET', 'HEAD']], - [AllowedMethods.ALLOW_GET_HEAD_OPTIONS, ['GET', 'HEAD', 'OPTIONS']], - [undefined, undefined], - ])('throws if allowedMethods is not ALLOW_ALL but %s and enableGrpc is true', (allowedMethods, methods) => { + AllowedMethods.ALLOW_GET_HEAD, + AllowedMethods.ALLOW_GET_HEAD_OPTIONS, + undefined, + ])('throws if allowedMethods is not ALLOW_ALL but %s and enableGrpc is true', (allowedMethods) => { expect(() => new CacheBehavior('origin_id', { pathPattern: '*', allowedMethods, enableGrpc: true, - })).toThrow(`'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true, got: ${methods?.join(',')}`); + })).toThrow(/'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true/); }); }); \ No newline at end of file From c965edd89d7bd94494fd4db99b68ae034e4811d3 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:51:16 +0900 Subject: [PATCH 11/23] change README --- packages/aws-cdk-lib/aws-cloudfront/README.md | 1 + .../aws-cloudfront/test/private/cache-behavior.test.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/README.md b/packages/aws-cdk-lib/aws-cloudfront/README.md index 28294119833d6..879c1e74ef19c 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/README.md +++ b/packages/aws-cdk-lib/aws-cloudfront/README.md @@ -809,6 +809,7 @@ Example: new cloudfront.Distribution(this, 'myCdn', { defaultBehavior: { origin: new origins.HttpOrigin('www.example.com'), + allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL, // `AllowedMethods.ALLOW_ALL` is required if specifying `enableGrpc` enableGrpc: true, }, }); diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index 730d2eeac485f..073932082fd8b 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -136,4 +136,4 @@ describe('gRPC config', () => { enableGrpc: true, })).toThrow(/'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true/); }); -}); \ No newline at end of file +}); From 85bb175eae783befd7e3168c14534395179862b4 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:52:06 +0900 Subject: [PATCH 12/23] fix doc --- packages/aws-cdk-lib/aws-cloudfront/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/README.md b/packages/aws-cdk-lib/aws-cloudfront/README.md index 879c1e74ef19c..e00f8e152b2cd 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/README.md +++ b/packages/aws-cdk-lib/aws-cloudfront/README.md @@ -809,7 +809,7 @@ Example: new cloudfront.Distribution(this, 'myCdn', { defaultBehavior: { origin: new origins.HttpOrigin('www.example.com'), - allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL, // `AllowedMethods.ALLOW_ALL` is required if specifying `enableGrpc` + allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL, // `AllowedMethods.ALLOW_ALL` is required if `enableGrpc` is true enableGrpc: true, }, }); From adc904b866f1291f42003877d25c9347c6402387 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:54:06 +0900 Subject: [PATCH 13/23] change error msg --- .../aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts | 2 +- .../aws-cloudfront/test/private/cache-behavior.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index 819ddd494f0c1..f24ae03f7e8d9 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -28,7 +28,7 @@ export class CacheBehavior { this.originId = originId; if (props.enableGrpc && props.allowedMethods !== AllowedMethods.ALLOW_ALL) { - throw new Error('\'allowedMethods\' can only be AllowedMethods.ALLOW_ALL if you set \'enableGrpc\' to true'); + throw new Error('\'allowedMethods\' can only be AllowedMethods.ALLOW_ALL if \'enableGrpc\' is true'); } this.validateEdgeLambdas(props.edgeLambdas); diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index 073932082fd8b..fc243dc6eaa9e 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -134,6 +134,6 @@ describe('gRPC config', () => { pathPattern: '*', allowedMethods, enableGrpc: true, - })).toThrow(/'allowedMethods' can only be AllowedMethods.ALLOW_ALL if you set 'enableGrpc' to true/); + })).toThrow(/'allowedMethods' can only be AllowedMethods.ALLOW_ALL if 'enableGrpc' is true/); }); }); From 0d61b26d454eee4eac516dcca6079745163ee822 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:42:43 +0900 Subject: [PATCH 14/23] change default label --- packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index d85bb423c11f9..82c55370a3b6f 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -1089,7 +1089,7 @@ export interface AddBehaviorOptions { * You must specify `AllowedMethods.ALLOW_ALL` including POST method to `allowedMethods` property if you set * `enableGrpc` to true because gRPC only supports POST method. * - * @default - gRPC will be disabled + * @default false * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-using-grpc.html */ readonly enableGrpc?: boolean; From 7b78244437179da08ebb950f8f57ed096ac7ecc8 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:24:39 +0900 Subject: [PATCH 15/23] validation for http2 --- .../aws-cloudfront/lib/distribution.ts | 17 +++++++++++++++-- .../lib/private/cache-behavior.ts | 8 +++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 82c55370a3b6f..ee876208cccc2 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -314,6 +314,7 @@ export class Distribution extends Resource implements IDistribution { public readonly distributionDomainName: string; public readonly distributionId: string; + private readonly httpVersion: HttpVersion; private readonly defaultBehavior: CacheBehavior; private readonly additionalBehaviors: CacheBehavior[] = []; private readonly boundOrigins: BoundOrigin[] = []; @@ -346,6 +347,8 @@ export class Distribution extends Resource implements IDistribution { }); } + this.validateHttpVersion(this.defaultBehavior); + if (props.webAclId) { this.validateWebAclId(props.webAclId); this.webAclId = props.webAclId; @@ -354,6 +357,7 @@ export class Distribution extends Resource implements IDistribution { this.certificate = props.certificate; this.errorResponses = props.errorResponses ?? []; this.publishAdditionalMetrics = props.publishAdditionalMetrics; + this.httpVersion = props.httpVersion ?? HttpVersion.HTTP2; // Comments have an undocumented limit of 128 characters const trimmedComment = @@ -372,7 +376,7 @@ export class Distribution extends Resource implements IDistribution { comment: trimmedComment, customErrorResponses: this.renderErrorResponses(), defaultRootObject: props.defaultRootObject, - httpVersion: props.httpVersion ?? HttpVersion.HTTP2, + httpVersion: this.httpVersion, ipv6Enabled: props.enableIpv6 ?? true, logging: this.renderLogging(props), priceClass: props.priceClass ?? undefined, @@ -724,7 +728,10 @@ export class Distribution extends Resource implements IDistribution { private renderCacheBehaviors(): CfnDistribution.CacheBehaviorProperty[] | undefined { if (this.additionalBehaviors.length === 0) { return undefined; } - return this.additionalBehaviors.map(behavior => behavior._renderBehavior()); + return this.additionalBehaviors.map(behavior => { + this.validateHttpVersion(behavior); + return behavior._renderBehavior() + }); } private renderErrorResponses(): CfnDistribution.CustomErrorResponseProperty[] | undefined { @@ -787,6 +794,12 @@ export class Distribution extends Resource implements IDistribution { sslSupportMethod: sslSupportMethod, }; } + + private validateHttpVersion(cacheBehavior: CacheBehavior) { + if (cacheBehavior.grpcEnabled && ![HttpVersion.HTTP2, HttpVersion.HTTP2_AND_3].includes(this.httpVersion)) { + throw new Error(`'httpVersion' must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${this.httpVersion}`); + } + } } /** Maximum HTTP version to support */ diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index f24ae03f7e8d9..0e024ac07b3d2 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -22,12 +22,14 @@ export interface CacheBehaviorProps extends AddBehaviorOptions { * CloudFrontWebDistribution implementation. */ export class CacheBehavior { + public readonly grpcEnabled?: boolean; private readonly originId: string; constructor(originId: string, private readonly props: CacheBehaviorProps) { this.originId = originId; + this.grpcEnabled = props.enableGrpc; - if (props.enableGrpc && props.allowedMethods !== AllowedMethods.ALLOW_ALL) { + if (this.grpcEnabled && props.allowedMethods !== AllowedMethods.ALLOW_ALL) { throw new Error('\'allowedMethods\' can only be AllowedMethods.ALLOW_ALL if \'enableGrpc\' is true'); } @@ -66,9 +68,9 @@ export class CacheBehavior { includeBody: edgeLambda.includeBody, })), trustedKeyGroups: this.props.trustedKeyGroups?.map(keyGroup => keyGroup.keyGroupId), - grpcConfig: this.props.enableGrpc !== undefined + grpcConfig: this.grpcEnabled !== undefined ? { - enabled: this.props.enableGrpc, + enabled: this.grpcEnabled, } : undefined, }; From 0d703a9fd3dc3187539bccf893437a1d91f7deb0 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:26:19 +0900 Subject: [PATCH 16/23] validation for edgeLambdas --- .../aws-cloudfront/lib/private/cache-behavior.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts index 0e024ac07b3d2..c197e359748bb 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/private/cache-behavior.ts @@ -29,8 +29,13 @@ export class CacheBehavior { this.originId = originId; this.grpcEnabled = props.enableGrpc; - if (this.grpcEnabled && props.allowedMethods !== AllowedMethods.ALLOW_ALL) { - throw new Error('\'allowedMethods\' can only be AllowedMethods.ALLOW_ALL if \'enableGrpc\' is true'); + if (this.grpcEnabled) { + if (props.allowedMethods !== AllowedMethods.ALLOW_ALL) { + throw new Error('\'allowedMethods\' can only be AllowedMethods.ALLOW_ALL if \'enableGrpc\' is true'); + } + if (props.edgeLambdas !== undefined && props.edgeLambdas.length > 0) { + throw new Error('\'edgeLambdas\' cannot be specified if \'enableGrpc\' is true'); + } } this.validateEdgeLambdas(props.edgeLambdas); From 3b4c1f586490b01a033163c1f89a31e3aa537715 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:45:02 +0900 Subject: [PATCH 17/23] validation for errorResponses and change method name to validateGrpc --- .../aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index ee876208cccc2..1eace4877d8ee 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -347,7 +347,7 @@ export class Distribution extends Resource implements IDistribution { }); } - this.validateHttpVersion(this.defaultBehavior); + this.validateGrpc(this.defaultBehavior); if (props.webAclId) { this.validateWebAclId(props.webAclId); @@ -729,7 +729,7 @@ export class Distribution extends Resource implements IDistribution { private renderCacheBehaviors(): CfnDistribution.CacheBehaviorProperty[] | undefined { if (this.additionalBehaviors.length === 0) { return undefined; } return this.additionalBehaviors.map(behavior => { - this.validateHttpVersion(behavior); + this.validateGrpc(behavior); return behavior._renderBehavior() }); } @@ -795,10 +795,16 @@ export class Distribution extends Resource implements IDistribution { }; } - private validateHttpVersion(cacheBehavior: CacheBehavior) { - if (cacheBehavior.grpcEnabled && ![HttpVersion.HTTP2, HttpVersion.HTTP2_AND_3].includes(this.httpVersion)) { + private validateGrpc(cacheBehavior: CacheBehavior) { + if (!cacheBehavior.grpcEnabled) { + return; + } + if (![HttpVersion.HTTP2, HttpVersion.HTTP2_AND_3].includes(this.httpVersion)) { throw new Error(`'httpVersion' must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${this.httpVersion}`); } + if (this.errorResponses.length > 0) { + throw new Error(`'errorResponses' cannot be specified if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${this.httpVersion}`); + } } } From 60d00d57ecfc1e3d20a95576c327a8964373f668 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:13:38 +0900 Subject: [PATCH 18/23] rm errorResponse validation --- packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 1eace4877d8ee..19c0a465f8f63 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -347,8 +347,6 @@ export class Distribution extends Resource implements IDistribution { }); } - this.validateGrpc(this.defaultBehavior); - if (props.webAclId) { this.validateWebAclId(props.webAclId); this.webAclId = props.webAclId; @@ -359,6 +357,8 @@ export class Distribution extends Resource implements IDistribution { this.publishAdditionalMetrics = props.publishAdditionalMetrics; this.httpVersion = props.httpVersion ?? HttpVersion.HTTP2; + this.validateGrpc(this.defaultBehavior); + // Comments have an undocumented limit of 128 characters const trimmedComment = props.comment && props.comment.length > 128 @@ -802,9 +802,6 @@ export class Distribution extends Resource implements IDistribution { if (![HttpVersion.HTTP2, HttpVersion.HTTP2_AND_3].includes(this.httpVersion)) { throw new Error(`'httpVersion' must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${this.httpVersion}`); } - if (this.errorResponses.length > 0) { - throw new Error(`'errorResponses' cannot be specified if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${this.httpVersion}`); - } } } From e8be128dd35e9b87c1d4065949c2a57e6b154a45 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:20:59 +0900 Subject: [PATCH 19/23] semi-colon in distribution --- packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 19c0a465f8f63..3dafc0a1219cc 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -730,7 +730,7 @@ export class Distribution extends Resource implements IDistribution { if (this.additionalBehaviors.length === 0) { return undefined; } return this.additionalBehaviors.map(behavior => { this.validateGrpc(behavior); - return behavior._renderBehavior() + return behavior._renderBehavior(); }); } From a67b2af2118d61681a34527036cde83284c8dfcb Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:34:20 +0900 Subject: [PATCH 20/23] jsdoc for validations --- packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts index 3dafc0a1219cc..a8e4989ea6db7 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts @@ -1102,8 +1102,10 @@ export interface AddBehaviorOptions { /** * Enables your CloudFront distribution to receive gRPC requests and to proxy them directly to your origins. * - * You must specify `AllowedMethods.ALLOW_ALL` including POST method to `allowedMethods` property if you set - * `enableGrpc` to true because gRPC only supports POST method. + * If the `enableGrpc` is set to true, the following restrictions apply: + * - The `allowedMethods` property must be `AllowedMethods.ALLOW_ALL` to include POST method because gRPC only supports POST method. + * - The `httpVersion` property must be `HttpVersion.HTTP2` or `HttpVersion.HTTP2_AND_3` because gRPC only supports versions including HTTP/2. + * - The `edgeLambdas` property can't be specified because gRPC is not supported with Lambda@Edge. * * @default false * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-using-grpc.html From 4bfe1cc99e44b1a1f9a2f0753f5dcf67d6178b21 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:56:15 +0900 Subject: [PATCH 21/23] unit test for edgeLambda --- .../test/private/cache-behavior.test.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index fc243dc6eaa9e..e51a1246e0400 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -62,7 +62,6 @@ test('renders with all properties specified', () => { functionVersion: fnVersion, }], trustedKeyGroups: [keyGroup], - enableGrpc: true, }); expect(behavior._renderBehavior()).toEqual({ @@ -83,9 +82,6 @@ test('renders with all properties specified', () => { trustedKeyGroups: [ keyGroup.keyGroupId, ], - grpcConfig: { - enabled: true, - }, }); }); @@ -136,4 +132,18 @@ describe('gRPC config', () => { enableGrpc: true, })).toThrow(/'allowedMethods' can only be AllowedMethods.ALLOW_ALL if 'enableGrpc' is true/); }); + + test('throws if edgeLambda is set and enableGrpc is true', () => { + const fnVersion = lambda.Version.fromVersionArn(stack, 'Version', 'arn:aws:lambda:testregion:111111111111:function:myTestFun:v1'); + + expect(() => new CacheBehavior('origin_id', { + pathPattern: '*', + allowedMethods: AllowedMethods.ALLOW_ALL, + enableGrpc: true, + edgeLambdas: [{ + eventType: LambdaEdgeEventType.ORIGIN_RESPONSE, + functionVersion: fnVersion, + }], + })).toThrow(/'edgeLambdas' cannot be specified if 'enableGrpc' is true/); + }); }); From 83893e0aea1f35193fa3258814b6506c9f4783cc Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:03:07 +0900 Subject: [PATCH 22/23] unit tests for httpVersion --- .../aws-cloudfront/test/distribution.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts index 927ba5861b368..9f770599d0927 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts @@ -8,6 +8,7 @@ import * as lambda from '../../aws-lambda'; import * as s3 from '../../aws-s3'; import { App, Aws, Duration, Stack } from '../../core'; import { + AllowedMethods, CfnDistribution, Distribution, Endpoint, @@ -1432,5 +1433,25 @@ describe('attachWebAclId', () => { }).toThrow(/WebACL for CloudFront distributions must be created in the us-east-1 region; received ap-northeast-1/); }); }); +}); + +describe('gRPC', () => { + test.each([ + HttpVersion.HTTP1_1, + HttpVersion.HTTP3, + ])('throws if httpVersion is %s and enableGrpc is true', (httpVersion) => { + const origin = defaultOrigin(); + const msg = `'httpVersion' must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${httpVersion}`; + expect(() => { + new Distribution(stack, 'MyDist', { + httpVersion, + defaultBehavior: { + origin, + enableGrpc: true, + allowedMethods: AllowedMethods.ALLOW_ALL, + }, + }); + }).toThrow(msg); + }); }); From 9d2391b6df8a7a5297faedf14aa67c65623d860e Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:57:47 +0900 Subject: [PATCH 23/23] unit tests for additionalBehaviors --- .../aws-cloudfront/test/distribution.test.ts | 34 ++++++++++++++++++- .../test/private/cache-behavior.test.ts | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts index 9f770599d0927..011d314d1108e 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts @@ -1439,7 +1439,7 @@ describe('gRPC', () => { test.each([ HttpVersion.HTTP1_1, HttpVersion.HTTP3, - ])('throws if httpVersion is %s and enableGrpc is true', (httpVersion) => { + ])('throws if httpVersion is %s and enableGrpc in defaultBehavior is true', (httpVersion) => { const origin = defaultOrigin(); const msg = `'httpVersion' must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${httpVersion}`; @@ -1454,4 +1454,36 @@ describe('gRPC', () => { }); }).toThrow(msg); }); + + test.each([ + HttpVersion.HTTP1_1, + HttpVersion.HTTP3, + ])('throws if httpVersion is %s and enableGrpc in additionalBehaviors is true', (httpVersion) => { + const origin = defaultOrigin(); + const msg = `'httpVersion' must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 if 'enableGrpc' in 'defaultBehavior' or 'additionalBehaviors' is true, got ${httpVersion}`; + new Distribution(stack, 'MyDist', { + httpVersion, + defaultBehavior: { + origin, + enableGrpc: false, + allowedMethods: AllowedMethods.ALLOW_ALL, + }, + additionalBehaviors: { + '/second': { + origin, + enableGrpc: false, + allowedMethods: AllowedMethods.ALLOW_ALL, + }, + '/third': { + origin, + enableGrpc: true, + allowedMethods: AllowedMethods.ALLOW_ALL, + }, + }, + }); + + expect(() => { + app.synth(); + }).toThrow(msg); + }); }); diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts index e51a1246e0400..76ce9f08b66c6 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/private/cache-behavior.test.ts @@ -98,7 +98,7 @@ test('throws if edgeLambda includeBody is set for wrong event type', () => { })).toThrow(/'includeBody' can only be true for ORIGIN_REQUEST or VIEWER_REQUEST event types./); }); -describe('gRPC config', () => { +describe('gRPC', () => { test.each([true, false, undefined])('enableGrpc is %s', (enableGrpc) => { const behavior = new CacheBehavior('origin_id', { pathPattern: '*',