-
Notifications
You must be signed in to change notification settings - Fork 988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: data source kubernetes_resource
returns null when resource does not exist
#1955
Comments
kubernetes_resource
returns null when resource does not existskubernetes_resource
returns null when resource does not exist
I have come across the same thing When trying to check for an already existent or not deployment - of course when it exists it works when it doesn't Fail with the same error output : Error: Provider produced null object this is really stupid in my opinion - should be either in a try block or someother way to indicate that it returned a null instead of failing now one has to find workaround to achieve this... |
Has anyone found a workaround for this issue? I'm trying to check if a CRD exists in the cluster so I know if another resource can be installed. |
This is possibile using data kubernetes_resources using
then use conditional resource like:
be careful as there are |
This doesn't work because
|
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you! |
When k8s resource described in
data.kubernetes_resource
does not existterraform plan/apply
ends with error.When resource exists, data is correctly returned.
I am trying to use this data source to verify if required Helm chart (MetalLB) is installed and CRDs exist.
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
kubernetes_resource
Terraform Configuration Files
Debug Output
https://gist.github.com/redzioch/967808d1b7b3eb436ba3a2f4177f41a6
Steps to Reproduce
git clone https://github.com/redzioch/terraform-kubernetes-resource-error.git
terraform plan
Expected Behavior
When resource does not exist,
data.kubernetes_resource.address_pool_crd.object
should benull
.Actual Behavior
Community Note
The text was updated successfully, but these errors were encountered: