Using the Terraform provider
This page describes how to issue and manage certificates using the Sectigo Terraform provider.
Request an SSL certificate
To request an SSL certificate, add the following resource block to your Terraform configuration file (for example, main.tf) and run terraform apply.
resource "sectigo_ssl_certificate" "example" {
org_id = 123
cert_profile_id = 456
csr_params = {
common_name = "example.com"
country = "US"
province = "California"
locality = "San Francisco"
organization = "My Company"
organizational_unit = "IT"
email = "[email protected]"
private_key_algorithm = "RSA"
private_key_size = "2048"
}
subject_alt_names = ["www.example.com", "api.example.com"]
validity = 365
external_requester = "[email protected]"
}
output "certificate" {
value = sectigo_ssl_certificate.example.certificate_body
sensitive = true
}
output "private_key" {
value = sectigo_ssl_certificate.example.csr_params.private_key_pem
sensitive = true
}
SSL certificate parameters
| Parameter | Type | Requirement | Description |
|---|---|---|---|
|
Number |
Mandatory |
Sectigo organization ID |
|
Number |
Mandatory |
Certificate profile ID |
|
Object |
Mandatory |
CSR parameters (see below) |
|
String |
Mandatory |
Requester email address |
|
List (string) |
Subject Alternative Names |
|
|
Number |
Validity period in days |
|
|
String |
Certificate comments |
|
|
List (object) |
Custom field key-value pairs |
|
|
Object |
Renewal configuration |
|
|
Object |
Revocation check configuration |
|
|
String |
External CSR in PEM format. When provided, |
|
|
Number |
Computed |
Sectigo certificate ID |
|
String |
Computed |
Renewal tracking ID |
|
String |
Computed |
PEM-encoded certificate chain |
Request a client certificate
To request a client certificate, add the following resource block to your Terraform configuration file (for example, main.tf) and run terraform apply.
resource "sectigo_client_certificate" "example" {
org_id = 123
cert_profile_id = 789
csr_params = {
common_name = "John Doe"
country = "US"
province = "California"
locality = "San Francisco"
organization = "My Company"
organizational_unit = "Engineering"
email = "[email protected]"
private_key_algorithm = "RSA"
private_key_size = "2048"
}
first_name = "John"
last_name = "Doe"
validity = 365
}
Client certificate parameters
| Parameter | Type | Requirement | Description |
|---|---|---|---|
|
Number |
Mandatory |
Sectigo organization ID |
|
Number |
Mandatory |
Certificate profile ID |
|
Object |
Mandatory |
CSR parameters (see below) |
|
String |
Mandatory |
Certificate holder’s first name |
|
String |
Mandatory |
Certificate holder’s last name |
|
String |
Certificate holder’s middle name |
|
|
String |
Phone number |
|
|
List (string) |
Additional email addresses |
|
|
Number |
Validity period in days |
|
|
String |
Certificate comments |
|
|
List (object) |
Custom field key-value pairs |
|
|
Object |
Renewal configuration |
|
|
Object |
Revocation check configuration |
|
|
String |
External CSR in PEM format. When provided, |
|
|
Number |
Computed |
Sectigo order number |
|
String |
Computed |
Backend certificate ID |
|
String |
Computed |
PEM-encoded certificate chain |
Request a CSR
CSR parameters are specified inside the csr_params block of an SSL or client certificate resource. The provider generates a private key and CSR automatically based on these parameters. Alternatively, you can provide your own pre-signed CSR using the external_csr attribute instead of csr_params.
CSR parameters
| Parameter | Type | Requirement | Description |
|---|---|---|---|
|
String |
Mandatory |
Domain (SSL) or name (Client) |
|
String |
Mandatory |
Two-letter country code |
|
String |
Mandatory |
State or province |
|
String |
Mandatory |
City |
|
String |
Mandatory |
Organization name |
|
String |
Mandatory |
Department |
|
String |
Mandatory |
Email address |
|
String |
Mandatory |
|
|
String |
Mandatory |
Key size. The options are:
|
|
String |
Computed |
Generated private key (sensitive) |
Configure auto-renewal
Configure automatic certificate renewal before expiry (see example below).
-
When you run
terraform plan, the provider checks if the certificate is within the expiry window. If renewal is needed, the plan shows the computed attributes (ssl_id,renew_id,certificate_body) as(known after apply). No API calls are made during plan. -
When you run
terraform apply, the actual renewal is performed via the Sectigo API. -
If
auto_renew=true, and the certificate is within the expiry window, the certificate is renewed. -
If
force_renew=true, the certificate is always renewed regardless of the expiry window.
force_renew must be manually reset to false after renewal, otherwise every terraform plan will show pending changes and every terraform apply will renew the certificate.
|
resource "sectigo_ssl_certificate" "auto_renew" {
# ... required fields ...
renew_options = {
auto_renew = true # Enable auto-renewal
expiry_window = 30 # Renew 30 days before expiry
force_renew = false # Set true to force immediate renewal
}
}
Auto-renewal parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
|
Bool |
|
Enable automatic renewal. Options are |
|
Number |
|
Number of days before expiry to trigger renewal. |
|
Bool |
|
Force renewal on next apply. Options are |
Validate revocation status before renewal
Before renewal or replacement, the provider checks the certificate revocation status using first OCSP, with CRL as a fallback.
-
If the certificate is not revoked, the operation proceeds normally.
-
If the certificate is revoked:
-
If
fail_on_revoked=true, the operation is blocked with an error. -
If
fail_on_revoked=false, a warning is displayed and the provider auto-enrolls a fresh certificate, skipping the Renew/Replace APIs which would fail on a revoked certificate.
-
resource "sectigo_ssl_certificate" "with_revocation" {
# ... required fields ...
revocation_check = {
enabled = true # Enable checking
check_ocsp = true # Try OCSP first
check_crl = true # Fall back to CRL
fail_on_revoked = true # Fail or warn on revoked
timeout_seconds = 10 # HTTP timeout
}
}
Check revocation status parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
|
Bool |
|
Enable revocation checking |
|
Bool |
|
Attempt OCSP check |
|
Bool |
|
Fall back to CRL |
|
Bool |
|
|
|
Number |
|
HTTP request timeout |