From a40357b6da4dba85834bc5deb7421532121418cb Mon Sep 17 00:00:00 2001 From: rankin-tr <43282033+rankin-tr@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:20:35 -0700 Subject: [PATCH] fix: tf lint formatting --- examples/complete/main.tf | 6 +++--- examples/complete/s3-origins.tf | 6 +++--- main.tf | 24 ++++++++++++------------ variables.tf | 20 ++++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 409d008c..4214b4a4 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -109,9 +109,9 @@ module "cloudfront_s3_cdn" { custom_origins = var.additional_custom_origins_enabled ? [local.additional_custom_origin_primary, local.additional_custom_origin_secondary] : [] s3_origins = concat([{ - domain_name = module.s3_bucket.bucket_regional_domain_name - origin_id = module.s3_bucket.bucket_id - origin_path = null + domain_name = module.s3_bucket.bucket_regional_domain_name + origin_id = module.s3_bucket.bucket_id + origin_path = null origin_access_control_id = null s3_origin_config = { origin_access_identity = null # will get translated to the origin_access_identity used by the origin created by this module. diff --git a/examples/complete/s3-origins.tf b/examples/complete/s3-origins.tf index 17b9e593..8c5ef61c 100644 --- a/examples/complete/s3-origins.tf +++ b/examples/complete/s3-origins.tf @@ -1,9 +1,9 @@ locals { additional_s3_origins_enabled = local.enabled && var.additional_s3_origins_enabled default_s3_origin_configuration = { - domain_name = null - origin_id = null - origin_path = null + domain_name = null + origin_id = null + origin_path = null origin_access_control_id = null s3_origin_config = { origin_access_identity = "" diff --git a/main.tf b/main.tf index a2e1aef6..6a7cee4a 100644 --- a/main.tf +++ b/main.tf @@ -15,7 +15,7 @@ locals { origin_access_control_enabled = local.enabled && var.origin_access_type == "origin_access_control" create_cloudfront_origin_access_identity = local.origin_access_identity_enabled && length(compact([var.cloudfront_origin_access_identity_iam_arn])) == 0 # "" or null - create_cloudfront_origin_access_control = local.origin_access_control_enabled && length(compact([var.cloudfront_origin_access_control_id])) == 0 # "" or null + create_cloudfront_origin_access_control = local.origin_access_control_enabled && length(compact([var.cloudfront_origin_access_control_id])) == 0 # "" or null origin_id = module.this.id origin_path = coalesce(var.origin_path, "/") @@ -37,7 +37,7 @@ locals { # Collect the information for cloudfront_origin_access_control and cloudfront_origin_access_identity and shorten the variable names cf_origin_access_control_id_arn = "arn:${join("", data.aws_partition.current[*].partition)}:cloudfront::${data.aws_caller_identity.current.account_id}:distribution/${var.cloudfront_origin_access_control_id}" - + cf_access_options = var.origin_access_type == "origin_access_identity" ? { new = local.create_cloudfront_origin_access_identity ? { arn = aws_cloudfront_origin_access_identity.default[0].iam_arn @@ -46,8 +46,8 @@ locals { existing = { arn = var.cloudfront_origin_access_identity_iam_arn path = var.cloudfront_origin_access_identity_path - } - } : var.origin_access_type == "origin_access_control" ? { + } + } : var.origin_access_type == "origin_access_control" ? { new = local.create_cloudfront_origin_access_control ? { arn = "arn:${join("", data.aws_partition.current[*].partition)}:cloudfront::${data.aws_caller_identity.current.account_id}:distribution/${aws_cloudfront_origin_access_control.default[0].id}" } : null @@ -108,7 +108,7 @@ locals { "$${origin_path}", local.origin_path), "$${bucket_name}", local.bucket), "$${cloudfront_origin_access_identity_iam_arn}", try(local.cf_access.arn, "")), - "$${cloudfront_origin_access_control_arn}", try(local.cf_access.arn, "")) + "$${cloudfront_origin_access_control_arn}", try(local.cf_access.arn, "")) } data "aws_partition" "current" { @@ -135,7 +135,7 @@ resource "aws_cloudfront_origin_access_identity" "default" { } resource "aws_cloudfront_origin_access_control" "default" { - count = local.create_cloudfront_origin_access_control ? 1 : 0 + count = local.create_cloudfront_origin_access_control ? 1 : 0 name = local.origin_id description = local.origin_id origin_access_control_origin_type = "s3" @@ -197,9 +197,9 @@ data "aws_iam_policy_document" "s3_origin_access_control" { } condition { - test = "StringEquals" + test = "StringEquals" variable = "AWS:SourceArn" - values = [aws_cloudfront_distribution.default[0].arn] + values = [aws_cloudfront_distribution.default[0].arn] } } } @@ -508,9 +508,9 @@ resource "aws_cloudfront_distribution" "default" { } origin { - domain_name = local.bucket_domain_name - origin_id = local.origin_id - origin_path = var.origin_path + domain_name = local.bucket_domain_name + origin_id = local.origin_id + origin_path = var.origin_path # the following enables specifying the origin_access_identity used by the origin created by this module, prior to the module's creation: origin_access_control_id = local.create_cloudfront_origin_access_control ? aws_cloudfront_origin_access_control.default[0].id : local.origin_access_control_enabled && length(compact([var.cloudfront_origin_access_control_id])) > 0 ? var.cloudfront_origin_access_control_id : null @@ -580,7 +580,7 @@ resource "aws_cloudfront_distribution" "default" { origin_path = lookup(origin.value, "origin_path", "") # the following enables specifying the origin_access_control used by the origin created by this module, prior to the module's creation: origin_access_control_id = local.origin_access_control_enabled && try(length(origin.value.s3_origin_config.origin_access_control_id), 0) > 0 ? origin.value.s3_origin_config.origin_access_control_id : local.origin_access_control_enabled ? aws_cloudfront_origin_access_control.default[0].id : null - + dynamic "s3_origin_config" { for_each = local.origin_access_identity_enabled ? var.s3_origins : [] content { diff --git a/variables.tf b/variables.tf index ab4e7d98..0e5bf1a5 100644 --- a/variables.tf +++ b/variables.tf @@ -76,12 +76,12 @@ variable "cloudfront_origin_access_control_id" { variable "origin_access_control_signing_behavior" { # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_origin_access_control#signing_behavior - type = string - default = "always" + type = string + default = "always" description = "Specifies which requests CloudFront signs. Specify always for the most common use case. Allowed values: always, never, and no-override." - + validation { - condition = var.origin_access_control_signing_behavior == "always" || var.origin_access_control_signing_behavior == "no-override" || var.origin_access_control_signing_behavior == "never" + condition = var.origin_access_control_signing_behavior == "always" || var.origin_access_control_signing_behavior == "no-override" || var.origin_access_control_signing_behavior == "never" error_message = "The origin_access_control_signing_behavior must be one of: `always`, `no-override`, or `never`." } } @@ -470,9 +470,9 @@ variable "custom_origins" { variable "s3_origins" { type = list(object({ - domain_name = string - origin_id = string - origin_path = string + domain_name = string + origin_id = string + origin_path = string origin_access_control_id = string s3_origin_config = object({ origin_access_identity = string @@ -517,11 +517,11 @@ variable "deployment_actions" { } variable "origin_access_type" { - type = string - default = "origin_access_identity" + type = string + default = "origin_access_identity" description = "Choose to use `origin_access_control` or `orgin_access_identity`" validation { - condition = var.origin_access_type == "origin_access_control" || var.origin_access_type == "origin_access_identity" + condition = var.origin_access_type == "origin_access_control" || var.origin_access_type == "origin_access_identity" error_message = "The origin_access_type must be `origin_access_control` or `origin_access_identity`." } }