Skip to content

ELB log delivery policy not as expected when applied #347

@emuesuenu

Description

@emuesuenu

Description

When attempting to move away from specification by the providers argument to the region argument,
ELB log delivery policy was not specified as expected

Versions

  • Module version [Required]:
    5.2.0
  • Terraform version:
    v1.12.2
  • Provider version(s):
    hashicorp/aws v6.3.0

Reproduction Code [Required]

before

module "log_bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "5.2.0"

  bucket = "example"

  attach_elb_log_delivery_policy = true

  providers = {
    aws = aws.ap_northeast_3
  }
}

after

module "log_bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "5.2.0"

  bucket = "example"
  region = "ap-northeast-3"

  attach_elb_log_delivery_policy = true
}

Expected behavior

We hope that the following differences will be eliminated

No changes. Your infrastructure matches the configuration.

Actual behavior

The region argument is ignored and the region specified as the default provider is referenced

# module.service.module.log_bucket.aws_s3_bucket_policy.this[0] will be updated in-place
  ~ resource "aws_s3_bucket_policy" "this" {
        id     = "example"
      ~ policy = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Principal = {
                          ~ AWS = "arn:aws:iam::383597477331:root" -> "arn:aws:iam::582318560864:root"
                        }
                      ~ Sid       = "ELBRegionAp-Northeast-3" -> "ELBRegionAp-Northeast-1"
                        # (3 unchanged attributes hidden)
                    },
                    {
                        Action    = "s3:PutObject"
                        Effect    = "Allow"
                        Principal = {
                            Service = "logdelivery.elasticloadbalancing.amazonaws.com"
                        }
                        Resource  = "arn:aws:s3:::example/*"
                    },
                    # (4 unchanged elements hidden)
                ]
                # (1 unchanged attribute hidden)
            }
        )
        # (2 unchanged attributes hidden)
    }

Additional context

It seems to me that the reason is that the region argument is not specified in the data source.

data "aws_region" "current" {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions