Skip to content

Commit 36035c2

Browse files
Add var.create_cloudfront_origin_access_identity
In some circumstances, it wasn't possible to automatically determine if an Origin Access Identity should be created. Because of this, Terraform requires us to always explicitly specify if the OAI should be created.
1 parent 2802ae3 commit 36035c2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ locals {
99
s3_access_logging_enabled = local.enabled && (var.s3_access_logging_enabled == null ? length(var.s3_access_log_bucket_name) > 0 : var.s3_access_logging_enabled)
1010
create_cf_log_bucket = local.cloudfront_access_logging_enabled && local.cloudfront_access_log_create_bucket
1111

12-
create_cloudfront_origin_access_identity = local.enabled && length(compact([var.cloudfront_origin_access_identity_iam_arn])) == 0 # "" or null
12+
create_cloudfront_origin_access_identity = local.enabled && var.create_cloudfront_origin_access_identity
1313

1414
origin_id = module.this.id
1515
origin_path = coalesce(var.origin_path, "/")

variables.tf

+8-2
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,13 @@ variable "deployment_actions" {
492492
variable "cloudfront_origin_access_identity_iam_arn" {
493493
type = string
494494
default = ""
495-
description = "Existing cloudfront origin access identity iam arn that is supplied in the s3 bucket policy"
495+
description = "Existing cloudfront origin access identity iam arn that is supplied in the s3 bucket policy. If you set this, you must also set `cloudfront_origin_access_identity_path` and disable `create_cloudfront_origin_access_identity`"
496496
}
497497

498498
variable "cloudfront_origin_access_identity_path" {
499499
type = string
500500
default = ""
501-
description = "Existing cloudfront origin access identity path used in the cloudfront distribution's s3_origin_config content"
501+
description = "Existing cloudfront origin access identity path used in the cloudfront distribution's s3_origin_config content. If you set this, you must also set `cloudfront_origin_access_identity_iam_arn` and disable `create_cloudfront_origin_access_identity`"
502502
}
503503

504504
variable "custom_origin_headers" {
@@ -662,3 +662,9 @@ variable "allow_ssl_requests_only" {
662662
default = true
663663
description = "Set to `true` to require requests to use Secure Socket Layer (HTTPS/SSL). This will explicitly deny access to HTTP requests"
664664
}
665+
666+
variable "create_cloudfront_origin_access_identity" {
667+
type = bool
668+
default = true
669+
description = "Set to `true` to create a CloudFront Origin Access Identity. You should disable this if you set `cloudfront_origin_access_identity_iam_arn` and `cloudfront_origin_access_identity_path`"
670+
}

0 commit comments

Comments
 (0)