Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(domain): DNAME support and improve performance when using record ID #1113

Merged
merged 6 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data-sources/domain_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data "scaleway_domain_record" "by_id" {
- `name` - (Required) The name of the record (can be an empty string for a root record).
Cannot be used with `record_id`.

- `type` - (Required) The type of the record (`A`, `AAAA`, `MX`, `CNAME`, `ALIAS`, `NS`, `PTR`, `SRV`, `TXT`, `TLSA`, or `CAA`).
- `type` - (Required) The type of the record (`A`, `AAAA`, `MX`, `CNAME`, `DNAME`, `ALIAS`, `NS`, `PTR`, `SRV`, `TXT`, `TLSA`, or `CAA`).
Cannot be used with `record_id`.

- `data` - (Required) The content of the record (an IPv4 for an `A`, a string for a `TXT`...).
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/domain_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ The following arguments are supported:

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

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

- `data` - (Required) The content of the record (an IPv4 for an `A`, a string for a `TXT`...).

Expand Down
8 changes: 4 additions & 4 deletions scaleway/resource_domain_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func resourceScalewayDomainRecord() *schema.Resource {
domain.RecordTypeAAAA.String(),
domain.RecordTypeALIAS.String(),
domain.RecordTypeCNAME.String(),
domain.RecordTypeDNAME.String(),
domain.RecordTypeMX.String(),
domain.RecordTypeNS.String(),
domain.RecordTypePTR.String(),
Expand Down Expand Up @@ -281,6 +282,7 @@ func resourceScalewayDomainRecordRead(ctx context.Context, d *schema.ResourceDat

res, err := domainAPI.ListDNSZoneRecords(&domain.ListDNSZoneRecordsRequest{
DNSZone: dnsZone,
ID: &id,
}, scw.WithAllPages())

if err != nil {
Expand All @@ -292,10 +294,8 @@ func resourceScalewayDomainRecordRead(ctx context.Context, d *schema.ResourceDat
}

for _, r := range res.Records {
if r.ID == id {
record = r
break
}
record = r
break
}
} else {
dnsZone = d.Get("dns_zone").(string)
Expand Down
772 changes: 386 additions & 386 deletions scaleway/testdata/data-source-domain-record-basic.cassette.yaml

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions scaleway/testdata/data-source-domain-zone-basic.cassette.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:19 GMT
- Tue, 19 Apr 2022 09:00:58 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -30,7 +30,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 1f1b5abb-e7f1-4636-be60-be4d833eca38
- 7dc924cf-8a64-4d46-b505-562772a817af
status: 200 OK
code: 200
duration: ""
Expand All @@ -46,7 +46,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones
method: POST
response:
body: '{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}'
body: '{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}'
headers:
Content-Length:
- "298"
Expand All @@ -55,7 +55,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:20 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -65,7 +65,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 10d64410-113d-4b54-935e-cef587b225ca
- b04afa50-f29f-447b-8e40-6bfa47b27a78
status: 200 OK
code: 200
duration: ""
Expand All @@ -79,7 +79,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -88,7 +88,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:20 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -98,7 +98,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- e9eebead-208f-4886-8ede-b95dc33d9810
- 22870c51-7e8a-4fda-91a9-5a68b9d24c64
status: 200 OK
code: 200
duration: ""
Expand All @@ -112,7 +112,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -121,7 +121,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:20 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -131,7 +131,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- cf52d131-ec1a-4570-b7f0-c82e3145b209
- 1d3406ea-68ea-4e2e-9e69-ed3389094b75
status: 200 OK
code: 200
duration: ""
Expand All @@ -145,7 +145,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -154,7 +154,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:20 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -164,7 +164,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- d8ed9662-da91-4626-a256-78be3536edbf
- 1eadedf8-6c8c-441b-922e-784a0668c22c
status: 200 OK
code: 200
duration: ""
Expand All @@ -178,7 +178,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -187,7 +187,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:21 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -197,7 +197,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 25bd8d9d-b75c-4013-a8a4-e0bf2f722751
- 35692695-b8e9-4484-b8c0-b3f4ea5a521b
status: 200 OK
code: 200
duration: ""
Expand All @@ -211,7 +211,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc&project_id=fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -220,7 +220,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:21 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -230,7 +230,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- f1ff645c-94ba-4fa1-a413-a28357171bf0
- b6896d13-92f5-40e5-82a4-a982db837125
status: 200 OK
code: 200
duration: ""
Expand All @@ -244,7 +244,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -253,7 +253,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:21 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -263,7 +263,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 783ad0f2-914a-4c7c-a6b0-0806882faaf8
- 921bef56-760f-48de-9136-805a12596175
status: 200 OK
code: 200
duration: ""
Expand All @@ -277,7 +277,7 @@ interactions:
url: https://api.scaleway.com/domain/v2beta1/dns-zones?dns_zone=test-zone2.scaleway-terraform.com&domain=&order_by=domain_asc
method: GET
response:
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-02-17T15:18:20Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
body: '{"total_count":1,"dns_zones":[{"domain":"scaleway-terraform.com","subdomain":"test-zone2","ns":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_default":["ns0.dom.scw.cloud","ns1.dom.scw.cloud"],"ns_master":[],"status":"active","message":null,"updated_at":"2022-04-19T09:00:58Z","project_id":"fbda9817-5c05-4e1d-aa8d-a1a8b0b80ddf"}]}'
headers:
Content-Length:
- "330"
Expand All @@ -286,7 +286,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:22 GMT
- Tue, 19 Apr 2022 09:00:59 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -296,7 +296,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 03e70c88-7172-45bc-8c01-f09a8669d70e
- 77182aa1-00d4-460e-96c5-a79fe861a762
status: 200 OK
code: 200
duration: ""
Expand All @@ -319,7 +319,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:23 GMT
- Tue, 19 Apr 2022 09:01:00 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -329,7 +329,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 1dfecb66-f570-41db-9957-90c1c95dd34e
- 29d7a622-d4ae-4529-b299-6fe3e889820a
status: 200 OK
code: 200
duration: ""
Expand All @@ -352,7 +352,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 17 Feb 2022 15:18:24 GMT
- Tue, 19 Apr 2022 09:01:00 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
Expand All @@ -362,7 +362,7 @@ interactions:
X-Frame-Options:
- DENY
X-Request-Id:
- 0cec2d11-9648-4376-80d2-eac3c2a928d9
- 9f6bd24f-9081-4320-a0c2-c1236f5c727d
status: 200 OK
code: 200
duration: ""
Loading