Skip to content

Commit fefae11

Browse files
author
Ichigo97438
committed
refactor: set vpc origin timeouts as variable
1 parent 965c8ca commit fefae11

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,17 @@ No modules.
154154
| <a name="input_logging_config"></a> [logging\_config](#input\_logging\_config) | The logging configuration that controls how logs are written to your distribution (maximum one). | `any` | `{}` | no |
155155
| <a name="input_ordered_cache_behavior"></a> [ordered\_cache\_behavior](#input\_ordered\_cache\_behavior) | An ordered list of cache behaviors resource for this distribution. List from top to bottom in order of precedence. The topmost cache behavior will have precedence 0. | `any` | `[]` | no |
156156
| <a name="input_origin"></a> [origin](#input\_origin) | One or more origins for this distribution (multiples allowed). | `any` | `null` | no |
157-
| <a name="input_origin_access_control"></a> [origin\_access\_control](#input\_origin\_access\_control) | Map of CloudFront origin access control | <pre>map(object({<br/> description = string<br/> origin_type = string<br/> signing_behavior = string<br/> signing_protocol = string<br/> }))</pre> | <pre>{<br/> "s3": {<br/> "description": "",<br/> "origin_type": "s3",<br/> "signing_behavior": "always",<br/> "signing_protocol": "sigv4"<br/> }<br/>}</pre> | no |
157+
| <a name="input_origin_access_control"></a> [origin\_access\_control](#input\_origin\_access\_control) | Map of CloudFront origin access control | <pre>map(object({<br> description = string<br> origin_type = string<br> signing_behavior = string<br> signing_protocol = string<br> }))</pre> | <pre>{<br> "s3": {<br> "description": "",<br> "origin_type": "s3",<br> "signing_behavior": "always",<br> "signing_protocol": "sigv4"<br> }<br>}</pre> | no |
158158
| <a name="input_origin_access_identities"></a> [origin\_access\_identities](#input\_origin\_access\_identities) | Map of CloudFront origin access identities (value as a comment) | `map(string)` | `{}` | no |
159159
| <a name="input_origin_group"></a> [origin\_group](#input\_origin\_group) | One or more origin\_group for this distribution (multiples allowed). | `any` | `{}` | no |
160160
| <a name="input_price_class"></a> [price\_class](#input\_price\_class) | The price class for this distribution. One of PriceClass\_All, PriceClass\_200, PriceClass\_100 | `string` | `null` | no |
161161
| <a name="input_realtime_metrics_subscription_status"></a> [realtime\_metrics\_subscription\_status](#input\_realtime\_metrics\_subscription\_status) | A flag that indicates whether additional CloudWatch metrics are enabled for a given CloudFront distribution. Valid values are `Enabled` and `Disabled`. | `string` | `"Enabled"` | no |
162162
| <a name="input_retain_on_delete"></a> [retain\_on\_delete](#input\_retain\_on\_delete) | Disables the distribution instead of deleting it when destroying the resource through Terraform. If this is set, the distribution needs to be deleted manually afterwards. | `bool` | `false` | no |
163163
| <a name="input_staging"></a> [staging](#input\_staging) | Whether the distribution is a staging distribution. | `bool` | `false` | no |
164164
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no |
165-
| <a name="input_viewer_certificate"></a> [viewer\_certificate](#input\_viewer\_certificate) | The SSL configuration for this distribution | `any` | <pre>{<br/> "cloudfront_default_certificate": true,<br/> "minimum_protocol_version": "TLSv1"<br/>}</pre> | no |
166-
| <a name="input_vpc_origin"></a> [vpc\_origin](#input\_vpc\_origin) | Map of CloudFront VPC origin | <pre>map(object({<br/> name = string<br/> arn = string<br/> http_port = number<br/> https_port = number<br/> origin_protocol_policy = string<br/> origin_ssl_protocols = object({<br/> items = list(string)<br/> quantity = number<br/> })<br/> timeouts = optional(object({<br/> create = optional(string)<br/> update = optional(string)<br/> delete = optional(string)<br/> }))<br/> }))</pre> | `{}` | no |
165+
| <a name="input_viewer_certificate"></a> [viewer\_certificate](#input\_viewer\_certificate) | The SSL configuration for this distribution | `any` | <pre>{<br> "cloudfront_default_certificate": true,<br> "minimum_protocol_version": "TLSv1"<br>}</pre> | no |
166+
| <a name="input_vpc_origin"></a> [vpc\_origin](#input\_vpc\_origin) | Map of CloudFront VPC origin | <pre>map(object({<br> name = string<br> arn = string<br> http_port = number<br> https_port = number<br> origin_protocol_policy = string<br> origin_ssl_protocols = object({<br> items = list(string)<br> quantity = number<br> })<br> timeouts = optional(object({<br> create = optional(string)<br> update = optional(string)<br> delete = optional(string)<br> }))<br> }))</pre> | `{}` | no |
167+
| <a name="input_vpc_origin_timeouts"></a> [vpc\_origin\_timeouts](#input\_vpc\_origin\_timeouts) | Create, update, and delete timeout configurations for vpc origin | `map(string)` | `{}` | no |
167168
| <a name="input_wait_for_deployment"></a> [wait\_for\_deployment](#input\_wait\_for\_deployment) | If enabled, the resource will wait for the distribution status to change from InProgress to Deployed. Setting this to false will skip the process. | `bool` | `true` | no |
168169
| <a name="input_web_acl_id"></a> [web\_acl\_id](#input\_web\_acl\_id) | If you're using AWS WAF to filter CloudFront requests, the Id of the AWS WAF web ACL that is associated with the distribution. The WAF Web ACL must exist in the WAF Global (CloudFront) region and the credentials configuring this argument must have waf:GetWebACL permissions assigned. If using WAFv2, provide the ARN of the web ACL. | `string` | `null` | no |
169170

examples/complete/main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ module "cloudfront" {
6565
items = ["TLSv1.2"]
6666
quantity = 1
6767
}
68-
timeouts = {
69-
create = "20m"
70-
update = "20m"
71-
destroy = "20m"
72-
}
7368
}
7469
}
7570

71+
vpc_origin_timeouts = {
72+
create = "20m"
73+
update = "20m"
74+
delete = "20m"
75+
}
76+
7677
logging_config = {
7778
bucket = module.log_bucket.s3_bucket_bucket_domain_name
7879
prefix = "cloudfront"

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ resource "aws_cloudfront_vpc_origin" "this" {
4242
}
4343

4444
timeouts {
45-
create = each.value.timeouts.create
46-
update = each.value.timeouts.update
47-
delete = each.value.timeouts.delete
45+
create = try(var.vpc_origin_timeouts.create, null)
46+
update = try(var.vpc_origin_timeouts.update, null)
47+
delete = try(var.vpc_origin_timeouts.delete, null)
4848
}
4949

5050
tags = var.tags

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,9 @@ variable "vpc_origin" {
208208
}))
209209
default = {}
210210
}
211+
212+
variable "vpc_origin_timeouts" {
213+
description = "Create, update, and delete timeout configurations for vpc origin"
214+
type = map(string)
215+
default = {}
216+
}

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module "wrapper" {
4141
minimum_protocol_version = "TLSv1"
4242
})
4343
vpc_origin = try(each.value.vpc_origin, var.defaults.vpc_origin, {})
44+
vpc_origin_timeouts = try(each.value.vpc_origin_timeouts, var.defaults.vpc_origin_timeouts, {})
4445
wait_for_deployment = try(each.value.wait_for_deployment, var.defaults.wait_for_deployment, true)
4546
web_acl_id = try(each.value.web_acl_id, var.defaults.web_acl_id, null)
4647
}

0 commit comments

Comments
 (0)