Skip to content

Commit ba818b3

Browse files
authored
fix: Append Terraform module resources to list (#1539)
This was causing module resources to be skipped!
1 parent 72c2bf8 commit ba818b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

provisioner/terraform/provision.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,15 @@ func parseTerraformPlan(ctx context.Context, terraform *tfexec.Terraform, planfi
290290
resources := make([]*proto.Resource, 0)
291291
agents := map[string]*proto.Agent{}
292292

293-
tfResources := plan.Config.RootModule.Resources
293+
tfResources := make([]*tfjson.ConfigResource, 0)
294294
var appendResources func(mod *tfjson.ConfigModule)
295295
appendResources = func(mod *tfjson.ConfigModule) {
296296
for _, module := range mod.ModuleCalls {
297297
appendResources(module.Module)
298298
}
299299
tfResources = append(tfResources, mod.Resources...)
300300
}
301+
appendResources(plan.Config.RootModule)
301302

302303
// Store all agents inside the maps!
303304
for _, resource := range tfResources {
@@ -416,14 +417,15 @@ func parseTerraformApply(ctx context.Context, terraform *tfexec.Terraform, state
416417
}
417418
agents := map[string]*proto.Agent{}
418419

419-
tfResources := state.Values.RootModule.Resources
420+
tfResources := make([]*tfjson.StateResource, 0)
420421
var appendResources func(resource *tfjson.StateModule)
421422
appendResources = func(mod *tfjson.StateModule) {
422423
for _, module := range mod.ChildModules {
423424
appendResources(module)
424425
}
425426
tfResources = append(tfResources, mod.Resources...)
426427
}
428+
appendResources(state.Values.RootModule)
427429

428430
// Store all agents inside the maps!
429431
for _, resource := range tfResources {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy