> ## Documentation Index
> Fetch the complete documentation index at: https://cdktn.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CDKTN Architecture - CDK Terrain

> Key CDK Terrain components and application structure.

export const AppArchitectureDiagram = () => {
  return <svg viewBox="0 0 740 620" width="100%" role="img" aria-label="CDKTN application architecture showing App containing Stacks with Resources, producing JSON config consumed by OpenTofu or Terraform" style={{
    maxWidth: 740,
    margin: "0 auto",
    display: "block"
  }}>
      <title>CDKTN Application Architecture</title>

      <defs>
        <marker id="aaArrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
          <path d="M 0 0 L 10 5 L 0 10 z" fill="#9ca3af" />
        </marker>
      </defs>

      {}
      <rect x="60" y="20" width="620" height="310" rx="12" fill="none" stroke="#d1d5db" strokeWidth="1.5" strokeDasharray="6 3" />
      <text x="85" y="48" fontSize="16" fontFamily="system-ui, sans-serif" fontWeight="700" fill="#111827">App</text>

      {}
      <rect x="90" y="65" width="270" height="245" rx="10" fill="none" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="225" y="92" textAnchor="middle" fontSize="15" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Stack (Development)</text>

      {}
      <rect x="120" y="110" width="210" height="40" rx="6" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="225" y="136" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#15803D">Resource</text>

      <rect x="120" y="162" width="210" height="40" rx="6" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="225" y="188" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#15803D">Resource</text>

      <rect x="120" y="214" width="210" height="40" rx="6" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="225" y="240" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#15803D">Resource</text>

      {}
      <rect x="385" y="65" width="270" height="245" rx="10" fill="none" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="520" y="92" textAnchor="middle" fontSize="15" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Stack (Test)</text>

      {}
      <rect x="415" y="110" width="210" height="40" rx="6" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="520" y="136" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#15803D">Resource</text>

      <rect x="415" y="162" width="210" height="40" rx="6" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="520" y="188" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#15803D">Resource</text>

      <rect x="415" y="214" width="210" height="40" rx="6" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="520" y="240" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#15803D">Resource</text>

      {}
      <circle cx="225" cy="330" r="4" fill="#d1d5db" />
      <circle cx="520" cy="330" r="4" fill="#d1d5db" />

      {}
      <line x1="225" y1="334" x2="225" y2="370" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#aaArrow)" />
      <line x1="520" y1="334" x2="520" y2="370" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#aaArrow)" />

      {}
      <text x="135" y="365" fontSize="12" fontFamily="system-ui, sans-serif" fill="#9ca3af">Output</text>
      <text x="430" y="365" fontSize="12" fontFamily="system-ui, sans-serif" fill="#9ca3af">Output</text>

      {}
      <rect x="130" y="375" width="190" height="80" rx="8" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <rect x="155" y="393" width="40" height="42" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="175" y="418" textAnchor="middle" fontSize="10" fontFamily="monospace" fontWeight="600" fill="#6b7280">JSON</text>
      <rect x="210" y="393" width="40" height="42" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="230" y="418" textAnchor="middle" fontSize="10" fontFamily="system-ui, sans-serif" fill="#6b7280">Config</text>
      <rect x="265" y="393" width="40" height="42" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="285" y="418" textAnchor="middle" fontSize="9" fontFamily="system-ui, sans-serif" fill="#6b7280">Artifacts</text>

      {}
      <rect x="425" y="375" width="190" height="80" rx="8" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <rect x="450" y="393" width="40" height="42" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="470" y="418" textAnchor="middle" fontSize="10" fontFamily="monospace" fontWeight="600" fill="#6b7280">JSON</text>
      <rect x="505" y="393" width="40" height="42" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="525" y="418" textAnchor="middle" fontSize="10" fontFamily="system-ui, sans-serif" fill="#6b7280">Config</text>
      <rect x="560" y="393" width="40" height="42" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="580" y="418" textAnchor="middle" fontSize="9" fontFamily="system-ui, sans-serif" fill="#6b7280">Artifacts</text>

      {}
      <circle cx="225" cy="455" r="4" fill="#d1d5db" />
      <circle cx="520" cy="455" r="4" fill="#d1d5db" />

      {}
      <line x1="225" y1="459" x2="225" y2="490" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="520" y1="459" x2="520" y2="490" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="225" y1="490" x2="370" y2="490" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="520" y1="490" x2="370" y2="490" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="370" y1="490" x2="370" y2="520" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#aaArrow)" />

      {}
      <rect x="195" y="525" width="350" height="75" rx="10" fill="#15803D" />

      {}
      <g transform="translate(240, 538) scale(1.0)">
        <path fill="#E6C220" d="M18.66,2.33c.2-.11,.44-.11,.64,0l14.2,7.81c.46,.25,.46,.91,0,1.16l-14.2,7.81c-.2,.11-.44-.11-.64,0L4.46,11.3c-.46-.25-.46-.91,0-1.16L18.66,2.33Z" />
        <path fill="#FFFFFF" d="M34.77,13.13c.44-.24,.98,.08,.98,.58v15.61c0,.24-.13,.47-.34,.58l-14.34,7.88c-.44,.24-.98-.08-.98-.58v-15.61c0-.24,.13-.47,.34-.58l14.34-7.88Z" />
        <path fill="#FEDA15" d="M17.53,21.01L3.2,13.13c-.44-.24-.98,.08-.98,.58v15.61c0,.24,.13,.47,.34,.58l14.34,7.88c.44,.24,.98-.08,.98-.58v-15.61c0-.24-.13-.47-.34-.58Zm-9.3,4.97l-3.36-1.77s0-.01,0-.02c.08-1.05,.89-1.5,1.82-1.01,.93,.49,1.62,1.73,1.54,2.78,0,0,0,.01,0,.02Zm5.29,3.05l-3.36-1.77s0-.01,0-.02c.08-1.05,.89-1.5,1.82-1.01,.93,.49,1.62,1.73,1.54,2.78,0,0,0,.01,0,.02Z" />
      </g>

      <text x="290" y="570" textAnchor="start" fontSize="19" fontFamily="system-ui, sans-serif" fontWeight="700" fill="white">OpenTofu</text>
      <text x="400" y="570" textAnchor="start" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="400" fill="rgba(255,255,255,0.7)">/ Terraform</text>
    </svg>;
};

