-
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
Silent Failure with "Cannot parse as an integer" when using derived value #18436
Comments
Hi @durkode! Sorry for this odd behavior. I think this is a bug that's already been addressed in the development branch for the next major release, since we've refactored a little how We still have some remaining work to do on the branch to get things ready to merge, but once we do we'll circle back here and confirm whether this is now fixed or if there's some additional work to do. Thanks for reporting this! |
Sounds good @apparentlymart, thanks for letting me know. |
Any quick workaround for this till 0.12 is out? |
@aramalipoor What I did was use the variable that count is assigned to as the output value (rather than referencing count on the resource). If count is currently just a variable, make it a variable/local first. That should fix it. |
Hi again @durkode! Sorry for the long silence here. Now that the development work has merged into master, I verified this with the v0.12.0-alpha2 prerelease build using the following config that should be equivalent to yours for the purposes of this issue, but can be applied local-only: variable "instance_count" {
default = 3
}
resource "null_resource" "a" {
count = "${var.instance_count}"
}
resource "null_resource" "b" {
count = "${null_resource.a.count}"
} Due to other changes in this release, this failed in an expected way:
In order to support using entire resources as objects in the language, we had to accept a breaking change here for the special resource "null_resource" "b" {
# (note that we no longer need the interpolation wrapper around this, either)
count = length(null_resource.a)
}
Since this fix is merged in master, I'm going to close this out. The fix will also be included in the forthcoming v0.12.0 release. Thanks again for reporting this, and sorry again for the delayed update. |
Thank you @apparentlymart, much appreciated. |
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. |
Terraform silently fails with
[WARN] Interpolation "count" failed: Error reading aws_instance.zk count: cannot parse "${var.instance_count}" as an integer
.Running a plan with a resource having a property of the count of another, the script silently fails. By that I mean the plan generates successfully (saying 3 resources will be created), terraform show outputs the plan correctly, however applying the plan exits as if successful, although the summary lists 0 resources created. Only when adding TF_LOG=DEBUG do you see the above warning
Terraform Version
Terraform Configuration Files
Relevant sections
Replacing the route53 record count with
"${var.instance_count}"
fixes the issueDebug Output
Gist Here
Crash Output
N/A
Expected Behavior
Plan applies as shown
Actual Behavior
Plan generates correctly. Apply exits successfully, but says no resources are created (when plan shows 3).
Steps to Reproduce
terraform plan
terraform apply
Additional Context
Using terraform via wrapper script, however
terraform show
shows the plan successfully and then it just runs an apply on the generated plan. Changing the route53 recordcount
to use"${var.instance_count}"
fixes the issue, so I don't think it is a problem with how I am running terraform.References
Initially thought it was #17368, however that errors rather than silently failing.
The text was updated successfully, but these errors were encountered: