@@ -45,6 +45,82 @@ output "hostingde_record" {
45
45
}
46
46
```
47
47
48
+ ### Importing existing zones and records
49
+ #### Zones
50
+ - Create ` *.tf ` files containing the existing zone and records you'd like to import
51
+ - Go to https://secure.hosting.de/dns/ then click "Show details" on the zone you'd like to import
52
+ - Copy the ` ZONE_CONFIG_ID ` from the URL: https://secure.hosting.de/dns/zones/id/$ZONE_CONFIG_ID/edit
53
+ - Import the ` hostingde_zone ` resouce using:
54
+ ``` shell
55
+ terraform import hostingde_zone.your_zone_name $ZONE_CONFIG_ID
56
+ ```
57
+
58
+ #### Records
59
+ - Importing records is a little more involved, let's go:
60
+ - Write a shell function to prepare ` curl ` JSON data (this assumes you have your
61
+ API token set in the environment and that you replace ` $ZONE_CONFIG_ID ` with
62
+ the ID from above)
63
+ ``` shell
64
+ generate_post_data ()
65
+ {
66
+ cat << EOF
67
+ {
68
+ "authToken": "$HOSTINGDE_AUTH_TOKEN ",
69
+ "filter": {
70
+ "field": "zoneConfigId",
71
+ "value": "$ZONE_CONFIG_ID "
72
+ },
73
+ "limit": 10,
74
+ "page": 1,
75
+ "sort": {
76
+ "field": "recordName",
77
+ "order": "asc"
78
+ }
79
+ }
80
+ EOF
81
+ }
82
+ ```
83
+ - Do the curl POST request to get all DNS record IDs of that zone
84
+ ``` shell
85
+ curl \
86
+ -H " Accept: application/json" \
87
+ -H " Content-Type:application/json" \
88
+ -X POST \
89
+ -d " $( generate_post_data) " \
90
+ https://secure.hosting.de/api/dns/v1/json/recordsFind
91
+ ```
92
+ - Example response:
93
+ ```
94
+ {
95
+ "errors": [
96
+ ],
97
+ "metadata": {
98
+ "clientTransactionId": "",
99
+ "serverTransactionId": "20230411151239132-dnsrobot-robots1-26486-0"
100
+ },
101
+ "response": {
102
+ "data": [
103
+ {
104
+ "accountId": "ACCOUNT_ID",
105
+ "addDate": "2023-02-03T13:33:26Z",
106
+ "comments": "",
107
+ "content": "\"v=DMARC1; p=reject;\"",
108
+ "id": "RECORD_ID",
109
+ "lastChangeDate": "2023-02-03T13:33:26Z",
110
+ "name": "_dmarc.your.domain",
111
+ "priority": null,
112
+ "recordTemplateId": null,
113
+ "ttl": 3600,
114
+ "type": "TXT",
115
+ "zoneConfigId": "ZONE_CONFIG_ID"
116
+ },
117
+ ...
118
+ ```
119
+ - One by one, import the records:
120
+ ``` shell
121
+ terraform import hostingde_record.your_record_name $RECORD_ID
122
+ ```
123
+
48
124
# Development and testing
49
125
Prepare Terraform for local provider install
50
126
``` shell
@@ -79,7 +155,7 @@ export HOSTINGDE_AUTH_TOKEN=YOUR-API-TOKEN
79
155
make testacc
80
156
```
81
157
82
- Then, navigate to the ` example ` directory.
158
+ Then, navigate to the ` example ` directory.
83
159
84
160
``` shell
85
161
cd example
0 commit comments