diff --git a/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway.go b/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway.go index b18a8ec741..9972ac6b94 100644 --- a/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway.go +++ b/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway.go @@ -144,7 +144,7 @@ func GetBeyondcorpSecurityGatewayApiObject(d tpgresource.TerraformResourceData, serviceDiscoveryProp, err := expandBeyondcorpSecurityGatewayServiceDiscovery(d.Get("service_discovery"), d, config) if err != nil { return nil, err - } else if v, ok := d.GetOkExists("service_discovery"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceDiscoveryProp)) && (ok || !reflect.DeepEqual(v, serviceDiscoveryProp)) { + } else if v, ok := d.GetOkExists("service_discovery"); ok || !reflect.DeepEqual(v, serviceDiscoveryProp) { obj["serviceDiscovery"] = serviceDiscoveryProp } @@ -409,9 +409,14 @@ func expandBeyondcorpSecurityGatewayServiceDiscovery(v interface{}, d tpgresourc return nil, nil } l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { + if len(l) == 0 { return nil, nil } + + if l[0] == nil { + transformed := make(map[string]interface{}) + return transformed, nil + } raw := l[0] original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) diff --git a/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway_application.go b/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway_application.go index 9b764325c9..d8cc9f9254 100644 --- a/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway_application.go +++ b/tfplan2cai/converters/google/resources/services/beyondcorp/beyondcorp_security_gateway_application.go @@ -411,21 +411,21 @@ func expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualH transformedUserInfo, err := expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualHeadersUserInfo(original["user_info"], d, config) if err != nil { return nil, err - } else if val := reflect.ValueOf(transformedUserInfo); val.IsValid() && !tpgresource.IsEmptyValue(val) { + } else { transformed["userInfo"] = transformedUserInfo } transformedGroupInfo, err := expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualHeadersGroupInfo(original["group_info"], d, config) if err != nil { return nil, err - } else if val := reflect.ValueOf(transformedGroupInfo); val.IsValid() && !tpgresource.IsEmptyValue(val) { + } else { transformed["groupInfo"] = transformedGroupInfo } transformedDeviceInfo, err := expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualHeadersDeviceInfo(original["device_info"], d, config) if err != nil { return nil, err - } else if val := reflect.ValueOf(transformedDeviceInfo); val.IsValid() && !tpgresource.IsEmptyValue(val) { + } else { transformed["deviceInfo"] = transformedDeviceInfo } @@ -444,9 +444,14 @@ func expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualH return nil, nil } l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { + if len(l) == 0 { return nil, nil } + + if l[0] == nil { + transformed := make(map[string]interface{}) + return transformed, nil + } raw := l[0] original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) @@ -470,9 +475,14 @@ func expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualH return nil, nil } l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { + if len(l) == 0 { return nil, nil } + + if l[0] == nil { + transformed := make(map[string]interface{}) + return transformed, nil + } raw := l[0] original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) @@ -496,9 +506,14 @@ func expandBeyondcorpSecurityGatewayApplicationUpstreamsProxyProtocolContextualH return nil, nil } l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { + if len(l) == 0 { return nil, nil } + + if l[0] == nil { + transformed := make(map[string]interface{}) + return transformed, nil + } raw := l[0] original := raw.(map[string]interface{}) transformed := make(map[string]interface{})