You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: Add Support for Origin Groups (Failover Origins) (#174)
* Add Support for Origin Groups (failover origins)
* Add tests for `var.s3_origins` and `var.custom_origins`
* Add functionality such that if `s3_origin_config.origin_access_identity` in `var.s3_origins` is null or an empty string, translate it to the `origin_access_identity` used by the origin created by the module.
origin_access_identity = null # will get translated to the origin_access_identity used by the origin created by this module.
165
+
}
166
+
}
167
+
origin_groups = {
168
+
primary_origin_id = null # will get translated to the origin id of the origin created by this module.
169
+
failover_origin_id = module.s3_bucket.bucket_id
170
+
failover_criteria = [
171
+
403,
172
+
404,
173
+
500,
174
+
502
175
+
]
176
+
}
177
+
}
178
+
```
179
+
139
180
### Background on CDNs, "Origins", S3 Buckets, and Web Servers
140
181
141
182
#### CDNs and Origin Servers
@@ -435,6 +476,7 @@ Available targets:
435
476
| <a name="input_ordered_cache"></a> [ordered\_cache](#input\_ordered\_cache) | An ordered list of [cache behaviors](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#cache-behavior-arguments) resource for this distribution.<br>List in order of precedence (first match wins). This is in addition to the default cache policy.<br>Set `target_origin_id` to `""` to specify the S3 bucket origin created by this module. | <pre>list(object({<br> target_origin_id = string<br> path_pattern = string<br><br> allowed_methods = list(string)<br> cached_methods = list(string)<br> compress = bool<br><br> cache_policy_id = string<br> origin_request_policy_id = string<br><br> viewer_protocol_policy = string<br> min_ttl = number<br> default_ttl = number<br> max_ttl = number<br><br> forward_query_string = bool<br> forward_header_values = list(string)<br> forward_cookies = string<br><br> lambda_function_association = list(object({<br> event_type = string<br> include_body = bool<br> lambda_arn = string<br> }))<br><br> function_association = list(object({<br> event_type = string<br> function_arn = string<br> }))<br> }))</pre> | `[]` | no |
436
477
| <aname="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 |
437
478
| <aname="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 |
479
+
| <aname="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 |
438
480
| <aname="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 |
439
481
| <aname="input_origin_ssl_protocols"></a> [origin\_ssl\_protocols](#input\_origin\_ssl\_protocols)| The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS. |`list(string)`| <pre>[<br> "TLSv1",<br> "TLSv1.1",<br> "TLSv1.2"<br>]</pre> | no |
440
482
| <aname="input_override_origin_bucket_policy"></a> [override\_origin\_bucket\_policy](#input\_override\_origin\_bucket\_policy)| When using an existing origin bucket (through var.origin\_bucket), setting this to 'false' will make it so the existing bucket policy will not be overriden |`bool`|`true`| no |
@@ -449,7 +491,7 @@ Available targets:
449
491
| <aname="input_s3_access_log_bucket_name"></a> [s3\_access\_log\_bucket\_name](#input\_s3\_access\_log\_bucket\_name)| Name of the existing S3 bucket where S3 Access Logs will be delivered. Default is not to enable S3 Access Logging. |`string`|`""`| no |
450
492
| <aname="input_s3_access_log_prefix"></a> [s3\_access\_log\_prefix](#input\_s3\_access\_log\_prefix)| Prefix to use for S3 Access Log object keys. Defaults to `logs/${module.this.id}`|`string`|`""`| no |
451
493
| <aname="input_s3_access_logging_enabled"></a> [s3\_access\_logging\_enabled](#input\_s3\_access\_logging\_enabled)| Set `true` to deliver S3 Access Logs to the `s3_access_log_bucket_name` bucket.<br>Defaults to `false` if `s3_access_log_bucket_name` is empty (the default), `true` otherwise.<br>Must be set explicitly if the access log bucket is being created at the same time as this module is being invoked. |`bool`|`null`| no |
452
-
| <aname="input_s3_origins"></a> [s3\_origins](#input\_s3\_origins)| A list of S3 [origins](https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments) (in addition to the one created by this module) for this distribution.<br>S3 buckets configured as websites are `custom_origins`, not `s3_origins`. | <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> s3_origin_config = object({<br> origin_access_identity = string<br> })<br> }))</pre> |`[]`| no |
494
+
| <aname="input_s3_origins"></a> [s3\_origins](#input\_s3\_origins)| A list of S3 [origins](https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments) (in addition to the one created by this module) for this distribution.<br>S3 buckets configured as websites are `custom_origins`, not `s3_origins`.<br>Specifying `s3_origin_config.origin_access_identity` as `null` or `""` will have it translated to the `origin_access_identity` used by the origin created by the module.| <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> s3_origin_config = object({<br> origin_access_identity = string<br> })<br> }))</pre> |`[]`| no |
453
495
| <aname="input_s3_website_password_enabled"></a> [s3\_website\_password\_enabled](#input\_s3\_website\_password\_enabled)| If set to true, and `website_enabled` is also true, a password will be required in the `Referrer` field of the<br>HTTP request in order to access the website, and Cloudfront will be configured to pass this password in its requests.<br>This will make it much harder for people to bypass Cloudfront and access the S3 website directly via its website endpoint. |`bool`|`false`| no |
454
496
| <aname="input_stage"></a> [stage](#input\_stage)| Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' |`string`|`null`| no |
455
497
| <aname="input_tags"></a> [tags](#input\_tags)| Additional tags (e.g. `map('BusinessUnit','XYZ')`|`map(string)`|`{}`| no |
@@ -465,13 +507,16 @@ Available targets:
465
507
466
508
| Name | Description |
467
509
|------|-------------|
468
-
| <aname="output_aliases"></a> [aliases](#output\_aliases)| Aliases of the CloudFront distibution|
510
+
| <aname="output_aliases"></a> [aliases](#output\_aliases)| Aliases of the CloudFront distribution.|
469
511
| <aname="output_cf_arn"></a> [cf\_arn](#output\_cf\_arn)| ARN of AWS CloudFront distribution |
470
512
| <aname="output_cf_domain_name"></a> [cf\_domain\_name](#output\_cf\_domain\_name)| Domain name corresponding to the distribution |
471
513
| <aname="output_cf_etag"></a> [cf\_etag](#output\_cf\_etag)| Current version of the distribution's information |
472
514
| <aname="output_cf_hosted_zone_id"></a> [cf\_hosted\_zone\_id](#output\_cf\_hosted\_zone\_id)| CloudFront Route 53 zone ID |
473
515
| <aname="output_cf_id"></a> [cf\_id](#output\_cf\_id)| ID of AWS CloudFront distribution |
474
516
| <aname="output_cf_identity_iam_arn"></a> [cf\_identity\_iam\_arn](#output\_cf\_identity\_iam\_arn)| CloudFront Origin Access Identity IAM ARN |
517
+
| <aname="output_cf_origin_groups"></a> [cf\_origin\_groups](#output\_cf\_origin\_groups)| List of Origin Groups in the CloudFront distribution. |
518
+
| <aname="output_cf_origin_ids"></a> [cf\_origin\_ids](#output\_cf\_origin\_ids)| List of Origin IDs in the CloudFront distribution. |
519
+
| <aname="output_cf_primary_origin_id"></a> [cf\_primary\_origin\_id](#output\_cf\_primary\_origin\_id)| The ID of the origin created by this module. |
475
520
| <aname="output_cf_s3_canonical_user_id"></a> [cf\_s3\_canonical\_user\_id](#output\_cf\_s3\_canonical\_user\_id)| Canonical user ID for CloudFront Origin Access Identity |
476
521
| <aname="output_cf_status"></a> [cf\_status](#output\_cf\_status)| Current status of the distribution |
Copy file name to clipboardExpand all lines: docs/terraform.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,7 @@
115
115
| <a name="input_ordered_cache"></a> [ordered\_cache](#input\_ordered\_cache) | An ordered list of [cache behaviors](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#cache-behavior-arguments) resource for this distribution.<br>List in order of precedence (first match wins). This is in addition to the default cache policy.<br>Set `target_origin_id` to `""` to specify the S3 bucket origin created by this module. | <pre>list(object({<br> target_origin_id = string<br> path_pattern = string<br><br> allowed_methods = list(string)<br> cached_methods = list(string)<br> compress = bool<br><br> cache_policy_id = string<br> origin_request_policy_id = string<br><br> viewer_protocol_policy = string<br> min_ttl = number<br> default_ttl = number<br> max_ttl = number<br><br> forward_query_string = bool<br> forward_header_values = list(string)<br> forward_cookies = string<br><br> lambda_function_association = list(object({<br> event_type = string<br> include_body = bool<br> lambda_arn = string<br> }))<br><br> function_association = list(object({<br> event_type = string<br> function_arn = string<br> }))<br> }))</pre> | `[]` | no |
116
116
| <aname="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 |
117
117
| <aname="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 |
118
+
| <aname="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 |
118
119
| <aname="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 |
119
120
| <aname="input_origin_ssl_protocols"></a> [origin\_ssl\_protocols](#input\_origin\_ssl\_protocols)| The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS. |`list(string)`| <pre>[<br> "TLSv1",<br> "TLSv1.1",<br> "TLSv1.2"<br>]</pre> | no |
120
121
| <aname="input_override_origin_bucket_policy"></a> [override\_origin\_bucket\_policy](#input\_override\_origin\_bucket\_policy)| When using an existing origin bucket (through var.origin\_bucket), setting this to 'false' will make it so the existing bucket policy will not be overriden |`bool`|`true`| no |
@@ -129,7 +130,7 @@
129
130
| <aname="input_s3_access_log_bucket_name"></a> [s3\_access\_log\_bucket\_name](#input\_s3\_access\_log\_bucket\_name)| Name of the existing S3 bucket where S3 Access Logs will be delivered. Default is not to enable S3 Access Logging. |`string`|`""`| no |
130
131
| <aname="input_s3_access_log_prefix"></a> [s3\_access\_log\_prefix](#input\_s3\_access\_log\_prefix)| Prefix to use for S3 Access Log object keys. Defaults to `logs/${module.this.id}`|`string`|`""`| no |
131
132
| <aname="input_s3_access_logging_enabled"></a> [s3\_access\_logging\_enabled](#input\_s3\_access\_logging\_enabled)| Set `true` to deliver S3 Access Logs to the `s3_access_log_bucket_name` bucket.<br>Defaults to `false` if `s3_access_log_bucket_name` is empty (the default), `true` otherwise.<br>Must be set explicitly if the access log bucket is being created at the same time as this module is being invoked. |`bool`|`null`| no |
132
-
| <aname="input_s3_origins"></a> [s3\_origins](#input\_s3\_origins)| A list of S3 [origins](https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments) (in addition to the one created by this module) for this distribution.<br>S3 buckets configured as websites are `custom_origins`, not `s3_origins`. | <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> s3_origin_config = object({<br> origin_access_identity = string<br> })<br> }))</pre> |`[]`| no |
133
+
| <aname="input_s3_origins"></a> [s3\_origins](#input\_s3\_origins)| A list of S3 [origins](https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments) (in addition to the one created by this module) for this distribution.<br>S3 buckets configured as websites are `custom_origins`, not `s3_origins`.<br>Specifying `s3_origin_config.origin_access_identity` as `null` or `""` will have it translated to the `origin_access_identity` used by the origin created by the module.| <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> s3_origin_config = object({<br> origin_access_identity = string<br> })<br> }))</pre> |`[]`| no |
133
134
| <aname="input_s3_website_password_enabled"></a> [s3\_website\_password\_enabled](#input\_s3\_website\_password\_enabled)| If set to true, and `website_enabled` is also true, a password will be required in the `Referrer` field of the<br>HTTP request in order to access the website, and Cloudfront will be configured to pass this password in its requests.<br>This will make it much harder for people to bypass Cloudfront and access the S3 website directly via its website endpoint. |`bool`|`false`| no |
134
135
| <aname="input_stage"></a> [stage](#input\_stage)| Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' |`string`|`null`| no |
135
136
| <aname="input_tags"></a> [tags](#input\_tags)| Additional tags (e.g. `map('BusinessUnit','XYZ')`|`map(string)`|`{}`| no |
@@ -145,13 +146,16 @@
145
146
146
147
| Name | Description |
147
148
|------|-------------|
148
-
| <aname="output_aliases"></a> [aliases](#output\_aliases)| Aliases of the CloudFront distibution|
149
+
| <aname="output_aliases"></a> [aliases](#output\_aliases)| Aliases of the CloudFront distribution.|
149
150
| <aname="output_cf_arn"></a> [cf\_arn](#output\_cf\_arn)| ARN of AWS CloudFront distribution |
150
151
| <aname="output_cf_domain_name"></a> [cf\_domain\_name](#output\_cf\_domain\_name)| Domain name corresponding to the distribution |
151
152
| <aname="output_cf_etag"></a> [cf\_etag](#output\_cf\_etag)| Current version of the distribution's information |
152
153
| <aname="output_cf_hosted_zone_id"></a> [cf\_hosted\_zone\_id](#output\_cf\_hosted\_zone\_id)| CloudFront Route 53 zone ID |
153
154
| <aname="output_cf_id"></a> [cf\_id](#output\_cf\_id)| ID of AWS CloudFront distribution |
154
155
| <aname="output_cf_identity_iam_arn"></a> [cf\_identity\_iam\_arn](#output\_cf\_identity\_iam\_arn)| CloudFront Origin Access Identity IAM ARN |
156
+
| <aname="output_cf_origin_groups"></a> [cf\_origin\_groups](#output\_cf\_origin\_groups)| List of Origin Groups in the CloudFront distribution. |
157
+
| <aname="output_cf_origin_ids"></a> [cf\_origin\_ids](#output\_cf\_origin\_ids)| List of Origin IDs in the CloudFront distribution. |
158
+
| <aname="output_cf_primary_origin_id"></a> [cf\_primary\_origin\_id](#output\_cf\_primary\_origin\_id)| The ID of the origin created by this module. |
155
159
| <aname="output_cf_s3_canonical_user_id"></a> [cf\_s3\_canonical\_user\_id](#output\_cf\_s3\_canonical\_user\_id)| Canonical user ID for CloudFront Origin Access Identity |
156
160
| <aname="output_cf_status"></a> [cf\_status](#output\_cf\_status)| Current status of the distribution |
0 commit comments