Skip to content

Commit

Permalink
Translate bool->string explicitly when they don't match
Browse files Browse the repository at this point in the history
This is necessary since implicit conversions cast to int, true->1, false->0 instead of to
string: true->"true", false->"false". The latter is what Terraform providers expect.
  • Loading branch information
iwahbe committed Aug 2, 2023
1 parent 5d215c8 commit cd9ad00
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/tfbridge/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ func (ctx *conversionContext) MakeTerraformInput(name string, old, v resource.Pr
case v.IsNull():
return nil, nil
case v.IsBool():
if tfs != nil && tfs.Type() == shim.TypeString {
if v.BoolValue() {
return "true", nil
}
return "false", nil
}
return v.BoolValue(), nil
case v.IsNumber():
if tfs != nil && tfs.Type() == shim.TypeFloat {
Expand Down

0 comments on commit cd9ad00

Please sign in to comment.