ExitAWS CDK and AWS CloudFormation: abstraction versus deployment1 / 9
Explanation

Three forms of infrastructure reuse

How CDK construct libraries differ from CloudFormation templates and modules, and where CDK's modeling responsibility ends and CloudFormation's deployment responsibility begins. · advanced

A CDK construct library distributes executable modeling code. Your CDK application instantiates constructs, and synthesis turns the resulting construct tree into CloudFormation templates. L1 constructs closely expose CloudFormation resource schemas; L2 constructs add intent-oriented APIs and defaults; higher-level patterns compose multiple resources. A construct is not itself a deployed resource.

A CloudFormation template is a declarative JSON or YAML description of resources, properties, and relationships. A CloudFormation module is a reusable, registered template fragment referenced from a template. CloudFormation expands module references into their constituent resources during template processing; it does not execute a CDK construct library.

The distinction is therefore not reusable versus nonreusable. Both approaches support standardization, but their abstraction interfaces differ: programming-language APIs for constructs, and declarative parameters and resource definitions for modules. After expansion, module resources participate in the consuming stack's lifecycle rather than becoming an independently deployed module stack.

FormConsumer interfaceProcessingDeployment result
Construct libraryProgramming-language APICDK application synthesisResources in generated templates
TemplateDeclarative stack definitionCloudFormation processingStack-managed resources
ModuleDeclarative module referenceCloudFormation expansionResources in consuming stack