Skip to content

Commit dac9b8a

Browse files
Ichigo97438Ichigo97438bryantbiggs
authored
feat: Add timeouts block for vpc origin resource (#165)
Co-authored-by: Ichigo97438 <[email protected]> Co-authored-by: Bryant Biggs <[email protected]>
1 parent d66669f commit dac9b8a

File tree

8 files changed

+38
-29
lines changed

8 files changed

+38
-29
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.96.2
3+
rev: v1.99.4
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ No modules.
164164
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no |
165165
| <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 |
166166
| <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/> }))</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/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Note that this example may create resources which cost money. Run `terraform des
2727

2828
| Name | Version |
2929
|------|---------|
30-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
30+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
3131
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.83 |
3232
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
3333
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
@@ -46,11 +46,11 @@ Note that this example may create resources which cost money. Run `terraform des
4646
|------|--------|---------|
4747
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | ~> 4.0 |
4848
| <a name="module_cloudfront"></a> [cloudfront](#module\_cloudfront) | ../../ | n/a |
49-
| <a name="module_ec2"></a> [ec2](#module\_ec2) | terraform-aws-modules/ec2-instance/aws | ~> 5.0 |
50-
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 7.0 |
51-
| <a name="module_log_bucket"></a> [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 4.0 |
52-
| <a name="module_records"></a> [records](#module\_records) | terraform-aws-modules/route53/aws//modules/records | ~> 2.0 |
53-
| <a name="module_s3_one"></a> [s3\_one](#module\_s3\_one) | terraform-aws-modules/s3-bucket/aws | ~> 4.0 |
49+
| <a name="module_ec2"></a> [ec2](#module\_ec2) | terraform-aws-modules/ec2-instance/aws | ~> 6.0 |
50+
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 8.0 |
51+
| <a name="module_log_bucket"></a> [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
52+
| <a name="module_records"></a> [records](#module\_records) | terraform-aws-modules/route53/aws//modules/records | ~> 5.0 |
53+
| <a name="module_s3_one"></a> [s3\_one](#module\_s3\_one) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
5454

5555
## Resources
5656

@@ -60,7 +60,6 @@ Note that this example may create resources which cost money. Run `terraform des
6060
| [aws_s3_bucket_policy.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
6161
| [null_resource.download_package](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
6262
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
63-
| [aws_ami.al2023](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
6463
| [aws_canonical_user_id.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |
6564
| [aws_cloudfront_log_delivery_canonical_user_id.cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_log_delivery_canonical_user_id) | data source |
6665
| [aws_iam_policy_document.s3_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

examples/complete/main.tf

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ module "cloudfront" {
6868
}
6969
}
7070

71+
vpc_origin_timeouts = {
72+
create = "20m"
73+
update = "20m"
74+
delete = "20m"
75+
}
76+
7177
logging_config = {
7278
bucket = module.log_bucket.s3_bucket_bucket_domain_name
7379
prefix = "cloudfront"
@@ -253,17 +259,17 @@ data "aws_cloudfront_log_delivery_canonical_user_id" "cloudfront" {}
253259

254260
module "s3_one" {
255261
source = "terraform-aws-modules/s3-bucket/aws"
256-
version = "~> 4.0"
262+
version = "~> 5.0"
257263

258-
bucket = "s3-one-${random_pet.this.id}"
264+
bucket_prefix = "s3-one-"
259265
force_destroy = true
260266
}
261267

262268
module "log_bucket" {
263269
source = "terraform-aws-modules/s3-bucket/aws"
264-
version = "~> 4.0"
270+
version = "~> 5.0"
265271

266-
bucket = "logs-${random_pet.this.id}"
272+
bucket_prefix = "logs-"
267273

268274
control_object_ownership = true
269275
object_ownership = "ObjectWriter"
@@ -287,7 +293,7 @@ module "log_bucket" {
287293
#############################################
288294

289295
locals {
290-
package_url = "https://raw.githubusercontent.com/terraform-aws-modules/terraform-aws-lambda/master/examples/fixtures/python3.8-zip/existing_package.zip"
296+
package_url = "https://raw.githubusercontent.com/terraform-aws-modules/terraform-aws-lambda/master/examples/fixtures/python-zip/existing_package.zip"
291297
downloaded = "downloaded_package_${md5(local.package_url)}.zip"
292298
}
293299

@@ -303,12 +309,12 @@ resource "null_resource" "download_package" {
303309

304310
module "lambda_function" {
305311
source = "terraform-aws-modules/lambda/aws"
306-
version = "~> 7.0"
312+
version = "~> 8.0"
307313

308314
function_name = "${random_pet.this.id}-lambda"
309315
description = "My awesome lambda function"
310316
handler = "index.lambda_handler"
311-
runtime = "python3.8"
317+
runtime = "python3.11"
312318

313319
publish = true
314320
lambda_at_edge = true
@@ -332,7 +338,7 @@ module "lambda_function" {
332338

333339
module "records" {
334340
source = "terraform-aws-modules/route53/aws//modules/records"
335-
version = "~> 2.0"
341+
version = "~> 5.0"
336342

337343
zone_id = data.aws_route53_zone.this.zone_id
338344

@@ -401,21 +407,11 @@ resource "aws_cloudfront_function" "example" {
401407
# EC2 instance for CloudFront VPC origin
402408
#########################################
403409

404-
data "aws_ami" "al2023" {
405-
most_recent = true
406-
owners = ["amazon"]
407-
408-
filter {
409-
name = "name"
410-
values = ["al2023-ami-2023*-x86_64"]
411-
}
412-
}
413-
414410
module "ec2" {
415411
source = "terraform-aws-modules/ec2-instance/aws"
416-
version = "~> 5.0"
412+
version = "~> 6.0"
417413

418-
ami = data.aws_ami.al2023.id
414+
name = "ec2-vpc-origin-${random_pet.this.id}"
419415
}
420416

421417
########

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.0"
2+
required_version = ">= 1.5.7"
33

44
required_providers {
55
aws = {

main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ resource "aws_cloudfront_vpc_origin" "this" {
4141
}
4242
}
4343

44+
timeouts {
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)
48+
}
49+
4450
tags = var.tags
4551
}
4652

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,9 @@ variable "vpc_origin" {
203203
}))
204204
default = {}
205205
}
206+
207+
variable "vpc_origin_timeouts" {
208+
description = "Create, update, and delete timeout configurations for vpc origin"
209+
type = map(string)
210+
default = {}
211+
}

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)