Repository: pulumi/pulumi-terraform-bridge
Pull request #407 (2021-10-29 17:48:06)

Ensure all variants of primitives are covered in TF Schema Overrides
Currently, the type needed to be correct "int" or "boolean" and that
wasn't obvious in the TF providers. So we now cater for "integer" and
"bool" to ensure that they are now all defaulting to strings

Without these additional cases, we could end up in a statement of
DotNet getting the incorrect type (i.e a string when it expected a double)
and thus throwing an error as follows:

```
System.InvalidOperationException: Expected System.Double but got System.String deserializing Pulumi.Aws.LB.TargetGroup.deregistrationDelay
```


github-actions[bot]: Diff for [pulumi-aws](https://github.com/pulumi-bot/pulumi-aws/compare/16db521d1..a8ee3d96b) with merge commit c8be7c9aa4b13d53381434c885c339ead7f5267b
github-actions[bot]: Diff for [pulumi-azure](https://github.com/pulumi-bot/pulumi-azure/compare/1d1b7ffda..12e1137e0) with merge commit c8be7c9aa4b13d53381434c885c339ead7f5267b

Patch:
diff --git a/pkg/tfbridge/schema.go b/pkg/tfbridge/schema.go
index 1c58b9e1..7b553c1c 100644
--- a/pkg/tfbridge/schema.go
+++ b/pkg/tfbridge/schema.go
@@ -955,12 +955,12 @@ func CoerceTerraformString(schType shim.ValueType, ps *SchemaInfo, stringValue s
 	// breaking overrides where we have a string and a TransformJSONDocument (see pulumi/pulumi#4592)
 	if ps != nil && ps.Type != "" {
 		switch strings.ToLower(ps.Type.String()) {
-		case "boolean":
+		case "bool", "boolean":
 			if stringValue == "" {
 				return nil, nil
 			}
 			return convertTfStringToBool(stringValue)
-		case "int":
+		case "int", "integer":
 			return convertTfStringToInt(stringValue)
 		case "float":
 			return convertTfStringToFloat(stringValue)


Test patch:
diff --git a/pkg/tfbridge/schema_test.go b/pkg/tfbridge/schema_test.go
index 0cd0f953..396ee23d 100644
--- a/pkg/tfbridge/schema_test.go
+++ b/pkg/tfbridge/schema_test.go
@@ -937,21 +937,36 @@ func TestOverridingTFSchema(t *testing.T) {
 		shimv1.NewProvider(testTFProvider),
 		map[string]interface{}{
 			"pulumi_override_tf_string_to_boolean":    MyString("true"),
+			"pulumi_override_tf_string_to_bool":       MyString("true"),
 			"pulumi_empty_tf_override":                MyString("true"),
+			"pulumi_override_tf_string_to_int":        MyString("1"),
+			"pulumi_override_tf_string_to_integer":    MyString("1"),
 			"tf_empty_string_to_pulumi_bool_override": MyString(""),
 		},
 		shimv1.NewSchemaMap(map[string]*schemav1.Schema{
 			"pulumi_override_tf_string_to_boolean":    {Type: schemav1.TypeString},
+			"pulumi_override_tf_string_to_bool":       {Type: schemav1.TypeString},
 			"pulumi_empty_tf_override":                {Type: schemav1.TypeString},
+			"pulumi_override_tf_string_to_int":        {Type: schemav1.TypeString},
+			"pulumi_override_tf_string_to_integer":    {Type: schemav1.TypeString},
 			"tf_empty_string_to_pulumi_bool_override": {Type: schemav1.TypeString},
 		}),
 		map[string]*SchemaInfo{
 			"pulumi_override_tf_string_to_boolean": {
 				Type: "boolean",
 			},
+			"pulumi_override_tf_string_to_bool": {
+				Type: "bool",
+			},
 			"pulumi_empty_tf_override": {
 				Type: "",
 			},
+			"pulumi_override_tf_string_to_int": {
+				Type: "int",
+			},
+			"pulumi_override_tf_string_to_integer": {
+				Type: "integer",
+			},
 			"tf_empty_string_to_pulumi_bool_override": {
 				Type:           "boolean",
 				MarkAsOptional: boolPointer(true),
@@ -963,7 +978,10 @@ func TestOverridingTFSchema(t *testing.T) {
 	)
 	assert.Equal(t, resource.NewPropertyMapFromMap(map[string]interface{}{
 		"pulumiOverrideTfStringToBoolean":   true,
+		"pulumiOverrideTfStringToBool":      true,
 		"pulumiEmptyTfOverride":             "true",
+		"pulumiOverrideTfStringToInt":       1,
+		"pulumiOverrideTfStringToInteger":   1,
 		"tfEmptyStringToPulumiBoolOverride": nil,
 	}), result)
 }