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

CDN: Add Support for "needs-cloudflare-cert" #1089

Merged
merged 7 commits into from
Dec 5, 2023
Merged

Conversation

danaelhe
Copy link
Member

@danaelhe danaelhe commented Dec 4, 2023

Address #1086

In order to have Cloudflare generate a certificate, certificate_id must be set to the value "needs-cloudflare-cert" in our API.

In the Terraform provider certificate_name is passed in instead of a certificate_id (we've deprecated certificate_id attribute in favor of certificate_name for digitalocean_cdn because when the certificate type is lets_encrypt, the certificate ID will change on renewal (after 3 months)), we use the name to look up the id and then set that id to certificate_id.....hence the certificate_id will not be needs-cloudflare-cert here:

	if name, nameOk := d.GetOk("certificate_name"); nameOk {
		certName := name.(string)
		if certName != "" {
			cert, err := certificate.FindCertificateByName(client, certName)
			if err != nil {
				return diag.FromErr(err)
			}

			cdnRequest.CertificateID = cert.ID
		}

Added logic to check if needs-cloudflare-certis passed into certificate_name to set that as the certificate_id

@danaelhe
Copy link
Member Author

danaelhe commented Dec 4, 2023

Hey @itssimon - could you give this a try?

@danaelhe danaelhe marked this pull request as draft December 4, 2023 18:59
@danaelhe danaelhe marked this pull request as ready for review December 4, 2023 20:55
Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Think this is a great workaround for the moment.

Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@danaelhe danaelhe merged commit 7dde232 into main Dec 5, 2023
2 checks passed
@danaelhe danaelhe deleted the cdn_cloudflare_cert branch December 5, 2023 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants