1
1
Fork 0
mirror of https://github.com/adammck/terraform-inventory synced 2024-05-23 08:06:09 +02:00

Stop creating groups for tfstate attribute counts (#47)

The count attribute key in state files has changed from # to %
This commit is contained in:
Jonathan McCall 2017-06-09 14:59:21 -04:00 committed by Adam Mckaig
parent cf2e5a91a3
commit 6f4c1a9983
2 changed files with 5 additions and 2 deletions

View File

@ -44,7 +44,7 @@ const exampleStateFile = `
"attributes": {
"id": "i-aaaaaaaa",
"private_ip": "10.0.0.1",
"tags.#": "1",
"tags.%": "1",
"tags.Role": "Web"
}
}

View File

@ -118,7 +118,10 @@ func (r Resource) Tags() map[string]string {
case "aws_instance":
for k, v := range r.Attributes() {
parts := strings.SplitN(k, ".", 2)
if len(parts) == 2 && parts[0] == "tags" && parts[1] != "#" {
// At some point Terraform changed the key for counts of attributes to end with ".%"
// instead of ".#". Both need to be considered as Terraform still supports state
// files using the old format.
if len(parts) == 2 && parts[0] == "tags" && parts[1] != "#" && parts[1] != "%" {
kk := strings.ToLower(parts[1])
vv := strings.ToLower(v)
t[kk] = vv