Courseiva
SDLC AutomationmediumMultiple ChoiceObjective-mapped

DOP-C02 SDLC Automation Practice Question

Network Topology
$ aws cloudformation describe-stacksstack-name my-stackquery "Stacks[0].Outputs""OutputKey": "BucketName","OutputValue": "my-stack-bucket-123456","Description": "S3 Bucket Name"},"OutputKey": "InstanceId","OutputValue": "i-0abcd1234efgh5678","Description": "EC2 Instance ID"

Refer to the exhibit. A CloudFormation stack has been deployed. A developer wants to use the S3 bucket name in a subsequent AWS CLI command. Which command will correctly retrieve the bucket name?

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

aws cloudformation describe-stacks --stack-name my-stack --query "Stacks[0].Outputs[?OutputKey=='BucketName'].OutputValue" --output text

The developer can use the --query parameter with the describe-stacks command to extract the OutputValue for the specific OutputKey 'BucketName'. Option C uses the correct JMESPath syntax with the filter [?OutputKey=='BucketName'] to select the matching output and then retrieves its OutputValue. Option A attempts to list all S3 buckets and grep for 'my-stack', which is unreliable and not the intended method. Option B uses describe-stack-resources but incorrectly assumes the bucket name is a physical resource ID when it is actually an output value. Option D uses incorrect JMESPath syntax (single bracket with equality) which is invalid.

Answer analysis

Option-by-option breakdown

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

  • aws s3 ls | grep my-stack

    Why it's wrong here

    Running `aws s3 ls` lists every S3 bucket in the account, then `grep my-stack` only pattern-matches bucket names containing 'my-stack'. This approach does not query CloudFormation at all, so it ignores the stack's declared `BucketName` output and any resources created outside S3; it also breaks if the bucket name differs from the stack name or if permissions restrict `s3:ListAllMyBuckets`. It is a brittle manual workaround, not a reliable API call tied to the stack.

  • aws cloudformation describe-stack-resources --stack-name my-stack --logical-resource-id BucketName --query "StackResources[0].PhysicalResourceId" --output text

    Why it's wrong here

    This command retrieves the physical resource ID of the resource with logical ID 'BucketName', which is the bucket name. However, the exhibit shows outputs, not resources. Both could work, but the question asks based on the exhibit which shows outputs. Option A is more direct given the exhibit.

  • aws cloudformation describe-stacks --stack-name my-stack --query "Stacks[0].Outputs[?OutputKey=='BucketName'].OutputValue" --output text

    Why this is correct

    This command is correct because it uses `aws cloudformation describe-stacks` to retrieve the stack's metadata, then JMESPath `Stacks[0].Outputs[?OutputKey=='BucketName'].OutputValue` filters the outputs array for the output whose `OutputKey` exactly equals `BucketName` and extracts its `OutputValue`. The `--output text` renders the result as plain text (the actual bucket name). This directly matches the exhibit, which shows the stack's outputs, and is the intended way to programmatically retrieve a CloudFormation output value.

  • aws cloudformation describe-stacks --stack-name my-stack --query "Stacks[0].Outputs[OutputKey='BucketName'].OutputValue" --output text

    Why it's wrong here

    This command fails because the JMESPath filter expression is invalid. In JMESPath, filtering an array uses the syntax `[?condition]` (e.g., `[?OutputKey=='BucketName']`), not bare brackets `[OutputKey=...]`. Additionally, the comparison operator must be `==`, not a single `=`, so the query `Outputs[OutputKey='BucketName']` will cause a JMESPath parse error or return no results. Even if `--query` syntactically accepted it, `--output text` would not produce the intended output, so this is incorrect.

Visual reference

Client Server SYN (seq=100) SYN-ACK (seq=200, ack=101) ACK (ack=201) Connection established — data transfer begins

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,013 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.