export const ProviderModulesDiagram = () => {
  return <svg viewBox="0 0 820 280" width="100%" role="img" aria-label="Diagram showing how providers and modules produce JSON schema, which a code generator converts into language-specific bindings" style={{
    maxWidth: 820,
    margin: "0 auto",
    display: "block"
  }}>
      <title>Provider and Module Code Generation</title>

      <defs>
        <marker id="pmArrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
          <path d="M 0 0 L 10 5 L 0 10 z" fill="#9ca3af" />
        </marker>
      </defs>

      {}
      <rect x="20" y="60" width="140" height="55" rx="8" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="90" y="93" textAnchor="middle" fontSize="15" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#15803D">Provider</text>

      {}
      <rect x="20" y="145" width="140" height="55" rx="8" fill="#f0fdf4" stroke="#16A34A" strokeWidth="1.5" />
      <text x="90" y="178" textAnchor="middle" fontSize="15" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#15803D">Module</text>

      {}
      <line x1="160" y1="88" x2="200" y2="88" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="200" y1="88" x2="200" y2="130" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="160" y1="173" x2="200" y2="173" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="200" y1="173" x2="200" y2="130" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="200" y1="130" x2="250" y2="130" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />

      {}
      <rect x="260" y="100" width="150" height="60" rx="8" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="335" y="136" textAnchor="middle" fontSize="15" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">JSON Schema</text>

      {}
      <line x1="410" y1="130" x2="470" y2="130" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />

      {}
      <rect x="480" y="95" width="170" height="70" rx="8" fill="#16A34A" />
      <text x="565" y="136" textAnchor="middle" fontSize="15" fontFamily="system-ui, sans-serif" fontWeight="700" fill="white">Code Generator</text>

      {}
      <line x1="650" y1="130" x2="690" y2="130" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="690" y1="20" x2="690" y2="250" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="690" y1="20" x2="720" y2="20" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />
      <line x1="690" y1="78" x2="720" y2="78" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />
      <line x1="690" y1="135" x2="720" y2="135" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />
      <line x1="690" y1="192" x2="720" y2="192" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />
      <line x1="690" y1="250" x2="720" y2="250" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#pmArrow)" />

      {}
      <rect x="730" y="2" width="80" height="36" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="770" y="25" textAnchor="middle" fontSize="12" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">TypeScript</text>

      <rect x="730" y="60" width="80" height="36" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="770" y="83" textAnchor="middle" fontSize="12" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Python</text>

      <rect x="730" y="117" width="80" height="36" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="770" y="140" textAnchor="middle" fontSize="12" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Java</text>

      <rect x="730" y="174" width="80" height="36" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="770" y="197" textAnchor="middle" fontSize="12" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">C#</text>

      <rect x="730" y="232" width="80" height="36" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="770" y="255" textAnchor="middle" fontSize="12" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Go</text>
    </svg>;
};

