mirror of
https://github.com/coder/coder.git
synced 2026-09-23 05:43:53 +08:00
fix: Use Terraform address to index resource + agent association (#1577)
This fixes resources created from Terraform modules not properly being associated with an agent. By not using the address, and resource identifiers prefixed with `module.<name>` would be missed!
This commit is contained in:
@@ -357,11 +357,10 @@ func parseTerraformPlan(ctx context.Context, terraform *tfexec.Terraform, planfi
|
||||
if resource.Type == "coder_agent" || resource.Type == "coder_agent_instance" {
|
||||
continue
|
||||
}
|
||||
resourceKey := strings.Join([]string{resource.Type, resource.Name}, ".")
|
||||
resources = append(resources, &proto.Resource{
|
||||
Name: resource.Name,
|
||||
Type: resource.Type,
|
||||
Agents: findAgents(resourceDependencies, agents, resourceKey),
|
||||
Agents: findAgents(resourceDependencies, agents, resource.Address),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -498,8 +497,7 @@ func parseTerraformApply(ctx context.Context, terraform *tfexec.Terraform, state
|
||||
if resource.Type == "coder_agent" || resource.Type == "coder_agent_instance" {
|
||||
continue
|
||||
}
|
||||
resourceKey := strings.Join([]string{resource.Type, resource.Name}, ".")
|
||||
resourceAgents := findAgents(resourceDependencies, agents, resourceKey)
|
||||
resourceAgents := findAgents(resourceDependencies, agents, resource.Address)
|
||||
for _, agent := range resourceAgents {
|
||||
// Didn't use instance identity.
|
||||
if agent.GetToken() != "" {
|
||||
|
||||
Reference in New Issue
Block a user