Cdktf Generated Java Code Does not Compile

I cannot get the cdktf generated Java code to compile. I’ve tried generating code for the Akamai provider.

cdktf version: 0.17.0 (not using 0.18.0 because it unfortunately uses Gradle instead of Maven)

Java version: 1.8 (Used 1.8 because I noticed that is the target used for com.hashicorp:cdktf-provider-aws)

Commands used to generate the code:

cdktf init --template="java" --providers="akamai/akamai" --local
cdktf get


  "language": "java",
  "app": "mvn -e -q compile exec:java",
  "projectId": "df543c03-be5f-4bb5-9e05-6012aa166781",
  "sendCrashReports": "true",
  "codeMakerOutput": "src/main/java/imports",
  "terraformProviders": [
    "akamai/akamai@~> 5.1"
  "terraformModules": [],
  "context": {}

The cdktf [get|init] commands succeed, but the generated code contains multiple compilation errors, mostly to do with the *Config classes.

[ERROR] cdktf-provider-akamai/src/main/java/imports/akamai/dns_record/[1064,48] error: cannot find symbol
  symbol:   variable amazon
  location: variable software of type String
[ERROR] cdktf-provider-akamai/src/main/java/imports/akamai/dns_record/[1064,76] error: an enum annotation value must be an enum constant

I’ve also noticed these compilation errors are present in the officially released Java providers, for example the AWS Provider.

Would it be possible to know how the cdktf-provider-aws project was compiled?

There does appear to be a bug in the code generator for that specific resource.
A simple workaround would be commenting out the software fields in that file and any code that references them (including a reference in

This isn’t an issue just for that one DnsRecordConfig class. This is broken for all generated *Config classes. Also as I’ve shown, this is also an issue for the code in the cdktf-provider-aws library that Hashicorp have deployed to maven central.

The cdktf is currently generating completely broken Java code that cannot be used.

I’m not observing the same behavior locally. After working around the one issue, the akamai provider code is compiling just fine.
As far as I’m aware, the published providers must compile successfully before being published as well.

Can you please post the versions you are using of the following?


Also can you please confirm that you are successfully running these two commands in the following order with the configuration I posted above?

cdktf get
mvn clean compile

Ok, so I have to apologise jsteinich, you are absolutely right, it is only the DnsRecord resource that is causing the issues. I deleted it and everything else is compiling fine.

I don’t know why my IDE is complaining about all the other files, but if the JDK can compile them then there must not be any actual issues.

I just got completely bamboozled by my IDE. Thank you jsteinich for identifying the actual issue :slight_smile:

You’re welcome. I also filed an issue so that the underlying problem can hopefully be addressed.