export const WorkflowDiagram = () => {
  return <svg viewBox="0 0 700 520" width="100%" role="img" aria-label="CDK Terrain workflow diagram showing the init, synth, and deploy phases" style={{
    maxWidth: 700,
    margin: "0 auto",
    display: "block"
  }}>
      <title>CDK Terrain Workflow</title>

      <defs>
        <marker id="wfArrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
          <path d="M 0 0 L 10 5 L 0 10 z" fill="#9ca3af" />
        </marker>
      </defs>

      {}
      <text x="30" y="50" fontSize="16" fontFamily="monospace" fontWeight="700" fill="#16A34A">cdktn init</text>
      <text x="30" y="72" fontSize="13" fontFamily="system-ui, sans-serif" fill="#6b7280">CDKTN creates a project</text>
      <text x="30" y="88" fontSize="13" fontFamily="system-ui, sans-serif" fill="#6b7280">where you define infrastructure</text>

      {}
      <rect x="300" y="25" width="250" height="65" rx="8" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="425" y="64" textAnchor="middle" fontSize="18" fontFamily="system-ui, sans-serif" fontWeight="700" fill="#111827">CDKTN App</text>

      {}
      <line x1="425" y1="90" x2="425" y2="145" stroke="#9ca3af" strokeWidth="2" markerEnd="url(#wfArrow)" />

      {}
      <text x="30" y="185" fontSize="16" fontFamily="monospace" fontWeight="700" fill="#16A34A">cdktn synth</text>
      <text x="30" y="207" fontSize="13" fontFamily="system-ui, sans-serif" fill="#6b7280">CDKTN generates</text>
      <text x="30" y="223" fontSize="13" fontFamily="system-ui, sans-serif" fill="#6b7280">configuration files</text>

      {}
      <text x="302" y="140" fontSize="12" fontFamily="system-ui, sans-serif" fill="#9ca3af">Output</text>

      {}
      <rect x="300" y="150" width="250" height="90" rx="8" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />

      {}
      <rect x="330" y="168" width="44" height="52" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="352" y="200" textAnchor="middle" fontSize="11" fontFamily="monospace" fontWeight="600" fill="#6b7280">JSON</text>

      {}
      <rect x="394" y="168" width="44" height="52" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="416" y="200" textAnchor="middle" fontSize="11" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#6b7280">Config</text>

      {}
      <rect x="458" y="168" width="44" height="52" rx="4" fill="#e5e7eb" stroke="#d1d5db" strokeWidth="1" />
      <text x="480" y="200" textAnchor="middle" fontSize="10" fontFamily="system-ui, sans-serif" fontWeight="500" fill="#6b7280">Artifacts</text>

      {}
      <line x1="425" y1="240" x2="425" y2="300" stroke="#9ca3af" strokeWidth="2" markerEnd="url(#wfArrow)" />

      {}
      <text x="30" y="345" fontSize="16" fontFamily="monospace" fontWeight="700" fill="#16A34A">cdktn deploy</text>
      <text x="30" y="367" fontSize="13" fontFamily="system-ui, sans-serif" fill="#6b7280">OpenTofu / Terraform provisions</text>
      <text x="30" y="383" fontSize="13" fontFamily="system-ui, sans-serif" fill="#6b7280">your infrastructure</text>

      {}
      <rect x="280" y="305" width="290" height="80" rx="10" fill="#15803D" />

      {}
      <g transform="translate(310, 320) scale(1.1)">
        <path fill="#E6C220" d="M18.66,2.33c.2-.11,.44-.11,.64,0l14.2,7.81c.46,.25,.46,.91,0,1.16l-14.2,7.81c-.2,.11-.44-.11-.64,0L4.46,11.3c-.46-.25-.46-.91,0-1.16L18.66,2.33Z" />
        <path fill="#FFFFFF" d="M34.77,13.13c.44-.24,.98,.08,.98,.58v15.61c0,.24-.13,.47-.34,.58l-14.34,7.88c-.44,.24-.98-.08-.98-.58v-15.61c0-.24,.13-.47,.34-.58l14.34-7.88Z" />
        <path fill="#FEDA15" d="M17.53,21.01L3.2,13.13c-.44-.24-.98,.08-.98,.58v15.61c0,.24,.13,.47,.34,.58l14.34,7.88c.44,.24,.98-.08,.98-.58v-15.61c0-.24-.13-.47-.34-.58Zm-9.3,4.97l-3.36-1.77s0-.01,0-.02c.08-1.05,.89-1.5,1.82-1.01,.93,.49,1.62,1.73,1.54,2.78,0,0,0,.01,0,.02Zm5.29,3.05l-3.36-1.77s0-.01,0-.02c.08-1.05,.89-1.5,1.82-1.01,.93,.49,1.62,1.73,1.54,2.78,0,0,0,.01,0,.02Z" />
      </g>

      <text x="360" y="352" textAnchor="start" fontSize="20" fontFamily="system-ui, sans-serif" fontWeight="700" fill="white">OpenTofu</text>
      <text x="470" y="352" textAnchor="start" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="400" fill="rgba(255,255,255,0.7)">/ Terraform</text>

      {}
      <line x1="425" y1="385" x2="425" y2="420" stroke="#9ca3af" strokeWidth="2" />
      <line x1="160" y1="420" x2="690" y2="420" stroke="#9ca3af" strokeWidth="1.5" />
      <line x1="160" y1="420" x2="160" y2="455" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#wfArrow)" />
      <line x1="290" y1="420" x2="290" y2="455" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#wfArrow)" />
      <line x1="425" y1="420" x2="425" y2="455" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#wfArrow)" />
      <line x1="560" y1="420" x2="560" y2="455" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#wfArrow)" />
      <line x1="690" y1="420" x2="690" y2="455" stroke="#9ca3af" strokeWidth="1.5" markerEnd="url(#wfArrow)" />

      {}
      <rect x="100" y="460" width="120" height="45" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="160" y="488" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">AWS</text>

      <rect x="230" y="460" width="120" height="45" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="290" y="488" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Azure</text>

      <rect x="365" y="460" width="120" height="45" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="425" y="488" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">GCP</text>

      <rect x="500" y="460" width="120" height="45" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="560" y="488" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">Kubernetes</text>

      <rect x="630" y="460" width="120" height="45" rx="6" fill="#f9fafb" stroke="#d1d5db" strokeWidth="1.5" />
      <text x="690" y="482" textAnchor="middle" fontSize="13" fontFamily="system-ui, sans-serif" fontWeight="600" fill="#374151">3000+</text>
      <text x="690" y="498" textAnchor="middle" fontSize="11" fontFamily="system-ui, sans-serif" fontWeight="400" fill="#6b7280">providers</text>
    </svg>;
};

