Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3fe2a0

Browse files
authored
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!
1 parent 0706c60 commit f3fe2a0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

provisioner/terraform/provision.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,10 @@ func parseTerraformPlan(ctx context.Context, terraform *tfexec.Terraform, planfi
357357
if resource.Type == "coder_agent" || resource.Type == "coder_agent_instance" {
358358
continue
359359
}
360-
resourceKey := strings.Join([]string{resource.Type, resource.Name}, ".")
361360
resources = append(resources, &proto.Resource{
362361
Name: resource.Name,
363362
Type: resource.Type,
364-
Agents: findAgents(resourceDependencies, agents, resourceKey),
363+
Agents: findAgents(resourceDependencies, agents, resource.Address),
365364
})
366365
}
367366

@@ -498,8 +497,7 @@ func parseTerraformApply(ctx context.Context, terraform *tfexec.Terraform, state
498497
if resource.Type == "coder_agent" || resource.Type == "coder_agent_instance" {
499498
continue
500499
}
501-
resourceKey := strings.Join([]string{resource.Type, resource.Name}, ".")
502-
resourceAgents := findAgents(resourceDependencies, agents, resourceKey)
500+
resourceAgents := findAgents(resourceDependencies, agents, resource.Address)
503501
for _, agent := range resourceAgents {
504502
// Didn't use instance identity.
505503
if agent.GetToken() != "" {

0 commit comments

Comments
 (0)