Skip to content

Commit

Permalink
resource/aws_iot_certificate: Fixes for tfproviderlint R002
Browse files Browse the repository at this point in the history
Reference: #9952

Remove pointer value dereferences, which can cause potential panics and are extraneous as `Set()` automatically handles pointer types including when `nil`.

Previously:

```
aws/resource_aws_iot_certificate.go:77:23: R002: ResourceData.Set() pointer value dereference is extraneous
aws/resource_aws_iot_certificate.go:78:24: R002: ResourceData.Set() pointer value dereference is extraneous
```

Output from acceptance testing:

```
--- PASS: TestAccAWSIoTCertificate_keys_certificate (14.29s)
--- PASS: TestAccAWSIoTCertificate_csr (14.85s)
```
  • Loading branch information
bflad committed Feb 13, 2020
1 parent 0efdad0 commit 2e0e6a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aws/resource_aws_iot_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func resourceAwsIotCertificateCreate(d *schema.ResourceData, meta interface{}) e
}
log.Printf("[DEBUG] Created certificate from CSR")

d.SetId(*out.CertificateId)
d.SetId(aws.StringValue(out.CertificateId))
} else {
log.Printf("[DEBUG] Creating keys and certificate")
out, err := conn.CreateKeysAndCertificate(&iot.CreateKeysAndCertificateInput{
Expand All @@ -73,9 +73,9 @@ func resourceAwsIotCertificateCreate(d *schema.ResourceData, meta interface{}) e
}
log.Printf("[DEBUG] Created keys and certificate")

d.SetId(*out.CertificateId)
d.Set("public_key", *out.KeyPair.PublicKey)
d.Set("private_key", *out.KeyPair.PrivateKey)
d.SetId(aws.StringValue(out.CertificateId))
d.Set("public_key", out.KeyPair.PublicKey)
d.Set("private_key", out.KeyPair.PrivateKey)
}

return resourceAwsIotCertificateRead(d, meta)
Expand Down

0 comments on commit 2e0e6a1

Please sign in to comment.