Skip to content

Commit f782e37

Browse files
Merge pull request #5 from TechHoldingLLC/feat/origin_request_policy
Origin Request Policy
2 parents 3d4ed2a + 53a5c1f commit f782e37

3 files changed

Lines changed: 35 additions & 14 deletions

File tree

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
| Name | Version |
44
|------|---------|
5-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0.0 |
5+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
66

77
## Providers
88

99
| Name | Version |
1010
|------|---------|
11-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.0.0 |
11+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
1212

1313
## Modules
1414

@@ -25,7 +25,7 @@ No modules.
2525

2626
| Name | Description | Type | Default | Required |
2727
|------|-------------|------|---------|:--------:|
28-
| <a name="input_acm_arn"></a> [acm\_arn](#input\_acm\_arn) | ACM cert arn | `string` | n/a | no |
28+
| <a name="input_acm_arn"></a> [acm\_arn](#input\_acm\_arn) | ACM cert arn | `string` | `""` | no |
2929
| <a name="input_allowed_methods"></a> [allowed\_methods](#input\_allowed\_methods) | Allowed methods | `list(any)` | <pre>[<br> "GET",<br> "HEAD"<br>]</pre> | no |
3030
| <a name="input_cache_policy_id"></a> [cache\_policy\_id](#input\_cache\_policy\_id) | AWS managed cache policy id | `string` | `""` | no |
3131
| <a name="input_cached_methods"></a> [cached\_methods](#input\_cached\_methods) | Cached methods | `list(any)` | <pre>[<br> "GET",<br> "HEAD"<br>]</pre> | no |
@@ -40,13 +40,21 @@ No modules.
4040
| <a name="input_lambda_function_association"></a> [lambda\_function\_association](#input\_lambda\_function\_association) | Lambda edge association | `list(any)` | `[]` | no |
4141
| <a name="input_logging_config"></a> [logging\_config](#input\_logging\_config) | Cloudfront logging config | `map(any)` | `{}` | no |
4242
| <a name="input_origin"></a> [origin](#input\_origin) | Origin configuration | `any` | n/a | yes |
43+
| <a name="input_origin_request_policy_id"></a> [origin\_request\_policy\_id](#input\_origin\_request\_policy\_id) | Unique identifier of the origin request policy that is attached to the behavior | `string` | `""` | no |
4344
| <a name="input_route53_zone_id"></a> [route53\_zone\_id](#input\_route53\_zone\_id) | Route53 zone id | `string` | `""` | no |
45+
| <a name="input_ttl_values"></a> [ttl\_values](#input\_ttl\_values) | map of ttl variables | `map(any)` | `{}` | no |
4446
| <a name="input_web_acl_id"></a> [web\_acl\_id](#input\_web\_acl\_id) | WAF web ACL id | `string` | `""` | no |
45-
| <a name="input_ttl_values"></a> [ttl\_values](#input\_ttl\_values) | ttl values | `map` | {} | no |
4647

4748
## Outputs
4849

4950
| Name | Description |
5051
|------|-------------|
51-
| <a name="output_cloudfront_arn"></a> [cloudfront\_arn](#output\_cloudfront\_arn) | n/a |
52-
| <a name="output_cloudfront_id"></a> [cloudfront\_id](#output\_cloudfront\_id) | n/a |
52+
| <a name="output_aliases"></a> [aliases](#output\_aliases) | n/a |
53+
| <a name="output_arn"></a> [arn](#output\_arn) | n/a |
54+
| <a name="output_domain_name"></a> [domain\_name](#output\_domain\_name) | n/a |
55+
| <a name="output_hosted_zone_id"></a> [hosted\_zone\_id](#output\_hosted\_zone\_id) | n/a |
56+
| <a name="output_id"></a> [id](#output\_id) | n/a |
57+
58+
## License
59+
60+
Apache 2 Licensed. See [LICENSE](https://github.com/TechHoldingLLC/terraform-aws-cloudfront/blob/main/LICENSE) for full details.

cloudfront.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,17 @@ resource "aws_cloudfront_distribution" "cloudfront" {
5353
default_root_object = var.default_root_object
5454

5555
default_cache_behavior {
56-
allowed_methods = var.allowed_methods
57-
cached_methods = var.cached_methods
58-
target_origin_id = var.origin["origin_id"]
59-
cache_policy_id = var.cache_policy_id
56+
allowed_methods = var.allowed_methods
57+
cached_methods = var.cached_methods
58+
target_origin_id = var.origin["origin_id"]
59+
cache_policy_id = var.cache_policy_id
60+
origin_request_policy_id = var.origin_request_policy_id
6061

61-
viewer_protocol_policy = "redirect-to-https"
62+
viewer_protocol_policy = var.viewer_protocol_policy
6263
compress = true
63-
min_ttl = lookup(var.ttl_values,"min_ttl",0)
64-
max_ttl = lookup(var.ttl_values,"max_ttl",86400)
65-
default_ttl = lookup(var.ttl_values,"default_ttl",3600)
64+
min_ttl = lookup(var.ttl_values, "min_ttl", 0)
65+
max_ttl = lookup(var.ttl_values, "max_ttl", 86400)
66+
default_ttl = lookup(var.ttl_values, "default_ttl", 3600)
6667

6768
dynamic "forwarded_values" {
6869
for_each = var.cache_policy_id != "" ? [] : [1]

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,16 @@ variable "ttl_values" {
102102
description = "map of ttl variables"
103103
type = map(any)
104104
default = {}
105+
}
106+
107+
variable "origin_request_policy_id" {
108+
description = "Unique identifier of the origin request policy that is attached to the behavior"
109+
type = string
110+
default = ""
111+
}
112+
113+
variable "viewer_protocol_policy" {
114+
description = "the protocol that users can use to access the files in the origin, valid values are allow-all, https-only, or redirect-to-https."
115+
type = string
116+
default = "redirect-to-https"
105117
}

0 commit comments

Comments
 (0)