You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the below example, cdk synth should output an error that a provider is used improperly. Otherwise, an invalid file is created that could move further along in a build process to an apply step. There are likely other scenarios where synth should provide more feedback / errors.
// main.tsimport{Construct}from"constructs";import{App,TerraformStack}from"cdktf";import{Container}from"./.gen/providers/docker";classMyStackextendsTerraformStack{constructor(scope: Construct,name: string){super(scope,name);// The line below is a semantic error, a Container should not be able to be instantiated without a Provider defined but this dependency does not show anywhere.newContainer(this,"my-container",{image: "ubuntu",name: "ubuntu-test",});}}constapp=newApp();newMyStack(app,"cdktf-test-docker");app.synth();
This has no build issues and runs through synth and creates a full output file set, but it is not terraform applyable or cdktf deployable because Container has a dependency on a Provider being defined before its called. There is no enforcement of that at the synth step, which results in aruntime error when trying to run cdktf deploy
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/docker: provider registry registry.terraform.io does not have a
provider named registry.terraform.io/hashicorp/docker
cdktf synth should be throwing an error when new Container() is called and the context does not have a corresponding provider already defined. The error doesn't occur until Terraform is trying to resolve the providers, which results in the unclear error message from Terraform which was really an issue in the synth step.
Here is the cdk.tf.json output file. Notice it doesn't have required providers referenced at all, so the docker_container resource cannot be resolved properly.
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Based on the below example,
cdk synth
should output an error that a provider is used improperly. Otherwise, an invalid file is created that could move further along in a build process to an apply step. There are likely other scenarios wheresynth
should provide more feedback / errors.This has no build issues and runs through synth and creates a full output file set, but it is not
terraform apply
able orcdktf deploy
able becauseContainer
has a dependency on aProvider
being defined before its called. There is no enforcement of that at the synth step, which results in aruntime error when trying to runcdktf deploy
cdktf synth
should be throwing an error whennew Container()
is called and the context does not have a corresponding provider already defined. The error doesn't occur until Terraform is trying to resolve the providers, which results in the unclear error message from Terraform which was really an issue in the synth step.Here is the
cdk.tf.json
output file. Notice it doesn't have required providers referenced at all, so the docker_container resource cannot be resolved properly.Originally posted by @lukep-coxauto in #465 (comment)
The text was updated successfully, but these errors were encountered: