diff --git a/pkg/resource_deployment.go b/pkg/resource_deployment.go index ae7990f3..ddeef84c 100644 --- a/pkg/resource_deployment.go +++ b/pkg/resource_deployment.go @@ -693,9 +693,7 @@ func resourceDeploymentUpdate(d *schema.ResourceData, m interface{}) error { if sec.caCertificate != "" { depl.Certificates.CaCertificateId = sec.caCertificate } - if sec.ipAllowlist != "" { - depl.IpallowlistId = sec.ipAllowlist - } + depl.IpallowlistId = sec.ipAllowlist } if d.HasChange(deplConfigurationFieldName) { conf, err := expandConfiguration(d.Get(deplConfigurationFieldName).([]interface{})) diff --git a/pkg/resource_ip_allowlist.go b/pkg/resource_ip_allowlist.go index 8e99d386..12f828dc 100644 --- a/pkg/resource_ip_allowlist.go +++ b/pkg/resource_ip_allowlist.go @@ -140,8 +140,6 @@ func expandToIPAllowlist(d *schema.ResourceData, defaultProject string) (*securi } if v, ok := d.GetOk(ipRemoteInspectionAllowedFieldName); ok { remoteInspectionAllowed = v.(bool) - } else { - return nil, fmt.Errorf("failed to parse field %s", ipRemoteInspectionAllowedFieldName) } project := defaultProject if v, ok := d.GetOk(ipDescriptionFieldName); ok { diff --git a/pkg/resource_ip_allowlist_test.go b/pkg/resource_ip_allowlist_test.go index bd5a549e..198c4881 100644 --- a/pkg/resource_ip_allowlist_test.go +++ b/pkg/resource_ip_allowlist_test.go @@ -79,22 +79,31 @@ func TestFlattenIPAllowlistResource(t *testing.T) { ipCreatedAtFieldName: "1980-03-03T01:01:01Z", ipProjectFieldName: "123456789", ipCIDRRangeFieldName: []string{"1.2.3.4/32", "88.11.0.0/16", "0.0.0.0/0"}, - ipRemoteInspectionAllowedFieldName: true, + ipRemoteInspectionAllowedFieldName: false, ipIsDeletedFieldName: false, } created, _ := types.TimestampProto(time.Date(1980, 03, 03, 1, 1, 1, 0, time.UTC)) cert := security.IPAllowlist{ - Name: "test-name", - Description: "test-description", - ProjectId: "123456789", - CidrRanges: []string{"1.2.3.4/32", "88.11.0.0/16", "0.0.0.0/0"}, - RemoteInspectionAllowed: true, - CreatedAt: created, - IsDeleted: false, + Name: "test-name", + Description: "test-description", + ProjectId: "123456789", + CidrRanges: []string{"1.2.3.4/32", "88.11.0.0/16", "0.0.0.0/0"}, + CreatedAt: created, + IsDeleted: false, } got := flattenIPAllowlistResource(&cert) assert.Equal(t, expected, got) + + cert.RemoteInspectionAllowed = true + expected[ipRemoteInspectionAllowedFieldName] = true + got = flattenIPAllowlistResource(&cert) + assert.Equal(t, expected, got) + + cert.RemoteInspectionAllowed = false + expected[ipRemoteInspectionAllowedFieldName] = false + got = flattenIPAllowlistResource(&cert) + assert.Equal(t, expected, got) } func TestExpandingIPAllowlistResource(t *testing.T) {