Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ module "cdn" {
}
}]
origin_groups = [{
group_id = "groupS3"
primary_origin_id = null # will get translated to the origin id of the origin created by this module.
failover_origin_id = module.s3_bucket.bucket_id
failover_criteria = [
Expand Down Expand Up @@ -525,7 +526,7 @@ module "cdn" {
| <a name="input_origin_access_type"></a> [origin\_access\_type](#input\_origin\_access\_type) | Choose to use `origin_access_control` or `orgin_access_identity` | `string` | `"origin_access_identity"` | no |
| <a name="input_origin_bucket"></a> [origin\_bucket](#input\_origin\_bucket) | Name of an existing S3 bucket to use as the origin. If this is not provided, it will create a new s3 bucket using `var.name` and other context related inputs | `string` | `null` | no |
| <a name="input_origin_force_destroy"></a> [origin\_force\_destroy](#input\_origin\_force\_destroy) | Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`) | `bool` | `false` | no |
| <a name="input_origin_groups"></a> [origin\_groups](#input\_origin\_groups) | List of [Origin Groups](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#origin-group-arguments) to create in the distribution.<br/>The values of `primary_origin_id` and `failover_origin_id` must correspond to origin IDs existing in `var.s3_origins` or `var.custom_origins`.<br/><br/>If `primary_origin_id` is set to `null` or `""`, then the origin id of the origin created by this module will be used in its place.<br/>This is to allow for the use case of making the origin created by this module the primary origin in an origin group. | <pre>list(object({<br/> primary_origin_id = string<br/> failover_origin_id = string<br/> failover_criteria = list(string)<br/> }))</pre> | `[]` | no |
| <a name="input_origin_groups"></a> [origin\_groups](#input\_origin\_groups) | List of [Origin Groups](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#origin-group-arguments) to create in the distribution.<br/>The values of `primary_origin_id` and `failover_origin_id` must correspond to origin IDs existing in `var.s3_origins` or `var.custom_origins`.<br/><br/>If `primary_origin_id` is set to `null` or `""`, then the origin id of the origin created by this module will be used in its place.<br/>This is to allow for the use case of making the origin created by this module the primary origin in an origin group. | <pre>list(object({<br/> group_id = optional(string)<br/> primary_origin_id = string<br/> failover_origin_id = string<br/> failover_criteria = list(string)<br/> }))</pre> | `[]` | no |
| <a name="input_origin_keepalive_timeout"></a> [origin\_keepalive\_timeout](#input\_origin\_keepalive\_timeout) | The Custom KeepAlive timeout, in seconds. By default, AWS enforces a limit of 60. But you can request an increase. | `number` | `5` | no |
| <a name="input_origin_path"></a> [origin\_path](#input\_origin\_path) | An optional element that causes CloudFront to request your content from a directory in your Amazon S3 bucket or your custom origin. It must begin with a /. Do not add a / at the end of the path. | `string` | `""` | no |
| <a name="input_origin_read_timeout"></a> [origin\_read\_timeout](#input\_origin\_read\_timeout) | The Custom Read timeout, in seconds. By default, AWS enforces a limit of 60. But you can request an increase. | `number` | `30` | no |
Expand Down
1 change: 1 addition & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ usage: |2-
}
}]
origin_groups = [{
group_id = "groupS3"
primary_origin_id = null # will get translated to the origin id of the origin created by this module.
failover_origin_id = module.s3_bucket.bucket_id
failover_criteria = [
Expand Down
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ module "cloudfront_s3_cdn" {
}
}], var.additional_s3_origins_enabled ? [local.additional_s3_origin_primary, local.additional_s3_origin_secondary] : [])
origin_groups = concat([{
group_id = "groupS3"
primary_origin_id = null # will get translated to the origin id of the origin created by this module.
failover_origin_id = module.s3_bucket.bucket_id
failover_criteria = var.origin_group_failover_criteria_status_codes
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ resource "aws_cloudfront_distribution" "default" {
dynamic "origin_group" {
for_each = var.origin_groups
content {
origin_id = "${module.this.id}-group[${origin_group.key}]"
origin_id = try(length(origin_group.value.group_id), 0) > 0 ? origin_group.value.group_id : "${module.this.id}-group[${origin_group.key}]"

failover_criteria {
status_codes = origin_group.value.failover_criteria
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ variable "s3_website_password_enabled" {

variable "origin_groups" {
type = list(object({
group_id = optional(string)
primary_origin_id = string
failover_origin_id = string
failover_criteria = list(string)
Expand Down