Hi I’m creating AWS Network Interface terraform module and getting below error -
Error: Unsupported attribute
│
│ on aws-nt-locals.tf line 11, in locals:
│ 11: id = module.test1-eni.id
│ ├────────────────
│ │ module.test1-eni is object with 1 attribute “plan-sg”
│
│ This object does not have an attribute named “id”.
Oh, I see, you’ve concatenated the module code and the calling code with no visible separator, making it rather non-obvious that there are two separate code snippets there.
Hi mate thanks for the heads up. Have read the welcome message and reacted. Updated the post according to the welcome message. you can view the code snippet in proper way now.
So i need to reference the child module id in parent output ??
Kindly let me know. Thanks
Your copy/pasted code is still confusing, as there is still no indication which bits come from which files and directories. You should break it up into separate blocks for each file, and clearly state the directory path to each file above each block.
I do not understand what you mean when you say
but it doesn’t sound correct to me.
The problem is simple:
You have written a reference to a module output (module.test1-eni.id).
You have not defined any such output (output "id" { ... }) in that module, so you get an error.
Please refer to the documentation link I provided above which documents these matters.
This is the first time you’ve disclosed that this part of the configuration exists. That has wasted a lot of time, as it pretty much invalidates the entire conversation up to this point.
Thank you for the new, better formatted, complete code post. From that, I can see the real problem is something entirely different:
This part of your configuration is incorrect:
because you have used for_each here:
meaning that module.test1-eni is not a single module, but a collection of multiple module instances.
You must decide which of those you are trying to look up the id attribute from: