diff --git a/templates/terraform/custom_flatten/default_if_empty.erb b/templates/terraform/custom_flatten/default_if_empty.erb index 6f608d211ed6..be21ab97e4cc 100644 --- a/templates/terraform/custom_flatten/default_if_empty.erb +++ b/templates/terraform/custom_flatten/default_if_empty.erb @@ -13,8 +13,16 @@ # limitations under the License. -%> func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return <%= go_literal(property.default_value) -%> } +<%- if property.is_a?(Api::Type::Integer) -%> + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { + return intVal + } // let terraform core handle it if we can't convert the string to an int. + } +<%- end %> return v }