June 20-22 Announcing HashiConf Europe full schedule: keynotes, sessions, labs & more Register Now
  • Overview
    • Enforce Policy as Code
    • Infrastructure as Code
    • Inject Secrets into Terraform
    • Integrate with Existing Workflows
    • Manage Kubernetes
    • Manage Network Infrastructure
    • Manage Virtual Machine Images
    • Multi-Cloud Deployment
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
  • Registry
  • Tutorials
    • About the Docs
    • Intro to Terraform
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
    • Terraform Tools
    • CDK for Terraform
    • Glossary
  • Community
GitHubTerraform Cloud
Download

    CDK for Terraform

  • Overview
  • Get Started
    • Architecture
    • HCL Interoperability
    • Constructs
    • Providers and Resources
    • Modules
    • Data Sources
    • Variables and Outputs
    • Functions
    • Remote Backends
    • Aspects
    • Assets
    • Tokens
    • Stacks
  • Examples and Guides
    • Project Setup
    • Configuration File
    • Best Practices
    • Environment Variables
    • Remote Templates
    • AWS Adapter [preview]
    • Unit Tests
    • Debugging
    • CLI Configuration
    • Commands
    • Overview
    • Upgrading to Version 0.6
    • Upgrading to Version 0.7
    • Upgrading to Version 0.9
    • Upgrading to Version 0.10
    • Upgrading to Version 0.11
  • Community
  • Telemetry
  • Other Docs

  • Intro to Terraform
  • Configuration Language
  • Terraform CLI
  • Terraform Cloud
  • Terraform Enterprise
  • Provider Use
  • Plugin Development
  • Registry Publishing
  • Integration Program
  • Terraform Tools
  • CDK for Terraform
  • Glossary
Type '/' to Search

»Upgrading to CDK for Terraform Version 0.10

0.10 includes improvements to the provider code bindings, to allow referencing lists of computed attributes as a whole list instead of just individual items of that list. We also shipped a lot of CLI improvements in 0.10, including support for multiple stacks in cdktf deploy, cdktf output, and cdktf destroy.

»Remove cdktf synth --json Option #1640

If you are using cdktf synth --json <stack-name> to get the synthesized JSON configuration for your Stack, you will now need to run cdktf synth && cat ./cdktf.out/stacks/<stack-name>/cdk.tf.json instead. The ./cdktf.out part is your output directory (set by cdktf.json or via the --output flag).

»Model ComplexComputedLists as ComplexLists and ComputedObjects #1499

In an effort to streamline the interfaces of resources, computed attributes of the type list and set are now modeled as a separate ComplexList type instead of being a method that directly takes an index and returns an item. This change also did change the type of the index from string to number.

»Typescript

// previously
const firstItemId = resource.listAttribute("0").id;

// new
const firstItemId = resource.listAttribute.get(0).id;
const firstItem = resource.listAttribute.get(0); // now possible
// previously
const firstItemId = resource.listAttribute("0").id;

// new
const firstItemId = resource.listAttribute.get(0).id;
const firstItem = resource.listAttribute.get(0); // now possible

»Python

# previously
first_item_id = resource.list_attribute("0").id;

# new
first_item_id = resource.list_attribute.get(0).id;
first_item = resource.list_attribute.get(0); # now possible
# previously
first_item_id = resource.list_attribute("0").id;

# new
first_item_id = resource.list_attribute.get(0).id;
first_item = resource.list_attribute.get(0); # now possible

»CSharp

// previously
string firstItemId = resource.ListAttribute("0").Id;

// new
string firstItemId = resource.ListAttribute.Get(0).Id;
ListAttributeItem firstItem = resource.ListAttribute.Get(0); // now possible
// previously
string firstItemId = resource.ListAttribute("0").Id;

// new
string firstItemId = resource.ListAttribute.Get(0).Id;
ListAttributeItem firstItem = resource.ListAttribute.Get(0); // now possible

»Java

// previously
String firstItemId = resource.listAttribute("0").getId();

// new
String firstItemId = resource.getListAttribute().get(0).getId();
ListAttributeItem firstItem = resource.getListAttribute().get(0); // now possible
// previously
String firstItemId = resource.listAttribute("0").getId();

// new
String firstItemId = resource.getListAttribute().get(0).getId();
ListAttributeItem firstItem = resource.getListAttribute().get(0); // now possible

»Go

// previously
firstItemId := resource.ListAttribute(jsii.String("0")).Id();

// new
firstItemId := resource.ListAttribute().Get(jsii.Number(0)).Id();
firstItem := resource.ListAttribute().Get(jsii.Number(0)); // now possible
// previously
firstItemId := resource.ListAttribute(jsii.String("0")).Id();

// new
firstItemId := resource.ListAttribute().Get(jsii.Number(0)).Id();
firstItem := resource.ListAttribute().Get(jsii.Number(0)); // now possible

»Referencing computed string map entries via function call #1630

In preparation for a similar change as to the computed lists (section above), string map entries can now be accessed via a function call instead of using Fn.lookup. Accessing the whole map at once now requires a different function call in the meantime.

»Example

const bucket = new s3.S3Bucket(this, "bucket");

// previously
const firstRuleStage = Fn.lookup(
  bucket.lifecycleRule("0").tags,
  "stage",
  "no-stage"
);
const firstRuleTags = bucket.lifecycleRule("0").tags;

// new
const firstRuleStage = bucket.lifecycleRule.get(0).tags("stage"); // tags is now a function
const firstRuleTags = bucket.lifecycleRule
  .get(0)
  .interpolationForAttribute("tags"); // will be improved in a future iteration
const bucket = new s3.S3Bucket(this, "bucket");

// previously
const firstRuleStage = Fn.lookup(
  bucket.lifecycleRule("0").tags,
  "stage",
  "no-stage"
);
const firstRuleTags = bucket.lifecycleRule("0").tags;

// new
const firstRuleStage = bucket.lifecycleRule.get(0).tags("stage"); // tags is now a function
const firstRuleTags = bucket.lifecycleRule
  .get(0)
  .interpolationForAttribute("tags"); // will be improved in a future iteration
github logoEdit this page
  • Overview
  • Docs
  • Extend
  • Privacy
  • Security
  • Press Kit
  • Consent Manager