locals {
application_config = flatten([for config in var.configs : yamldecode(file("${path.module}/configs/workspace_config.yaml"))])
config = {
applications = local.application_config,
}
workspaces = flatten([for application in local.config.applications : [
for workspace in application.workspaces : {
workspace_name = workspace.workspace_name
workspace = workspace
}]
])
terraform_workspace_team_permissions = flatten([for workspace in local.workspaces : [
for permission in workspace.workspace.workspace_permissions : {
workspace_name = workspace.workspace_name
team_name = permission.team_name
access_type = permission.access_type
}]
])
}
when I run terraform apply I get the following error message.
│ Error: Unsupported attribute
│
│ on locals.tf line 18, in locals:
│ 18: team_name = permission.team_name
│
│ This object does not have an attribute named "team_name".
╵
╷
│ Error: Unsupported attribute
│
│ on locals.tf line 19, in locals:
│ 19: access_type = permission.accee_type
│
│ This object does not have an attribute named "accee_type".
╵
╷
If anyone could assist it would be much appreciated.
This line doesn’t make sense. For each entry in var.configs you repeatedly load the same file over and over.
This transformation seems unwise - by introducing a second different representation of a workspace, for no clear reason, the readers and writers of your code now have to figure out which representation is being used at various points in the code. I think you should avoid introducing this extra complexity - I see no reason for it.
The code you’ve shown in this question, works. I literally tested it by copy/pasting it into files and running terraform console on it. It does not produce these errors.
There is also a clear misspelling in the error message (accee_type) that’s fixed in the sample code.
Thanks for your feedback, that is so strange that it works for you, I am still getting the same error.
Also, yes you are right regarding the var.config I was playing with some options on leading different files by specifying it in the variables file, but decided to go against it and forgot to clean it up.
Could I ask how exactly did you test it with Terraform console?