Is the CDKTF CLI’s get
command intended to be idempotent? If so, then why does it rebuild already-built components regardless of whether their source code has changed?
I have novice-level familiarity with Terraform and am doing some evaluation of use of its CDK with Go.
Initially, upon running cdktf get
on a sample project, I believed it to be failing, as the “downloading and generating modules and providers…” message would spin for several minutes before I gave up and terminated it.
Curious what was happening, and seeing only very terse output, I tried running with --verbose
, which was ignored. I looked at the inbuilt help, saw the --log-level
option, suspected it might log to standard out or standard error, tried running with --log-level=INFO
, --log-level=debug
and such, to no avail, then read more closely, saw the note, “Only supported via setting the env CDKTF_LOG_LEVEL”, set that environment variable, discovered that something was happening, gave it time to complete, and found that this operation, even with a simple project, on a very powerful machine with 64 GB of RAM, required six minutes to complete.
I later found discussion on this forum indicating that this operation, even to build a single provider, might take an hour or two for Go.
Once I understood that “get” in this context is a bit of a misnomer, as it results in building/compiling/creating one or more components rather than simply fetching/retrieving/getting them, I expected that a subsequent run with the same source would complete much more quickly. In my experience, a build operation is typically idempotent–repeat runs under the same circumstances do not typically result in any changes. Typically, something like make
is used to recognize that a given component has already been built, and to refrain from rebuilding it if its source has not changed. Such is apparently not the case with `cdktf build, as my repeat runs, seconds after a previous one, take roughly the same amount to complete as the first run took, and I assume that whatever source code the utility may retrieve from remote repositories is not changing on this frequency.
I understand that CDKTF users will likely someday be able to avoid the need for building Go providers locally. Until then, I hope to better understand what is happening, and ultimately how to determine in an automated fashion if and when to “re-get” (to regenerate CDK Constructs for Terraform providers and modules).
I did some related web searches and searched this forum, but I’ve found no specifically-related documentation or discussion. I read the CDK constructs and cdkt get command docs. I’ve not looked at cdktf’s source code.