Improve idempotency of aws_iam_server_certificate provisioning #2411
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses issue #2409. A brief recap follows:
When Terraform pulls down state data about AWS IAM certificates in its purview, it normalizes the certificate body by trimming whitespace from it and taking a SHA1 hash of the resulting string. This works well for dealing with newline characters at the end of a certificate, however, this logic does not apply to the certificate chain. A change to the certificate chain is enough for Terraform to rebuild the resource. The combination of these two circumstances means that, if one has an IAM certificate with a chain in their Terraform configuration,
terraform plan
will always require some action, even if everything appears to be in sync.This pull request normalizes the certificate chain in the same way as the certificate body. While the major gains are in the use of
strings.TrimSpace
, the SHA hashing is nice to have, as well. In passing, the integration test for this resource has been updated to include a self-signed certificate bearing a CA chain.