Notes
This example is the Terraform track of the
Deploy AWS CDK and CDK Terrain with lifecycle hooks
tutorial. CDK Terrain is the community fork of
CDK for Terraform (CDKTF), which HashiCorp deprecated; it keeps the same construct model and
lets you define Terraform configuration in a general-purpose language. A TypeScript Terrain app
in components/terraform/greeting/ declares an AWS provider and one aws_ssm_parameter.
The project file is still named cdktf.json in this Terrain release, a holdover from CDKTF.
The component's synth hook installs dependencies when package-lock.json changed or the CLI is missing, then runs
npm run synth before init, plan, and apply, so
Terraform always reads a freshly generated cdk.tf.json, a Terraform configuration in JSON
syntax. No CloudFormation is involved; Terraform state tracks the resource directly.
The local stack declares a Floci AWS emulator and an
aws/emulator identity in atmos.yaml wires the AWS provider to it, so no AWS account is
needed. Remove that identity and the emulator import to deploy to a real account.
The companion cdk-cloudformation example creates the same kind of
resource from an AWS CDK app through Atmos's native CloudFormation component.
Requirements: Node.js 22.19.0 or later (CDK Terrain's minimum), npm, Terraform or OpenTofu, and Docker or Podman for the emulator.
Usage
atmos validate stacksatmos emulator up aws -s localatmos terraform plan greeting -s localatmos terraform apply greeting -s localatmos terraform output greeting -s localatmos terraform destroy greeting -s localatmos emulator down aws -s local
Change vars.message and plan again to see the regenerated configuration. To apply a saved
plan with its original generated files, run
atmos terraform apply greeting -s local --from-plan --skip-hooks=synth.
Run the whole lifecycle with atmos test.