-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Value of count cannot be computed when using a map containing a reference to a resource #15471
Comments
@betabandido this is expected because since the value of
@apparentlymart gave me a good explanation a while ago. Here you go! @betabandido by building the |
Isn't it possible to use some sort of lazy evaluation? As the keys in the map are plain strings, their number does not depend on the potential contents of the map values. Therefore, If this is just impossible, I suppose an alternative is to first create the SNS topic using |
@betabandido yep using |
I'm hitting the same error following the sample in the documentation - is this not valid? https://www.terraform.io/docs/configuration/interpolation.html#using-templates-with-count |
This appears to be a massive limitation - "count" appears to be a necessity in reducing the amount of code/text written which helps to keep the code maintainable as it reduces having to duplicate code unnecessarily. I have use of count only to prevent resources in modules from being "run" but "count cannot compute" comes up and scuppers what i wrote. Using target in a wrapper script once is fine but more than once is often a headache and error prone especially when trying to write "sane" non-complex DRY terraform This is a Big limitiation |
Hitting the same issue. Would be glad to see it fixed. |
Hello All, The behavior here is specific to a very old version of terraform, so I'm going to close this out. The arguments to We use GitHub issues for tracking bugs and enhancements, rather than for questions. While we can sometimes help with certain simple problems here, it's better to use the community forum where there are more people ready to help. |
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 Version
Terraform v0.9.11
Problem description
We are creating a module to set up AWS cloudwatch alarms. The module accepts a map containing the configuration for each of the alarms that users want to configure (
var.alarms
). Then we instantiate multipleaws_cloudwatch_metric_alarm
resources usingcount
.Everything works fine until
var.alarms
contains a reference to another resource. In the example, we use the ARN for an SNS topic, but we have tried other resources such as the deployment ARN and it fails as well.The error message is:
module.api_cloudwatch_alarms.aws_cloudwatch_metric_alarm.alarm: aws_cloudwatch_metric_alarm.alarm: value of 'count' cannot be computed
Terraform Configuration Files
main.tf
api_cloudwatch_monitors/main.tf
Debug Output
https://gist.github.com/betabandido/e4fe821a5d08b1a291e508c7a163c4eb
The text was updated successfully, but these errors were encountered: