Skip to content

Commit

Permalink
GetResourceType function added
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed May 20, 2023
1 parent 50a35d0 commit ebccc51
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions external/states/statefile/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,21 @@ func GetResourcesArn(f io.Reader) []string {
}
return arns
}

// Returns the list of resource types
func GetResourcesTypes(f io.Reader) []string {
result, err := Read(f)
if err != nil {
panic(err)
}

types := make([]string, 0)

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

0 comments on commit ebccc51

Please sign in to comment.