@@ -139,11 +139,19 @@ func resourceDomainConfigurationCreate(ctx context.Context, d *schema.ResourceDa
139
139
conn := meta .(* conns.AWSClient ).IoTClient (ctx )
140
140
141
141
name := d .Get (names .AttrName ).(string )
142
- input := & iot.CreateDomainConfigurationInput {
142
+ input := iot.CreateDomainConfigurationInput {
143
143
DomainConfigurationName : aws .String (name ),
144
144
Tags : getTagsIn (ctx ),
145
145
}
146
146
147
+ if v , ok := d .GetOk ("application_protocol" ); ok {
148
+ input .ApplicationProtocol = awstypes .ApplicationProtocol (v .(string ))
149
+ }
150
+
151
+ if v , ok := d .GetOk ("authentication_type" ); ok {
152
+ input .AuthenticationType = awstypes .AuthenticationType (v .(string ))
153
+ }
154
+
147
155
if v , ok := d .GetOk ("authorizer_config" ); ok && len (v .([]any )) > 0 && v .([]any )[0 ] != nil {
148
156
input .AuthorizerConfig = expandAuthorizerConfig (v .([]any )[0 ].(map [string ]any ))
149
157
}
@@ -168,15 +176,7 @@ func resourceDomainConfigurationCreate(ctx context.Context, d *schema.ResourceDa
168
176
input .ValidationCertificateArn = aws .String (v .(string ))
169
177
}
170
178
171
- if v , ok := d .GetOk ("authentication_type" ); ok {
172
- input .AuthenticationType = awstypes .AuthenticationType (v .(string ))
173
- }
174
-
175
- if v , ok := d .GetOk ("application_protocol" ); ok {
176
- input .ApplicationProtocol = awstypes .ApplicationProtocol (v .(string ))
177
- }
178
-
179
- output , err := conn .CreateDomainConfiguration (ctx , input )
179
+ output , err := conn .CreateDomainConfiguration (ctx , & input )
180
180
181
181
if err != nil {
182
182
return sdkdiag .AppendErrorf (diags , "creating IoT Domain Configuration (%s): %s" , name , err )
@@ -203,7 +203,9 @@ func resourceDomainConfigurationRead(ctx context.Context, d *schema.ResourceData
203
203
return sdkdiag .AppendErrorf (diags , "reading IoT Domain Configuration (%s): %s" , d .Id (), err )
204
204
}
205
205
206
+ d .Set ("application_protocol" , output .ApplicationProtocol )
206
207
d .Set (names .AttrARN , output .DomainConfigurationArn )
208
+ d .Set ("authentication_type" , output .AuthenticationType )
207
209
if output .AuthorizerConfig != nil {
208
210
if err := d .Set ("authorizer_config" , []any {flattenAuthorizerConfig (output .AuthorizerConfig )}); err != nil {
209
211
return sdkdiag .AppendErrorf (diags , "setting authorizer_config: %s" , err )
@@ -227,8 +229,6 @@ func resourceDomainConfigurationRead(ctx context.Context, d *schema.ResourceData
227
229
d .Set ("tls_config" , nil )
228
230
}
229
231
d .Set ("validation_certificate_arn" , d .Get ("validation_certificate_arn" ))
230
- d .Set ("authentication_type" , output .AuthenticationType )
231
- d .Set ("application_protocol" , output .ApplicationProtocol )
232
232
233
233
return diags
234
234
}
@@ -238,10 +238,18 @@ func resourceDomainConfigurationUpdate(ctx context.Context, d *schema.ResourceDa
238
238
conn := meta .(* conns.AWSClient ).IoTClient (ctx )
239
239
240
240
if d .HasChangesExcept (names .AttrTags , names .AttrTagsAll ) {
241
- input := & iot.UpdateDomainConfigurationInput {
241
+ input := iot.UpdateDomainConfigurationInput {
242
242
DomainConfigurationName : aws .String (d .Id ()),
243
243
}
244
244
245
+ if d .HasChange ("application_protocol" ) {
246
+ input .ApplicationProtocol = awstypes .ApplicationProtocol (d .Get ("application_protocol" ).(string ))
247
+ }
248
+
249
+ if d .HasChange ("authentication_type" ) {
250
+ input .AuthenticationType = awstypes .AuthenticationType (d .Get ("authentication_type" ).(string ))
251
+ }
252
+
245
253
if d .HasChange ("authorizer_config" ) {
246
254
if v , ok := d .GetOk ("authorizer_config" ); ok && len (v .([]any )) > 0 && v .([]any )[0 ] != nil {
247
255
input .AuthorizerConfig = expandAuthorizerConfig (v .([]any )[0 ].(map [string ]any ))
@@ -260,15 +268,7 @@ func resourceDomainConfigurationUpdate(ctx context.Context, d *schema.ResourceDa
260
268
}
261
269
}
262
270
263
- if d .HasChange ("authentication_type" ) {
264
- input .AuthenticationType = awstypes .AuthenticationType (d .Get ("authentication_type" ).(string ))
265
- }
266
-
267
- if d .HasChange ("application_protocol" ) {
268
- input .ApplicationProtocol = awstypes .ApplicationProtocol (d .Get ("application_protocol" ).(string ))
269
- }
270
-
271
- _ , err := conn .UpdateDomainConfiguration (ctx , input )
271
+ _ , err := conn .UpdateDomainConfiguration (ctx , & input )
272
272
273
273
if err != nil {
274
274
return sdkdiag .AppendErrorf (diags , "updating IoT Domain Configuration (%s): %s" , d .Id (), err )
@@ -283,10 +283,11 @@ func resourceDomainConfigurationDelete(ctx context.Context, d *schema.ResourceDa
283
283
conn := meta .(* conns.AWSClient ).IoTClient (ctx )
284
284
285
285
if d .Get (names .AttrStatus ).(string ) == string (awstypes .DomainConfigurationStatusEnabled ) {
286
- _ , err := conn . UpdateDomainConfiguration ( ctx , & iot.UpdateDomainConfigurationInput {
286
+ input := iot.UpdateDomainConfigurationInput {
287
287
DomainConfigurationName : aws .String (d .Id ()),
288
288
DomainConfigurationStatus : awstypes .DomainConfigurationStatusDisabled ,
289
- })
289
+ }
290
+ _ , err := conn .UpdateDomainConfiguration (ctx , & input )
290
291
291
292
if errs.IsA [* awstypes.ResourceNotFoundException ](err ) {
292
293
return diags
@@ -298,9 +299,10 @@ func resourceDomainConfigurationDelete(ctx context.Context, d *schema.ResourceDa
298
299
}
299
300
300
301
log .Printf ("[DEBUG] Deleting IoT Domain Configuration: %s" , d .Id ())
301
- _ , err := conn . DeleteDomainConfiguration ( ctx , & iot.DeleteDomainConfigurationInput {
302
+ input := iot.DeleteDomainConfigurationInput {
302
303
DomainConfigurationName : aws .String (d .Id ()),
303
- })
304
+ }
305
+ _ , err := conn .DeleteDomainConfiguration (ctx , & input )
304
306
305
307
if errs.IsA [* awstypes.ResourceNotFoundException ](err ) {
306
308
return diags
@@ -314,11 +316,11 @@ func resourceDomainConfigurationDelete(ctx context.Context, d *schema.ResourceDa
314
316
}
315
317
316
318
func findDomainConfigurationByName (ctx context.Context , conn * iot.Client , name string ) (* iot.DescribeDomainConfigurationOutput , error ) {
317
- input := & iot.DescribeDomainConfigurationInput {
319
+ input := iot.DescribeDomainConfigurationInput {
318
320
DomainConfigurationName : aws .String (name ),
319
321
}
320
322
321
- output , err := conn .DescribeDomainConfiguration (ctx , input )
323
+ output , err := conn .DescribeDomainConfiguration (ctx , & input )
322
324
323
325
if errs.IsA [* awstypes.ResourceNotFoundException ](err ) {
324
326
return nil , & retry.NotFoundError {
0 commit comments