Course menuDOP-C02

Exams / DOP-C02 / Custom resources, helper scripts and stack policies / Question 1

DOP-C02 practice question: Custom resources, helper scripts and stack policies

Configuration Management and IaC A free question from our original DOP-C02 practice exam. Try it, then open the answer to see why each option is right or wrong.

Last verified against current AWS documentation ·How we write our questions

A hospital network deploys a CloudFormation stack that includes a custom resource. An AWS Lambda function behind the custom resource creates a database parameter group that the clinical reporting database needs.

After a recent change, stack creation hung for an hour and then failed with a timeout on the custom resource, even though the parameter group existed in the account. The Lambda function returned normally, but an exception in a helper path skipped the code that reports back to CloudFormation.

The operations team wants any future failure in the custom resource to end the stack operation quickly and report the reason, instead of making CloudFormation wait for its timeout.

Which change meets these requirements?

Choose one answer.

  1. A. Increase the custom resource's ServiceTimeout to the maximum allowed value, so that the stack waits longer and the function has more time to finish its work.
  2. B. Wrap the handler so that every event, including exceptions, sends a SUCCESS or FAILED response with the reason to the pre-signed response URL that CloudFormation supplies.
  3. C. Move the parameter group out of the template and create it with a CloudFormation StackSet, so that the custom resource no longer runs in the stack's account.
  4. D. Add a CreationPolicy with a count of one to the custom resource, so that CloudFormation waits for a signal from the function and fails the resource when the signal is missing.
Show the answer and explanation

Answer: B

Explanation

A custom resource is complete only when its handler sends a response to the pre-signed URL that CloudFormation provides. A handler that responds with SUCCESS or FAILED on every path lets the stack fail quickly and show the reason. Longer timeouts, StackSets and creation policies do not address the missing response.

Study

Keep practicing

Answer questions with a score at the end, or practice just this topic with the explanation after each one. No sign-up needed.

Want more on Custom resources, helper scripts and stack policies? The 5 full-length practice sets have 7 more Custom resources, helper scripts and stack policies questions, 375 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets