@@ -15,8 +15,9 @@ import (
15
15
)
16
16
17
17
const (
18
- webhookName = "terraform-webhook-test"
19
- organizationID = "105bdce1-64c0-48ab-899d-868455867ecf"
18
+ webhookName = "terraform-webhook-test"
19
+ organizationID = "105bdce1-64c0-48ab-899d-868455867ecf"
20
+ webhookDomainName = "webhook-test.scaleway-terraform.com"
20
21
)
21
22
22
23
func TestAccWebhook_Basic (t * testing.T ) {
@@ -55,50 +56,18 @@ func TestAccWebhook_Basic(t *testing.T) {
55
56
secret_key = scaleway_mnq_sns_credentials.sns_credentials.secret_key
56
57
}
57
58
58
- resource scaleway_tem_domain cr01 {
59
- name = "%s"
60
- accept_tos = true
61
- }
62
-
63
- resource "scaleway_domain_record" "spf" {
64
- dns_zone = "%s"
65
- type = "TXT"
66
- data = "v=spf1 ${scaleway_tem_domain.cr01.spf_config} -all"
67
- }
68
-
69
- resource "scaleway_domain_record" "dkim" {
70
- dns_zone = "%s"
71
- name = "${scaleway_tem_domain.cr01.project_id}._domainkey"
72
- type = "TXT"
73
- data = scaleway_tem_domain.cr01.dkim_config
74
- }
75
- resource "scaleway_domain_record" "mx" {
76
- dns_zone = "%s"
77
- type = "MX"
78
- data = "."
79
- }
80
-
81
- resource "scaleway_domain_record" "dmarc" {
82
- dns_zone = "%s"
83
- name = scaleway_tem_domain.cr01.dmarc_name
84
- type = "TXT"
85
- data = scaleway_tem_domain.cr01.dmarc_config
86
- }
87
-
88
- resource scaleway_tem_domain_validation valid {
89
- domain_id = scaleway_tem_domain.cr01.id
90
- region = scaleway_tem_domain.cr01.region
91
- timeout = 3600
59
+ data "scaleway_tem_domain" "cr01" {
60
+ name = "%s"
92
61
}
93
62
94
63
resource "scaleway_tem_webhook" "webhook" {
95
64
name = "%s"
96
- domain_id = scaleway_tem_domain.cr01.id
65
+ domain_id = data. scaleway_tem_domain.cr01.id
97
66
event_types = ["%s", "%s"]
98
67
sns_arn = scaleway_mnq_sns_topic.sns_topic.arn
99
- depends_on = [scaleway_tem_domain_validation.valid, scaleway_mnq_sns_topic.sns_topic]
68
+ depends_on = [scaleway_mnq_sns_topic.sns_topic]
100
69
}
101
- ` , organizationID , domainNameValidation , domainNameValidation , domainNameValidation , domainNameValidation , domainNameValidation , webhookName , eventTypes [0 ], eventTypes [1 ]),
70
+ ` , organizationID , webhookDomainName , webhookName , eventTypes [0 ], eventTypes [1 ]),
102
71
Check : resource .ComposeTestCheckFunc (
103
72
isWebhookPresent (tt , "scaleway_tem_webhook.webhook" ),
104
73
resource .TestCheckResourceAttr ("scaleway_tem_webhook.webhook" , "name" , webhookName ),
@@ -127,7 +96,6 @@ func TestAccWebhook_Update(t *testing.T) {
127
96
Steps : []resource.TestStep {
128
97
{
129
98
Config : fmt .Sprintf (`
130
-
131
99
data scaleway_account_project "project" {
132
100
name = "default"
133
101
organization_id = "%s"
@@ -146,55 +114,23 @@ func TestAccWebhook_Update(t *testing.T) {
146
114
147
115
resource "scaleway_mnq_sns_topic" "sns_topic" {
148
116
project_id = data.scaleway_mnq_sns.sns.project_id
149
- name = "test-mnq-sns-topic-update "
117
+ name = "test-mnq-sns-topic-basic "
150
118
access_key = scaleway_mnq_sns_credentials.sns_credentials.access_key
151
119
secret_key = scaleway_mnq_sns_credentials.sns_credentials.secret_key
152
120
}
153
121
154
- resource scaleway_tem_domain cr01 {
155
- name = "%s"
156
- accept_tos = true
157
- }
158
-
159
- resource "scaleway_domain_record" "spf" {
160
- dns_zone = "%s"
161
- type = "TXT"
162
- data = "v=spf1 ${scaleway_tem_domain.cr01.spf_config} -all"
163
- }
164
-
165
- resource "scaleway_domain_record" "dkim" {
166
- dns_zone = "%s"
167
- name = "${scaleway_tem_domain.cr01.project_id}._domainkey"
168
- type = "TXT"
169
- data = scaleway_tem_domain.cr01.dkim_config
170
- }
171
- resource "scaleway_domain_record" "mx" {
172
- dns_zone = "%s"
173
- type = "MX"
174
- data = "."
175
- }
176
-
177
- resource "scaleway_domain_record" "dmarc" {
178
- dns_zone = "%s"
179
- name = scaleway_tem_domain.cr01.dmarc_name
180
- type = "TXT"
181
- data = scaleway_tem_domain.cr01.dmarc_config
182
- }
183
-
184
- resource scaleway_tem_domain_validation valid {
185
- domain_id = scaleway_tem_domain.cr01.id
186
- region = scaleway_tem_domain.cr01.region
187
- timeout = 3600
122
+ data "scaleway_tem_domain" "cr01" {
123
+ name = "%s"
188
124
}
189
125
190
126
resource "scaleway_tem_webhook" "webhook" {
191
127
name = "%s"
192
- domain_id = scaleway_tem_domain.cr01.id
128
+ domain_id = data. scaleway_tem_domain.cr01.id
193
129
event_types = ["%s"]
194
130
sns_arn = scaleway_mnq_sns_topic.sns_topic.arn
195
- depends_on = [scaleway_tem_domain_validation.valid, scaleway_mnq_sns_topic.sns_topic]
131
+ depends_on = [scaleway_mnq_sns_topic.sns_topic]
196
132
}
197
- ` , organizationID , domainNameValidation , domainNameValidation , domainNameValidation , domainNameValidation , domainNameValidation , initialName , eventTypes [0 ]),
133
+ ` , organizationID , webhookDomainName , initialName , eventTypes [0 ]),
198
134
Check : resource .ComposeTestCheckFunc (
199
135
isWebhookPresent (tt , "scaleway_tem_webhook.webhook" ),
200
136
resource .TestCheckResourceAttr ("scaleway_tem_webhook.webhook" , "name" , initialName ),
@@ -205,7 +141,6 @@ func TestAccWebhook_Update(t *testing.T) {
205
141
},
206
142
{
207
143
Config : fmt .Sprintf (`
208
-
209
144
data scaleway_account_project "project" {
210
145
name = "default"
211
146
organization_id = "%s"
@@ -224,55 +159,23 @@ func TestAccWebhook_Update(t *testing.T) {
224
159
225
160
resource "scaleway_mnq_sns_topic" "sns_topic" {
226
161
project_id = data.scaleway_mnq_sns.sns.project_id
227
- name = "test-mnq-sns-topic-update "
162
+ name = "test-mnq-sns-topic-basic "
228
163
access_key = scaleway_mnq_sns_credentials.sns_credentials.access_key
229
164
secret_key = scaleway_mnq_sns_credentials.sns_credentials.secret_key
230
165
}
231
166
232
- resource scaleway_tem_domain cr01 {
233
- name = "%s"
234
- accept_tos = true
235
- }
236
-
237
- resource "scaleway_domain_record" "spf" {
238
- dns_zone = "%s"
239
- type = "TXT"
240
- data = "v=spf1 ${scaleway_tem_domain.cr01.spf_config} -all"
241
- }
242
-
243
- resource "scaleway_domain_record" "dkim" {
244
- dns_zone = "%s"
245
- name = "${scaleway_tem_domain.cr01.project_id}._domainkey"
246
- type = "TXT"
247
- data = scaleway_tem_domain.cr01.dkim_config
248
- }
249
- resource "scaleway_domain_record" "mx" {
250
- dns_zone = "%s"
251
- type = "MX"
252
- data = "."
253
- }
254
-
255
- resource "scaleway_domain_record" "dmarc" {
256
- dns_zone = "%s"
257
- name = scaleway_tem_domain.cr01.dmarc_name
258
- type = "TXT"
259
- data = scaleway_tem_domain.cr01.dmarc_config
260
- }
261
-
262
- resource scaleway_tem_domain_validation valid {
263
- domain_id = scaleway_tem_domain.cr01.id
264
- region = scaleway_tem_domain.cr01.region
265
- timeout = 3600
167
+ data "scaleway_tem_domain" "cr01" {
168
+ name = "%s"
266
169
}
267
170
268
171
resource "scaleway_tem_webhook" "webhook" {
269
172
name = "%s"
270
- domain_id = scaleway_tem_domain.cr01.id
173
+ domain_id = data. scaleway_tem_domain.cr01.id
271
174
event_types = ["%s"]
272
175
sns_arn = scaleway_mnq_sns_topic.sns_topic.arn
273
- depends_on = [scaleway_tem_domain_validation.valid, scaleway_mnq_sns_topic.sns_topic]
176
+ depends_on = [scaleway_mnq_sns_topic.sns_topic]
274
177
}
275
- ` , organizationID , domainNameValidation , domainNameValidation , domainNameValidation , domainNameValidation , domainNameValidation , updatedName , updatedEventTypes [0 ]),
178
+ ` , organizationID , webhookDomainName , updatedName , updatedEventTypes [0 ]),
276
179
Check : resource .ComposeTestCheckFunc (
277
180
isWebhookPresent (tt , "scaleway_tem_webhook.webhook" ),
278
181
resource .TestCheckResourceAttr ("scaleway_tem_webhook.webhook" , "name" , updatedName ),
0 commit comments