All available commands are described in the help file.
The defined stacks are listed:
cdktf list
Output:
Stack name Path
learn-cdktf-go cdktf.out/stacks/learn-cdktf-go
The next step is to create the hcl file with:
cdktf synth
You could step that step and go right to deploy. But with a synth before you check for errors before deploying.
Now in cdktf.out/stacks/learn-cdktf-go/cdk.tf.json the hcl file is generated
With the plan command you can see which resources will be created/changed/destroyed in the next apply run:
cdktf plan
Output
Stack: learn-cdktf-go
Resources
+ AWS_INSTANCE cdktfgo aws_instance.cdktfgo
Diff: 1 to create, 0 to update, 0 to delete.
With plan you check whether the crud action for the resources are as intended. Here we want to create an instance, so it’s ok.
With apply the resource(s) are created:
cdktf apply
Output while apply-ing:
⠧ Deploying Stack: learn-cdktf-go
Resources
⠼ AWS_INSTANCE cdktfgo aws_instance.cdktfgo
Summary: 0 created, 0 updated, 0 destroyed.
Output at the end:
Summary: 1 created, 0 updated, 0 destroyed.
Output: public_ip = 35.158.212.152
For the cleanup you destroy the stack:
cdktf destroy
Output:
Destroying Stack: learn-cdktf-go
Resources
✔ AWS_INSTANCE cdktfgo aws_instance.cdktfgo
Summary: 1 destroyed.