This page explains the tools and processes that CDK Terrain (CDKTN) uses to leverage the Terraform ecosystem and convert code into Terraform configuration files. It also explains the major components of a CDKTN application and how those pieces fit together.

## CDKTN Building Blocks

CDKTN leverages existing libraries and tools to help convert the definitions you write in your preferred programming language to Terraform configuration files. It also uses Terraform to provision and manage your infrastructure when you deploy your application.

### Amazon Web Services Cloud Development Kit

CDKTN shares core concepts and components with the [Amazon Web Services Cloud Development Kit](https://aws.amazon.com/cdk/) (AWS CDK), a tool that allows you to use familiar programming languages to define infrastructure on AWS CloudFormation. AWS CDK and CDK Terrain are different products, and you cannot yet use [AWS CDK constructs](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html) within CDKTN. The [interoperability layer](/create-and-deploy/aws-adapter) is a technical preview, and it is not yet ready for use in production.

### jsii

The [`jsii` tool](https://aws.github.io/jsii/) enables publishing polyglot libraries in all supported languages from a single Typescript code base. CDKTN uses Typescript types to generate an assembly file that `jsii` uses to generate the code bindings for the other supported languages.

### Terraform / OpenTofu

CDKTN [synthesizes](/cli-reference/commands#synth) infrastructure that you define in a supported programming language into [JSON configuration files](https://developer.hashicorp.com/terraform/language/syntax/json) that Terraform or OpenTofu can use to manage infrastructure.

The following diagram shows how synthesizing a CDKTN application produces a series of artifacts in a designated output folder. You can then either use the JSON file with Terraform directly or provision your infrastructure using CDKTN CLI commands. All CDKTN CLI operations like `diff`, `deploy`, and `destroy` communicate with Terraform (or OpenTofu) for execution.

A project declares the Terraform and OpenTofu version ranges it supports through the [`targetVersions`](/create-and-deploy/configuration-file#declare-target-runtimes) field in `cdktf.json`. These declared targets drive synth-time validations — for example [function availability](/concepts/functions#function-availability-across-terraform-and-opentofu) — without executing a binary. To additionally verify that the binary actually installed on a machine falls inside the declared range before `diff`, `deploy`, or `destroy` run it, opt in with [`validateInstalledBinary`](/create-and-deploy/configuration-file#validate-the-installed-binary).

<WorkflowDiagram />

CDKTN also automatically extracts the schemas from existing Terraform [providers](/concepts/providers) or [modules](/concepts/modules) and generates the necessary code bindings for your application.

<ProviderModulesDiagram />

## CDKTN Components

CDKTN has two major components that allow you to define and provision infrastructure.

* **Lib:** This is the `cdktn` package that is the foundation for each CDKTN project. It contains all of the core libraries that allow you to leverage the Terraform ecosystem and synthesize your application into Terraform configuration files.

* **CLI:** The [`cdktn` CLI](/cli-reference/cli-configuration) allows you to initialize a new CDKTN project, adjust project settings, synthesize your infrastructure into Terraform configuration files, deploy your CDKTN application, and more. Refer to the [CLI commands documentation](/cli-reference/commands) for more details. You can also use some Terraform CLI commands like `terraform apply` and `terraform destroy` directly, but we recommend using the available `cdktn cli` commands where possible. If you use OpenTofu, set `TERRAFORM_BINARY_NAME=tofu`. Refer to [Environment Variables](/create-and-deploy/environment-variables) for details.

## Application Architecture

CDKTN applications are structured as a tree of [constructs](https://github.com/aws/constructs), which the AWS documentation defines as "classes that define a 'piece of system state'". The foundational classes to build a CDKTN application are `App`, `Stack`, and `Resource`.

<AppArchitectureDiagram />

### `App` Class

Each CDKTN project has one or more `App` instances that act as a container for the infrastructure configurations you create and deploy. An `App` can have one or more [`Stacks`](/concepts/stacks) that represent a collection of related infrastructure.

### `Stack` Class

A `Stack` represents a collection of infrastructure resources that CDKTN synthesizes as a separate Terraform configuration. It is equivalent to a [Terraform working directory](/terraform/cli/init).

Stacks allow you to separate the state management within an application. For example, you may want to deploy and manage separate infrastructure resources for development and testing. Reference the [stack documentation](/concepts/stacks) for more details on when and how to use stacks in your project.

### `Resource` Class

A `Resource` represents the definition for one or more infrastructure objects. Resources and their required attributes vary depending on the provider. Reference the [resources documentation](/concepts/resources) for more details.

### Constructs

Rather than defining resources by hand, you can leverage constructs to reuse existing resource configurations written in your programming language. For example, you might create a construct that describes a Kubernetes deployment, import it into your application, and customize the deployment via the exposed properties.

This is an example of a [custom construct written in TypeScript](https://github.com/skorfmann/cdktn-hybrid-module/blob/7a84cbea62fbc3c3b7e92c00d75fcaad495cf29b/packages/cdktn-hybrid-module/lib/construct.ts) that creates a machine image. The exported interface allows users to specify the instance type and one or more tags. The rest of the configuration is defined in the construct and is abstracted from the consumer.

Reference the [constructs documentation](/concepts/constructs) for more details.

### Examples

Reference the [examples page](/examples-and-guides/examples) to see configured CDKTN applications in each supported programming language.
