CodexBloom - Programming Q&A Platform

AWS CodeBuild scenarios to Access S3 Bucket with 'Access Denied' scenarios Despite Policy Configurations

πŸ‘€ Views: 13 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-16
aws codebuild s3 json

I've tried everything I can think of but I'm working with an scenario where my AWS CodeBuild project is failing to pull artifacts from an S3 bucket due to an 'Access Denied' behavior... I've verified that the S3 bucket policy allows access from the CodeBuild service role, but I still get the behavior during the build phase. Here’s the relevant part of my S3 bucket policy: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "codebuild.amazonaws.com" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-bucket-name/*" } ] } ``` My CodeBuild project's service role has the following inline policy attached: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::my-bucket-name", "arn:aws:s3:::my-bucket-name/*" ] } ] } ``` I’ve also added the necessary permissions to the CodeBuild project's IAM Role, ensuring that it can access S3 resources. I tried running the build in a different region, and the same behavior continues. I suspect the scenario might be related to some missing settings or configurations. Any insights on how to resolve this scenario or additional configurations I might need to check would be greatly appreciated. Hoping someone can shed some light on this.