cloudposse / terraform-aws-elastic-beanstalk-environment

Terraform module to provision an AWS Elastic Beanstalk Environment
https://cloudposse.com/accelerate
Apache License 2.0
304 stars 325 forks source link

Deployment fails with "MalformedPolicy: Policy has invalid resource" with `enable_loadbalancer_logs = true` #259

Closed benjamin-hg closed 5 months ago

benjamin-hg commented 6 months ago

Describe the Bug

The issue arises with enable_loadbalancer_logs = true

Deployment fails, because the EB's ELB does not get permissions to access the bucket. This is caused by terraform failing to create the policy. The policy creation fails because it is invalid. The policy is invalid because a wrong bucket name is used as resource in some of the policy statements.

The bug seems to be that the bucket name is not set properly at

https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/blob/0.51.2/main.tf#L1107

Expected Behavior

The created policy statements reference the bucket with the correct name

Steps to Reproduce

  1. Create a terraform-aws-elastic-beanstalk-environment
  2. Set enable_loadbalancer_logs = true in that module
  3. Try terraform apply

Screenshots

No response

Environment

modules:

Additional Context

Related to https://github.com/cloudposse/terraform-aws-lb-s3-bucket/issues/81