Terraform how to to deploy AWS Elastic Beanstalk environment due to missing S3 bucket policy
I'm trying to figure out Could someone explain I'm trying to deploy an AWS Elastic Beanstalk application using Terraform, but I'm running into an scenario where the deployment fails due to a missing S3 bucket policy. The behavior message I'm receiving is: `behavior: S3 bucket is not accessible; ensure the bucket policy allows access`. I have the following code snippet that defines the Elastic Beanstalk application and the associated S3 bucket: ```hcl resource "aws_s3_bucket" "app_bucket" { bucket = "my-app-bucket-unique-name" acl = "private" } resource "aws_s3_bucket_policy" "app_bucket_policy" { bucket = aws_s3_bucket.app_bucket.id policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Principal = "*" Action = "s3:GetObject" Resource = "${aws_s3_bucket.app_bucket.arn}/*" } ] }) } resource "aws_elastic_beanstalk_application" "my_app" { name = "my-app" description = "My application deployed using Terraform" } resource "aws_elastic_beanstalk_environment" "my_env" { name = "my-env" application = aws_elastic_beanstalk_application.my_app.name solution_stack_name = "64bit Amazon Linux 2 v3.3.1 running Python 3.8" } ``` I've ensured that the bucket name is unique and that the IAM role associated with the Elastic Beanstalk has permission to access the S3 bucket. However, it seems that the bucket policy may not be configured correctly. I've tried specifying more granular permissions but to no avail. What should I adjust in the bucket policy to allow the Elastic Beanstalk environment to access the bucket correctly? Any insights would be greatly appreciated! I've been using Hcl for about a year now. What's the best practice here?