Skip to content

Commit ecc91c3

Browse files
committed
feat(origin-access-control): support aws v6
1 parent 3c54fb5 commit ecc91c3

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

modules/origin-access-control/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ This module creates following resources.
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
13-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.19 |
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.12 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.20 |
1414

1515
## Providers
1616

1717
| Name | Version |
1818
|------|---------|
19-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.26.0 |
19+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.24.0 |
2020

2121
## Modules
2222

@@ -33,14 +33,15 @@ No modules.
3333
| Name | Description | Type | Default | Required |
3434
|------|-------------|------|---------|:--------:|
3535
| <a name="input_name"></a> [name](#input\_name) | (Required) A name to identify the origin access control. | `string` | n/a | yes |
36+
| <a name="input_origin_type"></a> [origin\_type](#input\_origin\_type) | (Required) The type of origin that this origin access control is for. Valid values are `LAMBDA`, `MEDIAPACKAGE_V2`, `MEDIASTORE` and `S3`. | `string` | n/a | yes |
3637
| <a name="input_description"></a> [description](#input\_description) | (Optional) A description of the origin access control. | `string` | `"Managed by Terraform."` | no |
37-
| <a name="input_origin_type"></a> [origin\_type](#input\_origin\_type) | (Optional) The type of origin that this origin access control is for. Valid values are `S3` and `MEDIASTORE`. Defaults to `S3`. | `string` | `"S3"` | no |
38-
| <a name="input_signing_behavior"></a> [signing\_behavior](#input\_signing\_behavior) | (Optional) Specify which requests CloudFront signs (adds authentication information to). Valid values are `ALWAYS`, `NEVER`, `NO_OVERRIDE`. Defaults to `ALWAYS`.<br> `ALWAYS` - CloudFront signs all origin requests, overwriting the `Authorization` header from the viewer request if one exists.<br> `NEVER` - CloudFront doesn't sign any origin requests. This value turns off origin access control for all origins in all distributions that use this origin access control.<br> `NO_OVERRIDE` - If the viewer request doesn't contain the `Authorization` header, then CloudFront signs the origin request. If the viewer request contains the Authorization header, then CloudFront doesn't sign the origin request and instead passes along the Authorization header from the viewer request. | `string` | `"ALWAYS"` | no |
38+
| <a name="input_signing_behavior"></a> [signing\_behavior](#input\_signing\_behavior) | (Optional) Specify which requests CloudFront signs (adds authentication information to). Valid values are `ALWAYS`, `NEVER`, `NO_OVERRIDE`. Defaults to `ALWAYS`.<br/> `ALWAYS` - CloudFront signs all origin requests, overwriting the `Authorization` header from the viewer request if one exists.<br/> `NEVER` - CloudFront doesn't sign any origin requests. This value turns off origin access control for all origins in all distributions that use this origin access control.<br/> `NO_OVERRIDE` - If the viewer request doesn't contain the `Authorization` header, then CloudFront signs the origin request. If the viewer request contains the Authorization header, then CloudFront doesn't sign the origin request and instead passes along the Authorization header from the viewer request. | `string` | `"ALWAYS"` | no |
3939

4040
## Outputs
4141

4242
| Name | Description |
4343
|------|-------------|
44+
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the origin access control. |
4445
| <a name="output_description"></a> [description](#output\_description) | The description of the origin access control. |
4546
| <a name="output_etag"></a> [etag](#output\_etag) | The current version of the origin access control. |
4647
| <a name="output_id"></a> [id](#output\_id) | The ID of the origin access control. |

modules/origin-access-control/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ locals {
1313
"NEVER" = "never"
1414
"NO_OVERRIDE" = "no-override"
1515
}
16+
origin_types = {
17+
"LAMBDA" = "lambda"
18+
"MEDIAPACKAGE_V2" = "mediapackagev2"
19+
"MEDIASTORE" = "mediastore"
20+
"S3" = "s3"
21+
}
1622
}
1723

1824

@@ -24,7 +30,7 @@ resource "aws_cloudfront_origin_access_control" "this" {
2430
name = var.name
2531
description = var.description
2632

27-
origin_access_control_origin_type = lower(var.origin_type)
33+
origin_access_control_origin_type = local.origin_types[var.origin_type]
2834
signing_behavior = local.signing_behaviors[var.signing_behavior]
2935
signing_protocol = "sigv4"
3036
}

modules/origin-access-control/outputs.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
output "arn" {
2+
description = "The ARN of the origin access control."
3+
value = aws_cloudfront_origin_access_control.this.arn
4+
}
5+
16
output "id" {
27
description = "The ID of the origin access control."
38
value = aws_cloudfront_origin_access_control.this.id
@@ -20,7 +25,10 @@ output "description" {
2025

2126
output "origin_type" {
2227
description = "The type of origin that this origin access control is for."
23-
value = upper(aws_cloudfront_origin_access_control.this.origin_access_control_origin_type)
28+
value = {
29+
for k, v in local.origin_types :
30+
v => k
31+
}[aws_cloudfront_origin_access_control.this.origin_access_control_origin_type]
2432
}
2533

2634
output "signing_behavior" {

modules/origin-access-control/variables.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ variable "description" {
1212
}
1313

1414
variable "origin_type" {
15-
description = "(Optional) The type of origin that this origin access control is for. Valid values are `S3` and `MEDIASTORE`. Defaults to `S3`."
15+
description = "(Required) The type of origin that this origin access control is for. Valid values are `LAMBDA`, `MEDIAPACKAGE_V2`, `MEDIASTORE` and `S3`."
1616
type = string
17-
default = "S3"
1817
nullable = false
1918

2019
validation {
21-
condition = contains(["S3", "MEDIASTORE"], var.origin_type)
22-
error_message = "Valid values for `origin_type` are `S3` and `MEDIASTORE`."
20+
condition = contains(["LAMBDA", "MEDIAPACKAGE_V2", "MEDIASTORE", "S3"], var.origin_type)
21+
error_message = "Valid values for `origin_type` are `LAMBDA`, `MEDIAPACKAGE_V2`, `MEDIASTORE` and `S3`."
2322
}
2423
}
2524

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.6"
2+
required_version = ">= 1.12"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.19"
7+
version = ">= 6.20"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)