Closed bohnjamin closed 10 months ago
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
Fixed by #264
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Description
PR: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/pull/264
In release 3.8.2, a fix was made to support newer AWS regions which use a different log delivery policy: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/commit/3c094b32333a177a07477c4079ef3bd8cc56eea8#diff-dc46acf24afd63ef8c556b77c126ccc6e578bc87e3aa09a931f33d9bf2532fbb
The fix was essentially "if the old region exists in this list, use the old way, otherwise use the new way". Unfortunately, the China regions were left out of this list, so this module treats them as though they're new regions, and sets the Principal to
"Service": "logdelivery.elasticloadbalancing.amazonaws.com
, when it should be the old format:"AWS": "arn:aws-cn:iam::638102146993:root"
(example given is for cn-north-1)Documentation here describes regions excluding China: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy
China regions are listed here: https://docs.amazonaws.cn/en_us/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy
Versions
Module version [Required]: 3.15.1 (really, any version since 3.8.2)
Terraform version:
provider registry.terraform.io/hashicorp/aws v5.29.0
provider registry.terraform.io/hashicorp/random v3.6.0
Provider version(s):
provider registry.terraform.io/hashicorp/aws v5.29.0
provider registry.terraform.io/hashicorp/random v3.6.0
Reproduction Code [Required]
Steps to reproduce the behavior: Create an ELB log bucket in S3 in an AWS China region, with
attach_elb_log_delivery_policy
andattach_lb_log_delivery_policy
set to true, then create an ALB and setaccess_logs
to your bucket ID.Expected behavior
bucket should get created with correct permissions, and the ALB should be able to write to it
Actual behavior
The incorrect principal gets set in the bucket permissions, and the log delivery fails. This causes terraform to fail with an error like this:
Terminal Output Screenshot(s)
Additional context
Submitted PR with example code here: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/pull/264