-
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 'x' not found for 'variable x.1.id' with new graph, works fine with legacy graph #13510
Comments
resource "aws_nat_gateway" "gateway_1" { resource "aws_nat_gateway" "gateway_2" { resource "aws_nat_gateway" "gateway_3" { resource "aws_subnet" "public" { |
If I hardcode the count in aws_subnet.public, then it plans fine, e.g. resource "aws_subnet" "public" { I missed this off, also: variable "aws_zones" { |
In fact, if I introduce this: variable "xaws_zones" { then this works fine: resource "aws_route_table" "public" { |
I worked around it by using a list instead of splitting a string. |
In fact, this work around has also failed. Looks like it is plain intermittent I got this while running with debug on, not that it says much more. 7/04/11 13:03:15 [ERROR] root: eval: *terraform.EvalInterpolate, err: Resource 'aws_subnet.public' not found for variable 'aws_subnet.public.2.id' |
When I did manage to get this to attempt to apply, it turned out that there was a typo in my VPC CIDR... which meant that the CIDRs for the subnets where not within the vpc range. have no idea if this was related or not It certainly wouldn't have been the first time I had the issue back in January, because simply using the legacy graph got around the issue. |
@dlcc what was it that fixed your issue exactly? I think I'm having a similar issue |
@patrick-armitage I just kept retrying the |
I'm running into this issue this evening on the latest Terraform. |
having same issue with Terraform v0.9.5 |
Thanks for the detailed info here @dlcc. I'll look at this soon and try to figure out what's going here. |
|
Having this issue with terraform 0.9.6
When running "terraform apply":
If I change the array indices to 0, apply succeeds; I can then change the indices to 1 and run "apply" again and it will actually succeed. |
+1 |
Also experiencing this issue.. when I look at the state file, it appears that the item that I am pointing to isn't even being created at all (or at least, it is not stored in the state file). I was creating this resource using a fully generated name through the
It worked fine. |
Having the same issue with the latest version of terraform (0.10.3). I have an alb listener referencing an alb target group. |
Can I try out the "legacy-graph" as the original poster did with "-Xlegacy-graph" option to terraform? |
I think I have the same issue. Terraform 0.10.7. Attempting to add instances to an 'aws_elb' resource, using the correct TYPE.NAME.ATTR reference like so:
|
I also have the same issue with terraform 0.10.7 and 0.10.8:
|
+1 |
+1 |
Terraform v0.11.0
EDIT: Removed one case as it was a typo on our side. |
@apparentlymart Is there any plans to look at this issue? It was self-assigned in May and we are 6 months on :) |
+1 |
I had such error when my aws_ecs_task_definition failed to create because of the wrong JSON in container definition. And I get error text only when I removed usage of the failed resource. Looks like a bug. |
Getting blocked by this as well. Here's a module snippet where I'm getting:
|
for me the same is coming while referring data-source variable in resource file (but for the custom provider)
|
A similar issue with the ouput (
data "template_file" "user_data" {
template = "${file("user_data.sh")}"
}
resource "aws_instance" "my_ec2" {
count = 2
ami = "${var.ami_id}"
instance_type = "t2.micro"
key_name = "${var.key_name}"
subnet_id = "${count.index +1 == 1 ? var.subnet_1 : var.subnet_2}"
user_data = "${data.template_file.user_data.rendered}"
tags {
Name = "${format("%s-ec2-%01d", var.prefix, count.index +1 )}"
}
}
resource "aws_eip" "elastic_ip" {
instance = "${aws_instance.my_ec2.0.id}"
}
output "elastic_ip" {
value = "${aws_eip.elastic_ip.public_ip}"
}
output "public_ip" {
value = "${aws_instance.my_ec2.1.public_ip}"
}
|
@mitchellh Is there any possibility this could be prioritised as it appears to be affecting a number of people and has been open quite a while. Thanks. |
Hi all, We are expecting to address this along with a number of other similar issues as part of integrating an improved interpreter for the expression language. I apologize that we haven't done a great job of tracking down all of the various GitHub issues that this current work relates to, giving the impression of inaction. We're planning to release an experimental, opt-in version of the new parser and interpreter in the near future, which we'll then use to gather feedback and verify that the various issues have been addressed. After that, we'll make Terraform use the new implementation by default. This work has started, and although we took a break over the holiday period we've now picked it up again and are currently planning the next set of changes. Sorry for the silence here. I'm going to relabel this issue so that we'll be able to find it again for future updates. |
Stumbled on this as well, the culprit was like in @kozzztya's case: malformed task_definition caused it to not be created (without errors) and then aws_ecs_service stopped with an error:
Hope this helps with debugging. |
Hello, I'm having this issue when running
The resource definitely exists and is named correctly:
If anybody has any suggestions, I'd very much appreciate it, thanks! EDIT: After a lot of googling and playing around with stuff, I'm posting this for posterity. In the template file, you cannot quote your variables and you must jsonencode them. For example, the following is correct:
|
It's not directory solving Issue but I have found that some people's issue could be due to error message handling in terraform. (haven't looked into the code yet thogh...) My error was on My issue was also with
So I deleted
(I had too long name for target_group.) |
Experienced similar issue with aws_launch_configuration hashicorp/terraform-provider-aws#4056 |
@adamist521 thanks a lot, this was exactly my problem (in my case it was |
WOW that is really frustrating. I just had a similar issue:
output "ecs_task_definition_arn" {
value = "${aws_ecs_task_definition.ecs_task_definition.arn}"
description = "ARN of the ECS task definition"
} The problem had nothing to do with the error message. The problem was that my JSON for the If I comment out the
|
I enabled DEBUG mode and found that the real error is hiding somewhere in the middle of the output:
So the real problem was that I added quotes around values for ports inside a task definition:
|
@apparentlymart is there anywhere that i can get the opt-in version? |
similar issue here. tf does not seem to find a resource with id 1:
[lukas@localhost test-mgnmt]$ terraform version
|
Hi all! The work I mentioned before was merged into master a couple weeks ago, so we've been revisiting the various issues we previously tagged as planned to be addressed by that work. Reading through the subsequent discussion since my last comment, it seems like a lot of you are encountering the same root cause as the problem over in #18129, which is actually covering the combination of two problems:
The second issue here has now been addressed through additional safety checks and a redesign of how the expression evaluation is implemented, which is merged in master and ready to be included in the forthcoming v0.12.0 final release. As you can see over in #18129, the problem that the validation errors isn't surfacing is still not solved but we intend to address it before v0.12.0 final. Given that the second problem here was surfacing in lots of different ways I used this issue as an excuse to do test one more situation that was causing this error; specifically, I adapted @dlcc's config from way back at the start of this thread to make a repro case: provider "aws" {
region = "us-west-2"
}
variable "app_name" {
default = "foo"
}
variable "environment" {
default = "bar"
}
variable "aws_zones" {
default = "us-west-2a,us-west-2b,us-west-2c"
}
variable "public_subnets" {
type = map(string)
default = {
"0" = "10.1.1.0/24"
"1" = "10.1.2.0/24"
"2" = "10.1.3.0/24"
}
}
resource "aws_vpc" "vpc" {
cidr_block = "10.1.0.0/16"
}
resource "aws_nat_gateway" "gateway_1" {
allocation_id = "${aws_eip.nat_gateway_1.id}"
subnet_id = "${aws_subnet.public.0.id}"
}
resource "aws_nat_gateway" "gateway_2" {
allocation_id = "${aws_eip.nat_gateway_2.id}"
subnet_id = "${aws_subnet.public.1.id}"
}
resource "aws_nat_gateway" "gateway_3" {
allocation_id = "${aws_eip.nat_gateway_3.id}"
subnet_id = "${aws_subnet.public.2.id}"
}
resource "aws_subnet" "public" {
count = "${length(split(",", var.aws_zones))}"
vpc_id = "${aws_vpc.vpc.id}"
availability_zone = "${element(split(",", var.aws_zones), count.index)}"
cidr_block = "${lookup(var.public_subnets, count.index)}"
tags = {
Name = "${var.app_name} public ${var.environment} ${element(split(",", var.aws_zones), count.index)}"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_eip" "nat_gateway_1" {
}
resource "aws_eip" "nat_gateway_2" {
}
resource "aws_eip" "nat_gateway_3" {
} I was able to apply this without problems, which matches what I've seen with this in other cases where the validation-related problem wasn't the root cause. Since we already have #18129 tracking the validation error bug, I'm going to close this one out now. I also wanted to quickly address the comment I made earlier about a "preview release": unfortunately our plans for that had to change along the way when it proved to be impractical to ship both the new and old configuration engines in the same release. However, we do now have a v0.12.0-alpha2 release which is intended to serve the same purpose as that opt-in preview would've. Please do not use it against any "real" infrastructure -- there are still many things to fix -- but if you'd like to try it with your own examples in a experimental way, we'd be grateful for any new top-level issues if you find any non-validation-related instances where similar problems might still be occurring. Thank you all for sharing your examples and error messages here -- they were all very useful in tracking down the different situations that were addressed in the new build, even though we didn't address each one individually in comments -- and for your continued patience while we finish up this complex release. |
In my case the problem was also related to the parent resource, but with Azure:
But Terraform 💔 Failed to give feedback on:
PD: I know the issue Is closed, I just made the comment to ease the debugging of other fellow Terraform/Azure users that might stumble upon the same problem, and end up looking this at this Issue, as I did. |
@iamsortiz I have an embedded access_policy, and if i remove it it seems to not complain. Did you happen to see that at all? |
I have my KeyVault access policies as 'isolated resources' instead of embedded, so I didn't get to see the behaviour you describe. I'll try in future refactors with the 'embedded way'. Maybe this way if the parent resource fails, it will explicitly say so, and the error feedback will be more clear and to the point. Thank you : D |
@iamsortiz Thanks for the response. Yeah that was where I was originally, experimenting in a lot of places. Small question, have you tried setting key vault secrets? If so, did you get it to work? I'm strugging with 403 errors and other github issue posts haven't helped. :( |
Yes indeed
Yes
I guess you are ❌ missing a KeyVault "access policy"❌ giving you permission to write a secret (RBAC is not enough)
Example with admin-like rights: # [EXPLANATION] You can get the "tenant_id" from this data. You'll needed to setup the KeyVault Access Policy
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault_access_policy" "AccessPolicy-Admins" {
vault_name = "${azurerm_key_vault.KeyVault.name}"
resource_group_name = "${azurerm_key_vault.KeyVault.resource_group_name}"
# [EXPLANATION] Data needed, coming from "azurerm_client_config"
tenant_id = "${data.azurerm_client_config.current.tenant_id}"
# [CHANGETHIS] You need the ID from a Azure Active Directory user or group here
object_id = "${var.Auth-Admins}"
# [EXPLANATION] Admin-like permissions
certificate_permissions = ["create", "delete", "deleteissuers", "get", "getissuers", "import", "list", "listissuers", "managecontacts", "manageissuers", "purge", "recover", "setissuers", "update"]
key_permissions = ["backup", "create", "decrypt", "delete", "encrypt", "get", "import", "list", "purge", "recover", "restore", "sign", "unwrapKey", "update", "verify", "wrapKey"]
secret_permissions = ["backup", "delete", "get", "list", "purge", "recover", "restore", "set"]
}
Good luck ! ❤️ |
I am getting similar issue trying to refer route53_resolver_endpoint id from aws_route53_resolver_rule
Error is:
|
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. |
Hi,
I am still having ongoing issues with:-
#11437
Following on from the previous issue, I was able to progress with using the legacy graph. Having upgraded TF along the way, I was able to use the new graph against the resultant infrastructure. However, I am trying to re-use the same TF files for a new installation and I am back to the same error but no choice to go back to legacy graph!
Error running plan: 1 error(s) occurred:
aws_nat_gateway.gateway_2: 1 error(s) occurred:
aws_nat_gateway.gateway_2: Resource 'aws_subnet.public' not found for variable 'aws_subnet.public.1.id'
$ terraform -v
Terraform v0.9.1
The text was updated successfully, but these errors were encountered: