Open benhoskings opened 2 years ago
A partial workaround for this is to pull down your state file (terraform state pull
), find the tls_cert_request.example
resource, and copy the values in the subject
object over to your .tf
files. For example:
"subject": [
{
"common_name": "clientname",
"country": "",
"locality": "",
"organization": "my org name",
"organizational_unit": "",
"postal_code": "",
"province": "",
"serial_number": "",
"street_address": []
}
],
becomes
subject {
common_name = "clientname"
organization = "my org name"
country = ""
locality = ""
organizational_unit = ""
postal_code = ""
province = ""
serial_number = ""
street_address = []
}
You may still see ~ private_key_pem = (sensitive value)
but at least it changes from a replacement to an update. (It's still not something I'm comfortable applying but maybe this'll help others that are OK with the private key changing).
I wonder if the private_key_pem
update is a red herring. I'm seeing changes to cert_request_pem
that are reported as changes from a checksum to a CSR:
~ ca_cert_pem = (sensitive)
~ ca_private_key_pem = (sensitive value)
~ cert_request_pem = <<-EOT
- 56683b36b91b66c5b78cfdcfac4817f8a304b04d
+ -----BEGIN CERTIFICATE REQUEST-----
+ MIICdjCCAV4CAQAwMTESMBAGA1...
I've verified that the checksum (566..) is indeed the shasum for the CSR, so won't actually change anything. I think it's the same thing for private_key_pem
based on the output of terraform show -out=json
.
FWIW, I've tested this with v4.0.2.
I've committed a fix to a local copy of the provider. It seems to work but I don't know if it is doing it right.
The problem: The state file contains a SHA1 hash of some PEMs, so when the plan is compared against the state a difference is identified. I think this only occurs when some other value in the resource changes (e.g. the street_address
or whatever).
The "fix": If the SHA1 of the PEM in the plan matches the value in state, ignore the change. Or, rather, overwrite the plan value with the state value.
https://github.com/dpkirchner/terraform-provider-tls/commit/6610b48339251661ab112aa23215d128d7736e0f
We're having the same issue currently. Upgrading to hashicorp/tls
without any values changing is wanting to replace our entire root trust. Using 4.0.3
Any update on this?
Terraform CLI and Provider Versions
Terraform Configuration
Expected Behavior
No diff
Actual Behavior
Plan recreates the
tls_cert_request
Steps to Reproduce
terraform plan
on v4How much impact is this issue causing?
High
Logs
No response
Additional Information
On upgrading to v4 of the tls provider I found that our
tls_cert_request
resources, which are unchanged and have no diff on v3.4, are up for replacement due to a change in the handling of the subject block. It appears that the block itself is forcing replacement, rather than any attribute within it.Using tls v3.4.0, everything is as expected:
Using tls v4.0.1, the subject block causes the resource to churn:
Using tls v4.0.1 and adding
street_address = []
to the resource definition, the subject block still forces replacement even though none of the attributes within it are changing:Using tls v4.0.1 and ignoring changes on all of
subject
, it looks OK; consideringprivate_key_pem
is now stored as-is this is an expected change:Code of Conduct