From 13542893bc2d8b5b89e11df429310dbe212a697b Mon Sep 17 00:00:00 2001
From: Frank <639906+syphernl@users.noreply.github.com>
Date: Tue, 17 Jan 2023 16:14:40 +0100
Subject: [PATCH] feat: add http_version variable (#256)
* feat: add http_version variable
* Auto Format
Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
---
README.md | 3 ++-
docs/terraform.md | 1 +
main.tf | 1 +
variables.tf | 6 ++++++
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 54043a0e..ff208b03 100644
--- a/README.md
+++ b/README.md
@@ -534,6 +534,7 @@ Available targets:
| [function\_association](#input\_function\_association) | A config block that triggers a CloudFront function with specific actions.
See the [aws\_cloudfront\_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#function-association)
documentation for more information. |
list(object({
event_type = string
function_arn = string
}))
| `[]` | no |
| [geo\_restriction\_locations](#input\_geo\_restriction\_locations) | List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist) | `list(string)` | `[]` | no |
| [geo\_restriction\_type](#input\_geo\_restriction\_type) | Method that use to restrict distribution of your content by country: `none`, `whitelist`, or `blacklist` | `string` | `"none"` | no |
+| [http\_version](#input\_http\_version) | The maximum HTTP version to support on the distribution. Allowed values are http1.1, http2, http2and3 and http3 | `string` | `"http2"` | no |
| [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no |
| [index\_document](#input\_index\_document) | Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders | `string` | `"index.html"` | no |
| [ipv6\_enabled](#input\_ipv6\_enabled) | Set to true to enable an AAAA DNS record to be set as well as the A record | `bool` | `true` | no |
@@ -700,7 +701,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
## Copyright
-Copyright © 2017-2022 [Cloud Posse, LLC](https://cpco.io/copyright)
+Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright)
diff --git a/docs/terraform.md b/docs/terraform.md
index 794bb23a..3b47c9a3 100644
--- a/docs/terraform.md
+++ b/docs/terraform.md
@@ -102,6 +102,7 @@
| [function\_association](#input\_function\_association) | A config block that triggers a CloudFront function with specific actions.
See the [aws\_cloudfront\_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#function-association)
documentation for more information. | list(object({
event_type = string
function_arn = string
}))
| `[]` | no |
| [geo\_restriction\_locations](#input\_geo\_restriction\_locations) | List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist) | `list(string)` | `[]` | no |
| [geo\_restriction\_type](#input\_geo\_restriction\_type) | Method that use to restrict distribution of your content by country: `none`, `whitelist`, or `blacklist` | `string` | `"none"` | no |
+| [http\_version](#input\_http\_version) | The maximum HTTP version to support on the distribution. Allowed values are http1.1, http2, http2and3 and http3 | `string` | `"http2"` | no |
| [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no |
| [index\_document](#input\_index\_document) | Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders | `string` | `"index.html"` | no |
| [ipv6\_enabled](#input\_ipv6\_enabled) | Set to true to enable an AAAA DNS record to be set as well as the A record | `bool` | `true` | no |
diff --git a/main.tf b/main.tf
index 77ca6401..a946fc0b 100644
--- a/main.tf
+++ b/main.tf
@@ -377,6 +377,7 @@ resource "aws_cloudfront_distribution" "default" {
default_root_object = var.default_root_object
price_class = var.price_class
depends_on = [aws_s3_bucket.origin]
+ http_version = var.http_version
dynamic "logging_config" {
for_each = local.cloudfront_access_logging_enabled ? ["true"] : []
diff --git a/variables.tf b/variables.tf
index a2f2044e..f68e3480 100644
--- a/variables.tf
+++ b/variables.tf
@@ -674,3 +674,9 @@ variable "origin_shield_enabled" {
default = false
description = "If enabled, origin shield will be enabled for the default origin"
}
+
+variable "http_version" {
+ type = string
+ default = "http2"
+ description = "The maximum HTTP version to support on the distribution. Allowed values are http1.1, http2, http2and3 and http3"
+}
\ No newline at end of file