diff --git a/ovh/resource_dbaas_logs_input.go b/ovh/resource_dbaas_logs_input.go index d75b80ab..526bf4e1 100644 --- a/ovh/resource_dbaas_logs_input.go +++ b/ovh/resource_dbaas_logs_input.go @@ -140,7 +140,7 @@ func resourceDbaasLogsInputSchema() map[string]*schema.Schema { // Optional "allowed_networks": { - Type: schema.TypeList, + Type: schema.TypeSet, Description: "IP blocks", Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/ovh/resource_dbaas_logs_input_test.go b/ovh/resource_dbaas_logs_input_test.go index 14747862..6ca2051c 100644 --- a/ovh/resource_dbaas_logs_input_test.go +++ b/ovh/resource_dbaas_logs_input_test.go @@ -95,6 +95,47 @@ resource "ovh_dbaas_logs_input" "input" { } ` +const testAccResourceDbaasLogsInput_noNetwork = ` +data "ovh_dbaas_logs_input_engine" "logstash" { + service_name = "%s" + name = "%s" + version = "%s" +} + +resource "ovh_dbaas_logs_output_graylog_stream" "stream" { + service_name = "%s" + title = "%s" + description = "%s" +} + +resource "ovh_dbaas_logs_input" "input" { + service_name = ovh_dbaas_logs_output_graylog_stream.stream.service_name + description = ovh_dbaas_logs_output_graylog_stream.stream.description + title = ovh_dbaas_logs_output_graylog_stream.stream.title + engine_id = data.ovh_dbaas_logs_input_engine.logstash.id + stream_id = ovh_dbaas_logs_output_graylog_stream.stream.id + + allowed_networks = [] + exposed_port = "6154" + autoscale = true + min_scale_instance = 2 + max_scale_instance = 4 + + configuration { + logstash { + input_section = < 6514 + ssl => true + ssl_certificate => "/etc/ssl/private/server.crt" + ssl_key => "/etc/ssl/private/server.key" + } + EOF + } + } +} +` + func init() { resource.AddTestSweepers("ovh_dbaas_logs_input", &resource.Sweeper{ Name: "ovh_dbaas_logs_input", @@ -207,6 +248,8 @@ func TestAccResourceDbaasLogsInput_basic(t *testing.T) { serviceName, name, version, serviceName, title, desc, 4) configUpdated := fmt.Sprintf(testAccResourceDbaasLogsInput_updated, serviceName, name, version, serviceName, title, desc) + configNoNetwork := fmt.Sprintf(testAccResourceDbaasLogsInput_noNetwork, + serviceName, name, version, serviceName, title, desc) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheckDbaasLogsInput(t) }, @@ -313,6 +356,10 @@ func TestAccResourceDbaasLogsInput_basic(t *testing.T) { ), ), }, + { + Config: configNoNetwork, + Check: resource.TestCheckResourceAttr("ovh_dbaas_logs_input.input", "allowed_networks.#", "0"), + }, }, }) } diff --git a/ovh/types_dbaas_logs_input.go b/ovh/types_dbaas_logs_input.go index c2ecb88d..554dd1ce 100644 --- a/ovh/types_dbaas_logs_input.go +++ b/ovh/types_dbaas_logs_input.go @@ -83,7 +83,7 @@ func (opts *DbaasLogsInputOpts) FromResource(d *schema.ResourceData) *DbaasLogsI opts.StreamId = d.Get("stream_id").(string) opts.Title = d.Get("title").(string) - networks := d.Get("allowed_networks").([]interface{}) + networks := d.Get("allowed_networks").(*schema.Set).List() if len(networks) > 0 { networksString := make([]string, len(networks)) for i, net := range networks {