An AWS CodeBuild project is currently downloading a database population script from an S3 bucket using an unauthenticated request, which violates security policy. What is the most secure way to fix this?
Choose an answer
Tap an option to check your answer.
Correct answer: Remove public (unauthenticated) access to the S3 bucket via a bucket policy. Grant the CodeBuild service role permissions for S3 access, and use the AWS CLI in the buildspec to download the script using the service role..
Why this is the answer
The most secure solution involves removing public access to the S3 bucket, which is a critical security best practice. By granting the CodeBuild service role specific S3 read permissions, you leverage AWS IAM roles for secure, temporary credentials, eliminating the need for hardcoded keys. The AWS CLI automatically uses the CodeBuild service role's permissions when run within the CodeBuild environment, ensuring authenticated and authorized access. Adding the bucket name to AllowedBuckets doesn't inherently secure the S3 bucket itself or authenticate access. Enabling HTTPS basic authentication on S3 is not a native S3 feature for object access and is generally not recommended for programmatic access. Using hard-coded IAM access keys and secret access keys in the buildspec is a significant security vulnerability, as these credentials could be exposed.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed