Skip to content

Commit

Permalink
bugfix: invalid format for imports.tf (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu authored Dec 18, 2023
1 parent d0f4245 commit c053e4f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions types/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ func (r GenericResource) EmptyImportConfig() string {
if !r.IsForEach() {
return fmt.Sprintf(`resource "%s" "%s" {
count = %d
}`, r.ResourceType, r.Label, len(r.Instances))
}
`, r.ResourceType, r.Label, len(r.Instances))
}
keys := make([]string, 0)
for _, instance := range r.Instances {
keys = append(keys, fmt.Sprintf(`"%s"`, instance.Index))
}
return fmt.Sprintf(`resource "%s" "%s" {
for_each = toset([%s])
}`, r.ResourceType, r.Label, strings.Join(keys, ","))
}
`, r.ResourceType, r.Label, strings.Join(keys, ","))
}
return fmt.Sprintf("resource \"%s\" \"%s\" {}\n", r.ResourceType, r.Label)
}
Expand Down

0 comments on commit c053e4f

Please sign in to comment.