Skip to content

Commit 46f4b8c

Browse files
committed
r/aws_iot_domain_configuration: Alphabetize.
1 parent a2ebe59 commit 46f4b8c

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

internal/service/iot/domain_configuration.go

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,19 @@ func resourceDomainConfigurationCreate(ctx context.Context, d *schema.ResourceDa
139139
conn := meta.(*conns.AWSClient).IoTClient(ctx)
140140

141141
name := d.Get(names.AttrName).(string)
142-
input := &iot.CreateDomainConfigurationInput{
142+
input := iot.CreateDomainConfigurationInput{
143143
DomainConfigurationName: aws.String(name),
144144
Tags: getTagsIn(ctx),
145145
}
146146

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+
147155
if v, ok := d.GetOk("authorizer_config"); ok && len(v.([]any)) > 0 && v.([]any)[0] != nil {
148156
input.AuthorizerConfig = expandAuthorizerConfig(v.([]any)[0].(map[string]any))
149157
}
@@ -168,15 +176,7 @@ func resourceDomainConfigurationCreate(ctx context.Context, d *schema.ResourceDa
168176
input.ValidationCertificateArn = aws.String(v.(string))
169177
}
170178

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)
180180

181181
if err != nil {
182182
return sdkdiag.AppendErrorf(diags, "creating IoT Domain Configuration (%s): %s", name, err)
@@ -203,7 +203,9 @@ func resourceDomainConfigurationRead(ctx context.Context, d *schema.ResourceData
203203
return sdkdiag.AppendErrorf(diags, "reading IoT Domain Configuration (%s): %s", d.Id(), err)
204204
}
205205

206+
d.Set("application_protocol", output.ApplicationProtocol)
206207
d.Set(names.AttrARN, output.DomainConfigurationArn)
208+
d.Set("authentication_type", output.AuthenticationType)
207209
if output.AuthorizerConfig != nil {
208210
if err := d.Set("authorizer_config", []any{flattenAuthorizerConfig(output.AuthorizerConfig)}); err != nil {
209211
return sdkdiag.AppendErrorf(diags, "setting authorizer_config: %s", err)
@@ -227,8 +229,6 @@ func resourceDomainConfigurationRead(ctx context.Context, d *schema.ResourceData
227229
d.Set("tls_config", nil)
228230
}
229231
d.Set("validation_certificate_arn", d.Get("validation_certificate_arn"))
230-
d.Set("authentication_type", output.AuthenticationType)
231-
d.Set("application_protocol", output.ApplicationProtocol)
232232

233233
return diags
234234
}
@@ -238,10 +238,18 @@ func resourceDomainConfigurationUpdate(ctx context.Context, d *schema.ResourceDa
238238
conn := meta.(*conns.AWSClient).IoTClient(ctx)
239239

240240
if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) {
241-
input := &iot.UpdateDomainConfigurationInput{
241+
input := iot.UpdateDomainConfigurationInput{
242242
DomainConfigurationName: aws.String(d.Id()),
243243
}
244244

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+
245253
if d.HasChange("authorizer_config") {
246254
if v, ok := d.GetOk("authorizer_config"); ok && len(v.([]any)) > 0 && v.([]any)[0] != nil {
247255
input.AuthorizerConfig = expandAuthorizerConfig(v.([]any)[0].(map[string]any))
@@ -260,15 +268,7 @@ func resourceDomainConfigurationUpdate(ctx context.Context, d *schema.ResourceDa
260268
}
261269
}
262270

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)
272272

273273
if err != nil {
274274
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
283283
conn := meta.(*conns.AWSClient).IoTClient(ctx)
284284

285285
if d.Get(names.AttrStatus).(string) == string(awstypes.DomainConfigurationStatusEnabled) {
286-
_, err := conn.UpdateDomainConfiguration(ctx, &iot.UpdateDomainConfigurationInput{
286+
input := iot.UpdateDomainConfigurationInput{
287287
DomainConfigurationName: aws.String(d.Id()),
288288
DomainConfigurationStatus: awstypes.DomainConfigurationStatusDisabled,
289-
})
289+
}
290+
_, err := conn.UpdateDomainConfiguration(ctx, &input)
290291

291292
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
292293
return diags
@@ -298,9 +299,10 @@ func resourceDomainConfigurationDelete(ctx context.Context, d *schema.ResourceDa
298299
}
299300

300301
log.Printf("[DEBUG] Deleting IoT Domain Configuration: %s", d.Id())
301-
_, err := conn.DeleteDomainConfiguration(ctx, &iot.DeleteDomainConfigurationInput{
302+
input := iot.DeleteDomainConfigurationInput{
302303
DomainConfigurationName: aws.String(d.Id()),
303-
})
304+
}
305+
_, err := conn.DeleteDomainConfiguration(ctx, &input)
304306

305307
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
306308
return diags
@@ -314,11 +316,11 @@ func resourceDomainConfigurationDelete(ctx context.Context, d *schema.ResourceDa
314316
}
315317

316318
func findDomainConfigurationByName(ctx context.Context, conn *iot.Client, name string) (*iot.DescribeDomainConfigurationOutput, error) {
317-
input := &iot.DescribeDomainConfigurationInput{
319+
input := iot.DescribeDomainConfigurationInput{
318320
DomainConfigurationName: aws.String(name),
319321
}
320322

321-
output, err := conn.DescribeDomainConfiguration(ctx, input)
323+
output, err := conn.DescribeDomainConfiguration(ctx, &input)
322324

323325
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
324326
return nil, &retry.NotFoundError{

internal/service/iot/domain_configuration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ func testAccDomainConfigurationConfig_securityPolicy(rName, rootDomain, domain,
335335
resource "aws_iot_domain_configuration" "test" {
336336
depends_on = [aws_acm_certificate_validation.test]
337337
338-
authentication_type = %[5]q
339-
application_protocol = %[6]q
338+
authentication_type = %[5]q
339+
application_protocol = %[6]q
340340
341341
authorizer_config {
342342
allow_authorizer_override = %[4]t

0 commit comments

Comments
 (0)