Cloud Development Kit for Terraform
This is pre-release documentation.
CDKTF is ready for production use but configurations are subject to change.
Configuration
Terrateam Configuration
Terrateam behavior can be configured via a config.yml
. This file is located in
a directory named .terrateam
at the root of your Terraform repository:
.terrateam/config.yml
.
See Configuration documentation for details.
Terrateam configuration updates are required in order to enable CDKTF.
Full Example
Repository Layout
josh@elmer:~ $ tree cdktf-code/
cdktf-code/
└── prod
└── main.ts
1 directory, 1 file
CDKTF in TypeScript
cdktf-code/prod/main.ts
import { Construct } from "constructs";
import { App, TerraformStack } from "cdktf";
import * as Null from './.gen/providers/null';
class MyStack extends TerraformStack {
constructor(scope: Construct, id: string) {
super(scope, id);
new Null.provider.NullProvider(this, 'test-provider');
new Null.resource.Resource(this, 'test');
}
}
const app = new App();
new MyStack(app, "cdktf-stack1");
app.synth();
Terrateam Configuration
.terrateam/config.yml
workflows:
- tag_query: cdktf-code
cdktf: true
dirs:
prod:
tags: [cdktf-code]
when_modified:
file_patterns: ['${DIR}/*.ts']
stacks:
'cdktf-stack1':
tags: []
'cdktf-stack2':
tags: []
Configuration Explained
- Lines 1-3: Any directory containing the tag
cdktf-code
will enable CDKTF in a Terrateam operation. See Workflows for details. - Lines 7-8: The
prod
directory:- Terrateam operations should be triggered if any file with matches the
*.ts
pattern is changed in a pull request. - Assign the tag
cdktf-code
to be used inworkflows
. - Define two stacks:
cdktf-stack1
,cdktf-stack2
. See When Modified for details.
- Terrateam operations should be triggered if any file with matches the
Planning and Applying
Terrateam operations are identical when CDKTF is enabled. However, enabling CDKTF does create an additional implicit tag to match on the stack giving users the flexibility to run operations against stacks.
For example, to plan any directory with a stack named cdktf-stack1
, one could
comment the following in a pull request:
terrateam plan stack:cdktf-stack1