Export the bucket name as a CloudFormation output with the StackVariables namespace and deploy using StackVariables.BucketName
A DevOps engineer uses a pipeline in AWS CodePipeline. The pipeline has a build action and a deploy action for a single-page web application that is delivered to an Amazon S3 bucket. Amazon CloudFront serves the web application. The build action creates an artifact for the web application. The DevOps engineer has created an AWS CloudFormation template that defines the S3 bucket and configures the S3 bucket to host the application. The DevOps engineer has configured a CloudFormation deploy action before the S3 action. The CloudFormation deploy action creates the S3 bucket. The DevOps engineer needs to configure the S3 deploy action to use the S3 bucket from the CloudFormation template. Which combination of steps will meet these requirements? (Choose two.)
Community Votes
100% of anonymous learners picked answer BD. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The pipeline needs a way to carry the CloudFormation output forward, and CodePipeline provides that through the CloudFormation action's namespace, which makes template outputs available to later actions as namespace.outputName (B). Combined with the deploy action referencing StackVariables.BucketName, the S3 action always uses the bucket the stack produced (B and D). Option D is the necessary second half because the deploy action must actually consume the variable and take the build artifact as input. Option A's confusion of an AWS::SSM::Parameter resource with an output is not how outputs are declared, and option C conflates output artifacts with Parameter Store parameters.
The S3 bucket is created by a CloudFormation deploy action, so the later S3 deploy action needs the bucket name without it being hard-coded. Adding an output named BucketName to the template that refers to the bucket, and setting the CloudFormation action's namespace to StackVariables in the pipeline, makes that output available to subsequent actions as StackVariables.BucketName. The S3 deploy action then takes the build artifact as its input and deploys to the bucket named by that variable, so the pipeline always targets whatever bucket the stack created.
Setting the output's value to export to an AWS::SSM::Parameter resource named Stackvariables (A) — an output and an AWS::SSM::Parameter resource are different things; an Output section exports a value from the stack to the pipeline, while an SSM parameter is a separate resource that would have to be created and populated explicitly, so this does not surface the bucket name to the pipeline in the way the namespace mechanism does. Configuring the output artifacts of the CloudFormation action to be an AWS Systems Manager Parameter Store parameter named StackVariables with the artifact named BucketName (C) — this conflates output artifacts, which are files, with a Parameter Store parameter, so the bucket name would not be delivered as the pipeline variable the deploy action expects. Using both the build artifact and the SSM parameter as deploy inputs (E) — once the namespace mechanism in B is used, the value is carried in the pipeline variables rather than as a Parameter Store artifact, so adding a parameter as an extra input is redundant and based on the same conflation as C.
Community Discussion (3 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The pipeline already contains a CloudFormation deploy action that creates the bucket and an S3 deploy action that must target that bucket, so the bucket name has to travel from the template to the later action. Adding an output named BucketName to the CloudFormation template whose value refers to the S3 bucket, and then setting the CloudFormation action's namespace to StackVariables in the pipeline, makes that output available to subsequent actions under the name StackVariables.BucketName (B). Changwha described exactly this two-part configuration, defining the BucketName output and setting the CloudFormation action's namespace to StackVariables. The S3 deploy action is then configured to take the build artifact from the build action as its input and to deploy to the bucket identified by the StackVariables.BucketName variable, which is what ties the two actions together without any hard-coded bucket name (D). f4b18ba confirmed that adding the output lets the pipeline extract the bucket name created during the stack deployment and that setting the namespace exposes it as StackVariables.BucketName. B and D are the correct combination.Why the Other Options Are Wrong
A adds a BucketName output but sets the output's value to export to an AWS::SSM::Parameter resource named Stackvariables. An Output in a CloudFormation template exports a value from the stack to the pipeline's variable namespace; an AWS::SSM::Parameter is an entirely separate resource type that must be declared and populated explicitly. Conflating the two means the bucket name is never surfaced to the pipeline in the way the namespace mechanism provides, so the later action would have no value to consume. C configures the output artifacts of the CloudFormation action to be an AWS Systems Manager Parameter Store parameter named StackVariables with the artifact named BucketName. Pipeline output artifacts are files produced by an action, not Parameter Store parameters, so this does not deliver the bucket name as the pipeline variable the deploy action expects; it mixes up two unrelated concepts. E configures both the build artifact and the SSM parameter as inputs to the deploy action and deploys using StackVariables.BucketName. This rests on the same conflation as option C, and it is also redundant: once the CloudFormation action's namespace is set as in option B, the output is carried in the pipeline variables, so an additional Parameter Store input is neither needed nor correctly specified. B and D are correct.Community Comment Notes
Community voted B,D unanimously. Changwha gave the two steps explicitly, defining a BucketName output in the template and setting the CloudFormation action's namespace to StackVariables, then using the StackVariables.BucketName variable in the S3 deploy action. f4b18ba explained that adding the output allows the pipeline to extract the S3 bucket name created during the stack deployment and that setting the namespace exposes it as StackVariables.BucketName. uncledana described the same dynamic deployment pattern. No alternative received support.Official Reference
Related Analysis
Practice All DOP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full DOP-C02 Practice Test →