-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Resource missing errors propagating over validation errors during plan #18129
Comments
It seems this issue also goes beyond just Given this example configuration: # Invalid configuration - do not use this in a real environment
terraform {
required_version = "0.11.8"
}
provider "aws" {
version = "1.36.0"
}
resource "null_resource" "test" {}
resource "aws_launch_template" "test" {
iam_instance_profile = ["${null_resource.test.id}"]
}
output "test" {
value = "${aws_launch_template.test.id}"
} And this resource schema:
On Terraform 0.11.8, it seems to output a configuration validation error correctly along with the
On the second
|
I tried the following modified version of the first example in v0.12.0-alpha2: provider "aws" {
region = "us-east-1"
}
resource "null_resource" "upstream" {
triggers = {
name = "invalid name"
}
}
# aws_iam_role is an example resource that has a ValidateFunc
resource "aws_iam_role" "test" {
assume_role_policy = "{}"
# Hardcoding this correctly returns the validation error
# name = "invalid name"
name = "${null_resource.upstream.triggers.name}"
}
resource "null_resource" "downstream" {
triggers = {
name = "${aws_iam_role.test.name}"
}
} The incorrect message about
The local validation didn't run during
Amusingly though, when I ran
This over-zealous validation during destroy is likely just another instance of #19216, not directly related to this issue. It looks like there's still a validation-related bug here for us to take care of before v0.12.0 final, so I'm going to mark this with the v0.12.0 milestone. For the second example in the later comment, I did at least get a reasonable error message out of it:
However, this particular problem is now caught be Terraform Core (by referring to the schema) rather than by the provider itself, so it makes sense that this one would work even if Terraform does not properly pass through the results of the provider's own validation: this error is detected and returned before |
I just re-tested this on v0.12.0-alpha4 and verified that it is now fixed:
The error message form is still a little strange because the providers and provider SDK could do with some more work to improve these, but that work will happen asynchronously from v0.12.0 development since these error messages are not coming from the main core executable and can thus be updated at any time. Thanks for reporting this, @bflad! |
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 have 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. |
Seemingly, when a validation error occurs in a resource (due to a failing
ValidateFunc
),terraform plan
returns missing resource errors over returning the original validation error that caused the issue even though the underlyingEvalValidateResource
notices the error.Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/bflad/62edb26125e13dbac68d0a556523f1fd
Expected Behavior
Actual Behavior
Which is output as:
Steps to Reproduce
terraform init
terraform plan
The text was updated successfully, but these errors were encountered: