Skip to content

Commit

Permalink
resource/aws_dms_certificate: Properly set certificate_wallet into Te…
Browse files Browse the repository at this point in the history
…rraform state (#11496)

Reference: #9954
Reference: https://github.com/terraform-providers/terraform-provider-aws/blob/768341474a743c3db30610c6b434fed598d98cd8/aws/resource_aws_dms_certificate.go#L71

Previously:

```
/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_dms_certificate.go:130:31: R004: ResourceData.Set() incompatible value type: []byte
```

Here we perform the opposite `[]byte` to `string` conversion as compared to the creation function to prevent silently ignoring a type error in the `d.Set()` call and fix drift detection for the attribute.

Output from acceptance testing:

```
--- PASS: TestAccAWSDmsCertificateBasic (17.45s)
```

Aside: Its worth noting that this attribute is not acceptance tested and potentially may not work as given in Terraform 0.12+ if there are non UTF-8 characters in the value (e.g. the `file()` function will error). Generally `[]byte` attributes must have base64 encoding/decoding added above and beyond the AWS Go SDK's handling, however I do not have intimate knowledge about this functionality, so it may be okay. There are no bug reports and it would take a non-trivial amount of effort to create a valid Oracle Wallet acceptance test, so this fix is best effort with other similar fixes to allow us to continue working towards enabling the `tfproviderlint` `R004` check in the near future.
  • Loading branch information
bflad authored Jan 17, 2020
1 parent 071abb3 commit 3973812
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aws/resource_aws_dms_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func resourceAwsDmsCertificateSetState(d *schema.ResourceData, cert *dms.Certifi
if cert.CertificatePem != nil && *cert.CertificatePem != "" {
d.Set("certificate_pem", cert.CertificatePem)
}
if cert.CertificateWallet != nil && len(cert.CertificateWallet) == 0 {
d.Set("certificate_wallet", cert.CertificateWallet)
if cert.CertificateWallet != nil && len(cert.CertificateWallet) != 0 {
d.Set("certificate_wallet", string(cert.CertificateWallet))
}

return nil
Expand Down

0 comments on commit 3973812

Please sign in to comment.