Skip to content

Commit e419be1

Browse files
committed
ovh_domain_zone_record: Make fieldtype non-updatable
1 parent dddfe9e commit e419be1

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

ovh/resource_ovh_domain_zone_record.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func resourceOvhDomainZoneRecord() *schema.Resource {
7575
"fieldtype": {
7676
Type: schema.TypeString,
7777
Required: true,
78+
ForceNew: true,
7879
},
7980
"subdomain": {
8081
Type: schema.TypeString,

ovh/resource_ovh_domain_zone_record_test.go

+57
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,52 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
192192
})
193193
}
194194

195+
func TestAccOvhDomainZoneRecord_updateType(t *testing.T) {
196+
record := OvhDomainZoneRecord{}
197+
zone := os.Getenv("OVH_ZONE")
198+
subdomain := acctest.RandomWithPrefix(test_prefix)
199+
200+
resource.Test(t, resource.TestCase{
201+
PreCheck: func() { testAccPreCheck(t) },
202+
Providers: testAccProviders,
203+
CheckDestroy: testAccCheckOvhDomainZoneRecordDestroy,
204+
Steps: []resource.TestStep{
205+
{
206+
Config: testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, "192.168.0.1", 3600),
207+
Check: resource.ComposeTestCheckFunc(
208+
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
209+
resource.TestCheckResourceAttr(
210+
"ovh_domain_zone_record.foobar", "subdomain", subdomain),
211+
resource.TestCheckResourceAttr(
212+
"ovh_domain_zone_record.foobar", "zone", zone),
213+
resource.TestCheckResourceAttr(
214+
"ovh_domain_zone_record.foobar", "target", "192.168.0.1"),
215+
resource.TestCheckResourceAttr(
216+
"ovh_domain_zone_record.foobar", "fieldtype", "A"),
217+
resource.TestCheckResourceAttr(
218+
"ovh_domain_zone_record.foobar", "ttl", "3600"),
219+
),
220+
},
221+
{
222+
Config: testAccCheckOvhDomainZoneRecordConfig_CNAME(zone, subdomain, "google.com.", 3600),
223+
Check: resource.ComposeTestCheckFunc(
224+
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
225+
resource.TestCheckResourceAttr(
226+
"ovh_domain_zone_record.foobar", "subdomain", subdomain),
227+
resource.TestCheckResourceAttr(
228+
"ovh_domain_zone_record.foobar", "zone", zone),
229+
resource.TestCheckResourceAttr(
230+
"ovh_domain_zone_record.foobar", "target", "google.com."),
231+
resource.TestCheckResourceAttr(
232+
"ovh_domain_zone_record.foobar", "fieldtype", "CNAME"),
233+
resource.TestCheckResourceAttr(
234+
"ovh_domain_zone_record.foobar", "ttl", "3600"),
235+
),
236+
},
237+
},
238+
})
239+
}
240+
195241
func testAccCheckOvhDomainZoneRecordDestroy(s *terraform.State) error {
196242
provider := testAccProvider.Meta().(*Config)
197243
zone := os.Getenv("OVH_ZONE")
@@ -257,3 +303,14 @@ resource "ovh_domain_zone_record" "foobar" {
257303
ttl = %d
258304
}`, zone, subdomain, target, ttl)
259305
}
306+
307+
func testAccCheckOvhDomainZoneRecordConfig_CNAME(zone, subdomain, target string, ttl int) string {
308+
return fmt.Sprintf(`
309+
resource "ovh_domain_zone_record" "foobar" {
310+
zone = "%s"
311+
subdomain = "%s"
312+
target = "%s"
313+
fieldtype = "CNAME"
314+
ttl = %d
315+
}`, zone, subdomain, target, ttl)
316+
}

0 commit comments

Comments
 (0)