Skip to content

Commit 29c6b6f

Browse files
authored
fix(domain-record): set name as optional (#1155)
1 parent 0333377 commit 29c6b6f

File tree

4 files changed

+544
-157
lines changed

4 files changed

+544
-157
lines changed

docs/resources/domain_record.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ The following arguments are supported:
188188

189189
- `keep_empty_zone` - (Optional, default: `false`) When destroying a resource, if only NS records remain and this is set to `false`, the zone will be deleted. Please note, each zone not deleted will [cost you money](https://www.scaleway.com/en/dns/)
190190

191-
- `name` - (Required) The name of the record (can be an empty string for a root record).
191+
- `name` - (Optional) The name of the record (can be an empty string for a root record).
192192

193193
- `type` - (Required) The type of the record (`A`, `AAAA`, `MX`, `CNAME`, `ALIAS`, `NS`, `PTR`, `SRV`, `TXT`, `TLSA`, or `CAA`).
194194

scaleway/resource_domain_record.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func resourceScalewayDomainRecord() *schema.Resource {
4747
Type: schema.TypeString,
4848
Description: "The name of the record",
4949
ForceNew: true,
50-
Required: true,
50+
Optional: true,
5151
},
5252
"type": {
5353
Type: schema.TypeString,

scaleway/resource_domain_record_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ func TestAccScalewayDomainRecord_Basic(t *testing.T) {
7272
ProviderFactories: tt.ProviderFactories,
7373
CheckDestroy: testAccCheckScalewayDomainRecordDestroy(tt),
7474
Steps: []resource.TestStep{
75+
{
76+
Config: fmt.Sprintf(`
77+
resource "scaleway_domain_record" "tf_A" {
78+
dns_zone = "%s"
79+
type = "%s"
80+
data = "%s"
81+
ttl = %d
82+
priority = %d
83+
}
84+
`, testDNSZone, recordType, data, ttl, priority),
85+
Check: resource.ComposeTestCheckFunc(
86+
testAccCheckScalewayDomainRecordExists(tt, "scaleway_domain_record.tf_A"),
87+
resource.TestCheckResourceAttr("scaleway_domain_record.tf_A", "dns_zone", testDNSZone),
88+
resource.TestCheckResourceAttr("scaleway_domain_record.tf_A", "name", ""),
89+
resource.TestCheckResourceAttr("scaleway_domain_record.tf_A", "type", recordType),
90+
resource.TestCheckResourceAttr("scaleway_domain_record.tf_A", "data", data),
91+
resource.TestCheckResourceAttr("scaleway_domain_record.tf_A", "ttl", fmt.Sprint(ttl)),
92+
resource.TestCheckResourceAttr("scaleway_domain_record.tf_A", "priority", fmt.Sprint(priority)),
93+
testCheckResourceAttrUUID("scaleway_domain_record.tf_A", "id"),
94+
),
95+
},
7596
{
7697
Config: fmt.Sprintf(`
7798
resource "scaleway_domain_record" "tf_A" {

0 commit comments

Comments
 (0)