Skip to content

Commit

Permalink
Prefix w/ tf-- if resource ID starts with digit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmingoia committed Mar 20, 2024
1 parent dea6af2 commit d65d616
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions terraformutils/hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,12 @@ func escapeRune(s string) string {
}

// Sanitize name for terraform style
// Prefix with tfer-- if starts with digit
func TfSanitize(name string) string {
name = unsafeChars.ReplaceAllStringFunc(name, escapeRune)
if (len(name) > 0 && name[0] >= '0' && name[0] <= '9') {
name = "tfer--" + name
}
return name
}

Expand Down

0 comments on commit d65d616

Please sign in to comment.