Courseiva
SDLC Automation →easyMultiple Select

DOP-C02 SDLC Automation Practice Question

Which TWO actions should a DevOps engineer take to ensure that an AWS CodeBuild project can access a private Amazon S3 bucket to download build artifacts? (Choose two.)

⚠ Common exam trap

Many candidates confuse network-level controls (VPC endpoints) with IAM permissions, thinking that a VPC endpoint alone is sufficient to grant access to S3, when in fact IAM policies or bucket policies are still required.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Add a bucket policy that explicitly allows access from the CodeBuild project's IAM role ARN

A bucket policy can explicitly grant access to the CodeBuild project's IAM role ARN, allowing the CodeBuild service to download objects from the private S3 bucket. This is a common method to cross-account or service-specific access without making the bucket public.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Generate an access key and secret key for the CodeBuild project to use in the buildspec

    Why it's wrong here

    Generating long-term IAM access keys and placing them in the CodeBuild buildspec is an anti-pattern because CodeBuild is designed to assume an IAM service role and automatically obtain temporary credentials via STS. Hard-coded access keys create a principal outside the IAM role model, introduce secrets management overhead, and violate least privilege. They are also unnecessary: CodeBuild's service role already provides the proper identity for authorizing S3 operations.

  • ✓

    Add a bucket policy that explicitly allows access from the CodeBuild project's IAM role ARN

    Why this is correct

    Adding a bucket policy that explicitly grants the CodeBuild project's IAM role ARN the s3:GetObject action is a resource-based policy approach. It complements the identity-based policy attached to the role and ensures S3 evaluates the permission grant directly, which is required when the bucket account enforces resource policies or when the bucket resides in a different account. This explicit allow on the bucket side removes any dependency on implicit same-account authorization and is a secure, scoped way to permit object retrieval.

  • ✗

    Configure the CodeBuild project to run in a VPC with an S3 VPC endpoint

    Why it's wrong here

    Configuring the CodeBuild project to run in a VPC with an S3 VPC endpoint only changes the network path used to reach S3—it does not grant or alter IAM permissions. S3 access from CodeBuild normally works over the public S3 service endpoint without a VPC, and the service manages the underlying network connectivity. A VPC endpoint would be relevant only if you need private network routing or are subject to a restrictive network policy, so it is not a required action for granting CodeBuild access to an S3 bucket.

  • ✓

    Attach an IAM role to the CodeBuild project with s3:GetObject permissions for the bucket

    Why this is correct

    Attaching an IAM role to the CodeBuild project with a policy that allows s3:GetObject on the specific bucket is an identity-based permission. CodeBuild assumes this role at build runtime, and the temporary credentials it receives carry the permissions defined in the role's attached policies. This is the standard mechanism for granting CodeBuild access to any AWS resource, including downloading build artifacts or source code from S3, and it follows least-privilege by scoping the action and resource.

  • ✗

    Make the S3 bucket publicly readable

    Why it's wrong here

    Making the S3 bucket publicly readable is both insecure and unnecessary because it exposes all objects to anyone on the internet, violating the principle of least privilege. Even for a bucket containing only build outputs, public read access removes all access control and bypasses the IAM role-based authorization that should govern sensitive or internal artifacts. The correct approach is to rely on IAM roles and resource policies so access remains attributable and auditable.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.