Skip to content

Commit

Permalink
Merge pull request #5 from kaytu-io/fix-state-arns
Browse files Browse the repository at this point in the history
fix: get arns with state object
  • Loading branch information
artaasadi authored Sep 11, 2023
2 parents ebccc51 + 75f9543 commit d82ecb9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions external/states/statefile/resources.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package statefile

import (
"github.com/kaytu-io/terraform-package/external/states"
"io"
"sort"

Expand All @@ -17,9 +18,12 @@ func GetResourcesArn(f io.Reader) []string {
panic(err)
}

arns := make([]string, 0)

state := result.State
return GetArnsFromStateFile(state)
}

func GetArnsFromStateFile(state *states.State) []string {
arns := make([]string, 0)
for _, ms := range state.Modules {
addrsOrder := make([]addrs.AbsResourceInstance, 0, len(ms.Resources))
for _, rs := range ms.Resources {
Expand Down Expand Up @@ -67,9 +71,13 @@ func GetResourcesTypes(f io.Reader) []string {
panic(err)
}

state := result.State
return GetResourcesTypesFromState(state)
}

func GetResourcesTypesFromState(state *states.State) []string {
types := make([]string, 0)

state := result.State
for _, ms := range state.Modules {
for _, re := range ms.Resources {
types = append(types, re.Addr.Resource.Type)
Expand Down

0 comments on commit d82ecb9

Please sign in to comment.