-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Currently, the Terraform provisioner relies on the output of terraform graph
to determine what resource coder_metadata
instances should be applied to when building the template or workspace.
Unfortunately, it's very reasonable for a user to write a template where the output of terraform graph
does not meet what's required to correctly map the metadata to the resource, such as when using the contents of another resource to populate a field. This results in the UI showing metadata intended for one resource on another.
Here's a minimal example of this using null_resource
s:
resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
}
// Agent resource
resource "null_resource" "about" {
depends_on = [
coder_agent.main,
]
triggers = {
name = "Null About"
}
}
// Some secondary resource, such as a volume, pointing to the agent resource
resource "null_resource" "other" {
triggers = {
about_name = null_resource.about.triggers.name
}
}
// Metadata pointing to the agent resource and the volume
resource "coder_metadata" "about_info" {
resource_id = null_resource.about.id
item {
key = "other-reference"
value = null_resource.other.triggers.about_name
}
}
The graph output of this template is then:
Since null_resource.other
is the closest resource to coder_metadata.about_info
, the metadata gets assigned to it, instead of null_resource.about
, as was indicated in the template.
The same graph and graph traversal algorithm is used to determine which resource the agent exists within, so it's possible (but not proven) that this same issue effects assigning the agent to a resource.
Regardless, this should be a purely cosmetic bug, and shouldn't have any bearing on anything outside of how workspace metadata is shown in the UI.