-
Notifications
You must be signed in to change notification settings - Fork 605
/
schema_cloudflare_record.go
305 lines (277 loc) · 7.25 KB
/
schema_cloudflare_record.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
package sdkv2provider
import (
"fmt"
"strings"
"github.com/cloudflare/terraform-provider-cloudflare/internal/consts"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceCloudflareRecordSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
consts.ZoneIDSchemaKey: {
Description: consts.ZoneIDSchemaDescription,
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: func(i interface{}) string {
return strings.ToLower(i.(string))
},
Description: "The name of the record.",
},
"hostname": {
Type: schema.TypeString,
Computed: true,
Description: "The FQDN of the record.",
},
"type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"A", "AAAA", "CAA", "CNAME", "TXT", "SRV", "LOC", "MX", "NS", "SPF", "CERT", "DNSKEY", "DS", "NAPTR", "SMIMEA", "SSHFP", "TLSA", "URI", "PTR", "HTTPS"}, false),
Description: fmt.Sprintf("The type of the record. %s", renderAvailableDocumentationValuesStringSlice([]string{"A", "AAAA", "CAA", "CNAME", "TXT", "SRV", "LOC", "MX", "NS", "SPF", "CERT", "DNSKEY", "DS", "NAPTR", "SMIMEA", "SSHFP", "TLSA", "URI", "PTR", "HTTPS"})),
},
"value": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ConflictsWith: []string{"data"},
DiffSuppressFunc: suppressTrailingDots,
Description: "The value of the record.",
},
"data": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
ConflictsWith: []string{"value"},
Description: "Map of attributes that constitute the record value.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
// Properties present in several record types
"algorithm": {
Type: schema.TypeInt,
Optional: true,
},
"key_tag": {
Type: schema.TypeInt,
Optional: true,
},
"flags": {
Type: schema.TypeString,
Optional: true,
},
"service": {
Type: schema.TypeString,
Optional: true,
},
"certificate": {
Type: schema.TypeString,
Optional: true,
},
"type": {
Type: schema.TypeInt,
Optional: true,
},
"usage": {
Type: schema.TypeInt,
Optional: true,
},
"selector": {
Type: schema.TypeInt,
Optional: true,
},
"matching_type": {
Type: schema.TypeInt,
Optional: true,
},
"weight": {
Type: schema.TypeInt,
Optional: true,
},
// SRV record properties
"proto": {
Type: schema.TypeString,
Optional: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
},
"priority": {
Type: schema.TypeInt,
Optional: true,
},
"port": {
Type: schema.TypeInt,
Optional: true,
},
"target": {
Type: schema.TypeString,
Optional: true,
},
// LOC record properties
"size": {
Type: schema.TypeFloat,
Optional: true,
},
"altitude": {
Type: schema.TypeFloat,
Optional: true,
},
"long_degrees": {
Type: schema.TypeInt,
Optional: true,
},
"lat_degrees": {
Type: schema.TypeInt,
Optional: true,
},
"precision_horz": {
Type: schema.TypeFloat,
Optional: true,
},
"precision_vert": {
Type: schema.TypeFloat,
Optional: true,
},
"long_direction": {
Type: schema.TypeString,
Optional: true,
},
"long_minutes": {
Type: schema.TypeInt,
Optional: true,
},
"long_seconds": {
Type: schema.TypeFloat,
Optional: true,
},
"lat_direction": {
Type: schema.TypeString,
Optional: true,
},
"lat_minutes": {
Type: schema.TypeInt,
Optional: true,
},
"lat_seconds": {
Type: schema.TypeFloat,
Optional: true,
},
// DNSKEY record properties
"protocol": {
Type: schema.TypeInt,
Optional: true,
},
"public_key": {
Type: schema.TypeString,
Optional: true,
},
// DS record properties
"digest_type": {
Type: schema.TypeInt,
Optional: true,
},
"digest": {
Type: schema.TypeString,
Optional: true,
},
// NAPTR record properties
"order": {
Type: schema.TypeInt,
Optional: true,
},
"preference": {
Type: schema.TypeInt,
Optional: true,
},
"regex": {
Type: schema.TypeString,
Optional: true,
},
"replacement": {
Type: schema.TypeString,
Optional: true,
},
// SSHFP record properties
"fingerprint": {
Type: schema.TypeString,
Optional: true,
},
// URI record properties
"content": {
Type: schema.TypeString,
Optional: true,
},
// CAA record properties
"tag": {
Type: schema.TypeString,
Optional: true,
},
"value": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"ttl": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "The TTL of the record.",
},
"priority": {
Type: schema.TypeInt,
Optional: true,
DiffSuppressFunc: suppressPriority,
Description: "The priority of the record.",
},
"proxied": {
Optional: true,
Type: schema.TypeBool,
Description: "Whether the record gets Cloudflare's origin protection.",
},
"created_on": {
Type: schema.TypeString,
Computed: true,
Description: "The RFC3339 timestamp of when the record was created.",
},
"metadata": {
Type: schema.TypeMap,
Computed: true,
Description: "A key-value map of string metadata Cloudflare associates with the record.",
},
"modified_on": {
Type: schema.TypeString,
Computed: true,
Description: "The RFC3339 timestamp of when the record was last modified.",
},
"proxiable": {
Type: schema.TypeBool,
Computed: true,
Description: "Shows whether this record can be proxied.",
},
"allow_overwrite": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Allow creation of this record in Terraform to overwrite an existing record, if any. This does not affect the ability to update the record in Terraform and does not prevent other resources within Terraform or manual changes outside Terraform from overwriting this record. **This configuration is not recommended for most environments**",
},
"comment": {
Type: schema.TypeString,
Optional: true,
Description: "Comments or notes about the DNS record. This field has no effect on DNS responses.",
},
"tags": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "Custom tags for the DNS record.",
},
}
}