Skip to content

Commit

Permalink
feat(cloudfront): create distributions with HTTP/3 (#21613)
Browse files Browse the repository at this point in the history
This adds support for CloudFront distributions that use HTTP/3.

News post: https://aws.amazon.com/about-aws/whats-new/2022/08/amazon-cloudfront-supports-http-3-quic/
CloudFormation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-distributionconfig.html#cfn-cloudfront-distribution-distributionconfig-httpversion

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
laurelmay authored Aug 16, 2022
1 parent e48cf15 commit 58101a6
Show file tree
Hide file tree
Showing 12 changed files with 549 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,20 @@ new cloudfront.Distribution(this, 'myDist', {
});
```

### HTTP Versions

You can configure CloudFront to use a particular version of the HTTP protocol. By default,
newly created distributions use HTTP/2 but can be configured to use both HTTP/2 and HTTP/3 or
just HTTP/3. For all supported HTTP versions, see the `HttpVerson` enum.

```ts
// Configure a distribution to use HTTP/2 and HTTP/3
new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: { origin: new origins.HttpOrigin('www.example.com'); },
httpVersion: cloudfront.HttpVersion.HTTP2_AND_3,
});
```

### Importing Distributions

Existing distributions can be imported as well; note that like most imported constructs, an imported distribution cannot be modified.
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,11 @@ export enum HttpVersion {
/** HTTP 1.1 */
HTTP1_1 = 'http1.1',
/** HTTP 2 */
HTTP2 = 'http2'
HTTP2 = 'http2',
/** HTTP 2 and HTTP 3 */
HTTP2_AND_3 = 'http2and3',
/** HTTP 3 */
HTTP3 = 'http3'
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"devDependencies": {
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"20.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"Resources": {
"Http118E669F5D": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "integdistributionhttpversionHttp11Origin117833241",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": true,
"HttpVersion": "http1.1",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
},
"DomainName": "www.example.com",
"Id": "integdistributionhttpversionHttp11Origin117833241"
}
]
}
}
},
"Http25ED2A59B": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "integdistributionhttpversionHttp2Origin15C0A1B66",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": true,
"HttpVersion": "http2",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
},
"DomainName": "www.example.com",
"Id": "integdistributionhttpversionHttp2Origin15C0A1B66"
}
]
}
}
},
"Http2and3D987DA75": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "integdistributionhttpversionHttp2and3Origin1487BBB15",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": true,
"HttpVersion": "http2and3",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
},
"DomainName": "www.example.com",
"Id": "integdistributionhttpversionHttp2and3Origin1487BBB15"
}
]
}
}
},
"Http31D566096": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "integdistributionhttpversionHttp3Origin10970C9C4",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": true,
"HttpVersion": "http3",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
},
"DomainName": "www.example.com",
"Id": "integdistributionhttpversionHttp3Origin10970C9C4"
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "20.0.0",
"testCases": {
"DistributionHttpVersion/DefaultTest": {
"stacks": [
"integ-distribution-http-version"
],
"assertionStack": "DistributionHttpVersionDefaultTestDeployAssert506965CB"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"version": "20.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"integ-distribution-http-version": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "integ-distribution-http-version.template.json",
"validateOnSynth": false
},
"metadata": {
"/integ-distribution-http-version/Http11/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "Http118E669F5D"
}
],
"/integ-distribution-http-version/Http2/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "Http25ED2A59B"
}
],
"/integ-distribution-http-version/Http2and3/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "Http2and3D987DA75"
}
],
"/integ-distribution-http-version/Http3/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "Http31D566096"
}
]
},
"displayName": "integ-distribution-http-version"
},
"DistributionHttpVersionDefaultTestDeployAssert506965CB": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "DistributionHttpVersionDefaultTestDeployAssert506965CB.template.json",
"validateOnSynth": false
},
"displayName": "DistributionHttpVersion/DefaultTest/DeployAssert"
}
}
}
Loading

0 comments on commit 58101a6

Please sign in to comment.