Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore tls_cert_request to being a managed resource #9035

Merged
merged 1 commit into from
Sep 30, 2016
Merged

Restore tls_cert_request to being a managed resource #9035

merged 1 commit into from
Sep 30, 2016

Conversation

apparentlymart
Copy link
Contributor

@apparentlymart apparentlymart commented Sep 24, 2016

In c244e5a (#7469) this resource was converted to a data source, but that was a big mistake on my part since data sources are expected to produce stable results on each run, and yet certificate requests contain a random nonce as part of the signature and so any other downstream resources will see a new cert request PEM on each run, preventing convergence.

Additionally, using the data source as a managed resource through the provided compatibility shim was not actually working, since Read was trying to parse the private key out of a SHA1 hash of the key, which is what we place in state due to the StateFunc on that attribute.

By restoring this we restore Terraform's ability to produce all of the parts of a basic PKI/CA, which is useful for creating dev environments and bootstrapping PKI for production environments.

This is basically just a revert of c244e5a, but with some extra text in the docs to explain this resource's temporary stint as a data source in case some folks find old, broken examples elsewhere and wonder what's going on. (These docs assume this would be merged in time for 0.7.5, and will need to be amended if not.)

This is a backward-compatibility break that should be noted in CHANGELOG.md if merged. I intentionally did not preserve compatibility with using this as a data source since it was so broken as to be useless anyway, and so little reason to stay compatible with it.

This fixes #8764 and #8782, addresses an issue reported via the mailing list, and makes my article on using Terraform as a CA actually work. 😀

In c244e5a this resource was converted to a data source, but that was
a mistake since data sources are expected to produce stable results on
each run, and yet certificate requests contain a random nonce as part of
the signature.

Additionally, using the data source as a managed resource through the
provided compatibility shim was not actually working, since "Read" was
trying to parse the private key out of a SHA1 hash of the key, which is
what we place in state due to the StateFunc on that attribute.

By restoring this we restore Terraform's ability to produce all of the
parts of a basic PKI/CA, which is useful for creating dev environments
and bootstrapping PKI for production environments.
@blurrcat
Copy link

@apparentlymart Thanks for the awesome blog AND this PR!
Now terraform generates a new CSR every time and this goes down the stream to change everything, user-data, launch configuration, asg, instances..

@blurrcat blurrcat mentioned this pull request Sep 26, 2016
12 tasks
@jen20 jen20 merged commit 506268a into hashicorp:master Sep 30, 2016
terraformbot pushed a commit that referenced this pull request Sep 30, 2016
[origin/master] Merge pull request #9035 from apparentlymart/tls-cert-request-resource
506268a
@jen20
Copy link
Contributor

jen20 commented Sep 30, 2016

Thanks @apparentlymart! I just hit this while reading your article, so great timing 👍!

@davemssavage
Copy link

Thanks @apparentlymart for the fix, yes I've also just been hit by this issue on 0.7.4, any idea on the ETA of the next release?

@ghost
Copy link

ghost commented Apr 21, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tls_cert_request with count forces new resource every time
4 participants