diff --git a/bigip/resource_bigip_ltm_datagroup.go b/bigip/resource_bigip_ltm_datagroup.go index f1f608d6..c1a40099 100644 --- a/bigip/resource_bigip_ltm_datagroup.go +++ b/bigip/resource_bigip_ltm_datagroup.go @@ -128,7 +128,7 @@ func resourceBigipLtmDataGroupRead(ctx context.Context, d *schema.ResourceData, name := d.Id() log.Printf("[DEBUG] Retrieving Data Group List %s", name) datagroup, err := client.GetInternalDataGroup(name) - if err != nil { + if err != nil && !strings.Contains(err.Error(), "not found") { return diag.FromErr(fmt.Errorf("Error retrieving Data Group List %s: %v ", name, err)) } diff --git a/bigip/resource_bigip_ltm_datagroup_test.go b/bigip/resource_bigip_ltm_datagroup_test.go index eb56552e..a6d4dea6 100644 --- a/bigip/resource_bigip_ltm_datagroup_test.go +++ b/bigip/resource_bigip_ltm_datagroup_test.go @@ -30,6 +30,15 @@ var TestDatagroupStringResource = ` } }` +var TestExternalDatagroupResource = ` +resource "bigip_ltm_datagroup" "test-datagroup-string" { + name = "` + TestDatagroupName + `" + type = "string" + internal = false + records_src = "foo.bars" + +}` + var TestDatagroupIpResource = ` resource "bigip_ltm_datagroup" "test-datagroup-ip" { name = "` + TestDatagroupName + `" @@ -73,6 +82,24 @@ func TestAccBigipLtmDataGroup_Create_TypeString(t *testing.T) { }, }) } + +func TestAccBigipLtmDataGroup_Create_External(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAcctPreCheck(t) + }, + Providers: testAccProviders, + CheckDestroy: testCheckDataGroupDestroyed, + Steps: []resource.TestStep{ + { + Config: TestExternalDatagroupResource, + Check: resource.ComposeTestCheckFunc( + testCheckExternalDataGroupExists(TestDatagroupName), + ), + }, + }, + }) +} func TestAccBigipLtmDataGroup_Create_TypeIp(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -186,6 +213,22 @@ func testCheckDataGroupExists(name string) resource.TestCheckFunc { } } +func testCheckExternalDataGroupExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := testAccProvider.Meta().(*bigip.BigIP) + datagroup, err := client.GetExternalDataGroup(name) + if err != nil { + return fmt.Errorf("Error while fetching Data Group: %v ", err) + + } + datagroupName := datagroup.FullPath + if datagroupName != name { + return fmt.Errorf("Data Group name does not match. Expecting %s got %s ", name, datagroupName) + } + return nil + } +} + func testCheckDataGroupDestroyed(s *terraform.State) error { client := testAccProvider.Meta().(*bigip.BigIP) diff --git a/bigip/resource_bigip_ltm_profile_http.go b/bigip/resource_bigip_ltm_profile_http.go index 93dda640..10e11a0e 100644 --- a/bigip/resource_bigip_ltm_profile_http.go +++ b/bigip/resource_bigip_ltm_profile_http.go @@ -79,9 +79,9 @@ func resourceBigipLtmProfileHttp() *schema.Resource { Description: "Specifies a passphrase for the cookie encryption. Note: Since it's a sensitive entity idempotency will fail for it in the update call.", }, "fallback_host": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + // Computed: true, Description: "Specifies an HTTP fallback host. HTTP redirection allows you to redirect HTTP traffic to another protocol identifier, host name, port number, or URI path.", }, "fallback_status_codes": { @@ -468,7 +468,12 @@ func getHttpProfileConfig(d *schema.ResourceData, config *bigip.HttpProfile) *bi config.Description = d.Get("description").(string) config.EncryptCookieSecret = d.Get("encrypt_cookie_secret").(string) config.EncryptCookies = setToStringSlice(d.Get("encrypt_cookies").(*schema.Set)) - config.FallbackHost = d.Get("fallback_host").(string) + if _, ok := d.GetOk("fallback_host"); ok { + config.FallbackHost = d.Get("fallback_host").(string) + } else { + config.FallbackHost = "" + } + config.FallbackStatusCodes = setToStringSlice(d.Get("fallback_status_codes").(*schema.Set)) config.HeaderErase = d.Get("head_erase").(string) config.HeaderInsert = d.Get("head_insert").(string) diff --git a/bigip/resource_bigip_ltm_profile_http_test.go b/bigip/resource_bigip_ltm_profile_http_test.go index 4d9dc595..97be219f 100644 --- a/bigip/resource_bigip_ltm_profile_http_test.go +++ b/bigip/resource_bigip_ltm_profile_http_test.go @@ -21,11 +21,11 @@ var resHttpName = "bigip_ltm_profile_http" var TestHttpResource = ` resource "bigip_ltm_profile_http" "test-http" { - name = "/Common/test-http" - defaults_from = "/Common/http" - description = "some http" - fallback_host = "titanic" - fallback_status_codes = ["400","500","300"] + name = "/Common/test-http" + defaults_from = "/Common/http" + description = "some http" + fallback_host = "titanic" + fallback_status_codes = ["400", "500", "300"] } ` @@ -92,7 +92,7 @@ func TestAccBigipLtmProfileHttpUpdateServerAgent(t *testing.T) { CheckDestroy: testCheckHttpsDestroyed, Steps: []resource.TestStep{ { - Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName, "http-profile-test"), + Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName), Check: resource.ComposeTestCheckFunc( testCheckhttpExists(TestHttpName), resource.TestCheckResourceAttr(resFullName, "name", TestHttpName), @@ -109,7 +109,7 @@ func TestAccBigipLtmProfileHttpUpdateServerAgent(t *testing.T) { ), }, { - Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName, "http-profile-test"), + Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName), Check: resource.ComposeTestCheckFunc( testCheckhttpExists(TestHttpName), resource.TestCheckResourceAttr(resFullName, "name", TestHttpName), @@ -121,38 +121,47 @@ func TestAccBigipLtmProfileHttpUpdateServerAgent(t *testing.T) { }) } -func TestAccBigipLtmProfileHttpUpdateFallbackhost(t *testing.T) { +func TestAccBigipLtmProfileHttpUpdateFallbackHost(t *testing.T) { t.Parallel() - var instName = "test-http-Update-FallbackHost" - var instFullName = fmt.Sprintf("/%s/%s", TestPartition, instName) - resFullName := fmt.Sprintf("%s.%s", resHttpName, instName) + var instName = "test-http-Update-fallbackhost" + var TestHttpName = fmt.Sprintf("/%s/%s", TestPartition, instName) + resFullName := fmt.Sprintf("%s.%s", resHttpName, "http-profile-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAcctPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckHttpsDestroyed, + Providers: testAccProviders, + // CheckDestroy: testCheckHttpsDestroyed, Steps: []resource.TestStep{ { - Config: testaccbigipltmprofilehttpUpdateParam(instName, ""), + Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName), Check: resource.ComposeTestCheckFunc( - testCheckhttpExists(instFullName), - resource.TestCheckResourceAttr(resFullName, "name", instFullName), + testCheckhttpExists(TestHttpName), + resource.TestCheckResourceAttr(resFullName, "name", TestHttpName), resource.TestCheckResourceAttr(resFullName, "defaults_from", "/Common/http"), ), }, { - Config: testaccbigipltmprofilehttpUpdateParam(instName, "fallback_host"), + Config: testaccbigipltmprofilehttpUpdateFallbackHost(TestPartition, TestHttpName, "http-profile-test"), Check: resource.ComposeTestCheckFunc( - testCheckhttpExists(instFullName), - resource.TestCheckResourceAttr(resFullName, "name", instFullName), + testCheckhttpExists(TestHttpName), + resource.TestCheckResourceAttr(resFullName, "name", TestHttpName), + resource.TestCheckResourceAttr(resFullName, "defaults_from", "/Common/http"), + resource.TestCheckResourceAttr(resFullName, "fallback_host", "https://www.google.de"), + ), + }, + { + Config: testaccbigipltmprofilehttpDefaultConfig(TestPartition, TestHttpName), + Check: resource.ComposeTestCheckFunc( + testCheckhttpExists(TestHttpName), + resource.TestCheckResourceAttr(resFullName, "name", TestHttpName), resource.TestCheckResourceAttr(resFullName, "defaults_from", "/Common/http"), - resource.TestCheckResourceAttr(resFullName, "fallback_host", "titanic"), ), }, }, }) } + func TestAccBigipLtmProfileHttpUpdateBasicAuthRealm(t *testing.T) { t.Parallel() var instName = "test-http-Update-BasicAuthRealm" @@ -525,13 +534,13 @@ func testCheckHttpsDestroyed(s *terraform.State) error { return nil } -func testaccbigipltmprofilehttpDefaultConfig(partition, profileName, resourceName string) string { +func testaccbigipltmprofilehttpDefaultConfig(partition, profileName string) string { return fmt.Sprintf(` resource "bigip_ltm_profile_http" "%[3]s" { name = "%[2]s" defaults_from = "/%[1]s/http" } -`, partition, profileName, resourceName) +`, partition, profileName, "http-profile-test") } func testaccbigipltmprofilehttpUpdateServeragentConfig(partition, profileName, resourceName string) string { @@ -544,6 +553,16 @@ resource "bigip_ltm_profile_http" "%[3]s" { `, partition, profileName, resourceName) } +func testaccbigipltmprofilehttpUpdateFallbackHost(partition, profileName, resourceName string) string { + return fmt.Sprintf(` +resource "bigip_ltm_profile_http" "%[3]s" { + name = "%[2]s" + defaults_from = "/%[1]s/http" + fallback_host = "https://www.google.de" +} +`, partition, profileName, resourceName) +} + func testaccBigipLtmHttpProfileImportConfig() string { return fmt.Sprintf(` resource "bigip_ltm_profile_http" "test-http" { diff --git a/vendor/github.com/f5devcentral/go-bigip/ltm.go b/vendor/github.com/f5devcentral/go-bigip/ltm.go index c82bc382..714e611d 100644 --- a/vendor/github.com/f5devcentral/go-bigip/ltm.go +++ b/vendor/github.com/f5devcentral/go-bigip/ltm.go @@ -1829,7 +1829,7 @@ type HttpProfile struct { Description string `json:"description,omitempty"` EncryptCookieSecret string `json:"encryptCookieSecret,omitempty"` EncryptCookies []string `json:"encryptCookies,omitempty"` - FallbackHost string `json:"fallbackHost,omitempty"` + FallbackHost string `json:"fallbackHost"` FallbackStatusCodes []string `json:"fallbackStatusCodes,omitempty"` HeaderErase string `json:"headerErase,omitempty"` HeaderInsert string `json:"headerInsert,omitempty"`