DOP-C02 - Configuration Management and Infrastructure as Code - Section 2.2

Build reusable infrastructure components with the AWS Cloud Development Kit, CloudFormation modules and the AWS Serverless Application Model.

Build sharable infrastructure patterns using the AWS Cloud Development Kit constructs, CloudFormation modules, and the AWS Serverless Application Model. Recognise which abstraction layer suits a team - typed programming constructs in CDK versus template-level modules versus SAM transforms for serverless resources.

AWS Cloud Development KitCloudFormation modulesAWS Serverless Application ModelReusable constructs

Practice question for this objective

Free sampleConfiguration Management and Infrastructure as Codemedium

A team defines a serverless API using plain CloudFormation. Each endpoint requires an AWS::Lambda::Function, an AWS::IAM::Role, an AWS::Logs::LogGroup, and several AWS::ApiGateway resources, so the template has grown long and error-prone, and engineers frequently misconfigure the IAM role and log retention. They want a template authoring model where a single resource declares the function and wires its API event, permissions and logging, while still producing standard CloudFormation under the hood. Which change BEST reduces this boilerplate?

  • AKeep the raw CloudFormation resources but move the IAM role and log group into a nested stack so the main template is shorter, referencing them from each function through cross-stack outputs.
  • BReplace the inline resources with a CloudFormation macro the team writes to generate the function and its dependencies, registering the macro so each template calls it for every endpoint.
  • CAdopt the AWS Serverless Application Model transform and declare each endpoint as an AWS::Serverless::Function with an Api event, letting the transform expand it into the underlying function, role, permissions and API resources. Correct
  • DContinue using the existing resources but add a CloudFormation parameter for log retention and a managed policy reference for the role, so the misconfigured values are supplied consistently across endpoints.
Use the AWS Serverless Application Model transform so one AWS::Serverless::Function declaration expands into the function, role, permissions and API resources as standard CloudFormation. The AWS Serverless Application Model is a CloudFormation transform: a single AWS::Serverless::Function with an Api event expands at deploy time into the Lambda function, its execution role, permissions and API Gateway resources as ordinary CloudFormation, removing repetitive boilerplate that nested stacks, a custom macro or parameters do not eliminate.

Why A is wrong: A nested stack hides some lines behind a separate template but each endpoint still declares the full function, role, log group and API resources by hand, so the misconfiguration and boilerplate the team wants to remove remain.

Why B is wrong: A self-written macro could expand the resources but it puts the burden of authoring and maintaining a Lambda-backed transform on the team, whereas the managed serverless transform already provides this expansion.

Why C is correct: The AWS Serverless Application Model transform lets one AWS::Serverless::Function resource declare the function plus its API event and generate the role, permissions and API plumbing as standard CloudFormation, removing the hand-written boilerplate the team struggles with.

Why D is wrong: Parameters and a shared policy standardise specific values but every endpoint still declares all four resource types explicitly, so the lengthy error-prone template the team wants to simplify is unchanged.

See more DOP-C02 practice questions, answers explained.

More in this domain

Back to all Configuration Management and Infrastructure as Code objectives, or the DOP-C02 cert hub.

Examworthy is not affiliated with or endorsed by Amazon Web Services. Original, blueprint-aligned practice material only.