Migrating to the new provider
This page provides instructions for migrating your Terraform state and configuration from the legacy Sectigo provider (v2.0.1) to the new provider.
Overview
The legacy provider used a single sectigo_certificate resource type with a cert_config_type discriminator field.
The new provider uses separate resource types:
-
sectigo_ssl_certificate— for SSL/TLS certificates -
sectigo_client_certificate— for client (S/MIME) certificates
This migration tool handles:
-
Converting resource types and attribute names.
-
Transforming flat attributes to nested structures (
csr_params,renew_options). -
Converting comma-separated SANs to list format.
-
Reading private keys and certificates from disk files (legacy provider wrote these to disk, not state).
-
Generating new Terraform configuration compatible with the new provider.
Configure the options
Configure the options referring to the following table.
sectigo-migrate [options]
| Option | Default | Description |
|---|---|---|
|
|
Path to legacy terraform.tfstate file |
|
|
Path for converted state file |
|
|
Path for generated Terraform configuration |
|
(from state) |
Directory containing certificate/key files |
|
|
New provider address |
|
|
Print conversion results without writing files |
|
|
Enable verbose output |
Examples
Preview migration (dry-run)
sectigo-migrate -input terraform.tfstate -dry-run -verbose
Perform migration
sectigo-migrate \
-input terraform.tfstate \
-output-state terraform.tfstate.new \
-output-config main.tf.new \
-provider "hashicorp.com/edu/sectigo"
Specify certificate directory
If your certificate files are in a different location than recorded in state, specify the correct location.
sectigo-migrate \
-input terraform.tfstate \
-cert-dir /path/to/certs \
-output-state terraform.tfstate.new \
-output-config main.tf.new
Perform the migration
-
Backup your current state.
cp terraform.tfstate terraform.tfstate.backup -
Run the migration tool.
sectigo-migrate \ -input terraform.tfstate \ -output-state terraform.tfstate.new \ -output-config main.tf.new \ -provider "hashicorp.com/edu/sectigo" \ -verbose -
Examine the generated configuration (
main.tf.new) and state (terraform.tfstate.new) to ensure they look correct. -
Update the provider configuration.
The generated
main.tf.newincludes a provider block with placeholders for credentials.provider "sectigo" { host = "https://demo.cert-manager.com" # username = var.SECTIGO_USERNAME # Or set SECTIGO_USERNAME env var # password = var.SECTIGO_PASSWORD # Or set SECTIGO_PASSWORD env var # customer_uri = var.SECTIGO_CUSTOMER_URI # Or set SECTIGO_CUSTOMER_URI env var }Update this to use your preferred credential method.
Option A: Environment variables
export SECTIGO_HOST="https://cert-manager.com" export SECTIGO_USERNAME="your-username" export SECTIGO_PASSWORD="your-password" export SECTIGO_CUSTOMER_URI="your-customer-uri"Option B: Variables file
# terraform.tfvars SECTIGO_USERNAME = "your-username" SECTIGO_PASSWORD = "your-password" SECTIGO_CUSTOMER_URI = "your-customer-uri" -
Replace state and configuration.
# Backup and replace state mv terraform.tfstate terraform.tfstate.legacy mv terraform.tfstate.new terraform.tfstate # Replace configuration mv main.tf main.tf.legacy mv main.tf.new main.tf -
Install the new provider.
The new provider must be installed before running Terraform commands.
Option A: Download from releases
# Download the provider binary for your platform # Place it in the Terraform plugin directory: ~/.terraform.d/plugins/terraform.local/local/sectigo/1.0.0/<os>_<arch>/terraform-provider-sectigo_v1.0.0Option B: Build from source
cd terraform-provider-sectigo make install -
Configure provider credentials.
Update the provider block in
main.tfwith your credentials.provider "sectigo" { host = "https://cert-manager.com" username = var.SECTIGO_USERNAME password = var.SECTIGO_PASSWORD customer_uri = var.SECTIGO_CUSTOMER_URI }Create a
variables.tffile.variable "SECTIGO_USERNAME" { type = string sensitive = true } variable "SECTIGO_PASSWORD" { type = string sensitive = true } variable "SECTIGO_CUSTOMER_URI" { type = string }Option A: Create a
terraform.tfvarsfile (do not commit to version control)SECTIGO_USERNAME = "your-username" SECTIGO_PASSWORD = "your-password" SECTIGO_CUSTOMER_URI = "your-customer-uri"Option B: Use environment variables
export SECTIGO_HOST="https://cert-manager.com" export SECTIGO_USERNAME="your-username" export SECTIGO_PASSWORD="your-password" export SECTIGO_CUSTOMER_URI="your-customer-uri" -
Initialize and verify.
# Initialize Terraform with the new provider terraform init # Verify no changes detected terraform planYou should see the following message:
No changes. Your infrastructure matches the configuration.If Terraform shows changes, review the differences and adjust your configuration as needed.
-
Continue using Terraform.
After successful migration, you can manage your certificates with standard Terraform commands:
# Make changes to your configuration terraform plan # Apply changes (renew, replace, or modify certificates) terraform apply # Destroy certificates when no longer needed terraform destroy
Attribute Mapping Reference
Provider Configuration
| Legacy | New | Notes |
|---|---|---|
|
|
Environment variable |
|
|
Environment variable |
|
|
Environment variable |
(in resource |
|
Moved to provider level |
SSL Certificate Attributes
| Legacy | New | Notes |
|---|---|---|
|
(implicit) |
Resource type determines this |
|
|
Direct mapping |
|
|
Direct mapping |
|
|
Direct mapping |
|
|
Direct mapping |
|
|
Direct mapping |
|
|
Comma-separated → List |
|
|
Format conversion |
|
|
Direct mapping |
|
|
Nested |
|
|
Nested |
|
|
Nested |
|
|
Nested |
|
|
Nested |
|
|
Nested |
|
|
Nested |
|
|
Nested |
|
|
Nested, int → string |
|
|
Nested |
|
|
Nested |
|
|
Computed |
|
|
Computed |
Client Certificate Attributes
| Legacy | New | Notes |
|---|---|---|
|
|
Nested |
|
|
Direct mapping |
|
|
Direct mapping |
|
|
Direct mapping |
|
|
Format conversion |
|
|
Computed |
Removed Attributes
These legacy attributes are not supported in the new provider:
| Legacy Attribute | Reason |
|---|---|
|
Use |
|
Use |
|
Fixed to x509CO |
|
Not used |
|
Not used |
|
Handled internally |
|
Handled internally |
|
Fixed message on delete |
|
Always revokes |
Writing certificates to files
The legacy provider automatically wrote certificates to disk.
With the new provider, use the local_file resource.
resource "sectigo_ssl_certificate" "example" {
# ... certificate configuration
}
resource "local_file" "certificate" {
content = sectigo_ssl_certificate.example.certificate_body
filename = "${path.module}/certificate.crt"
}
resource "local_sensitive_file" "private_key" {
content = sectigo_ssl_certificate.example.csr_params.private_key_pem
filename = "${path.module}/private.key"
}
Troubleshooting
"Could not read private key" warning
The migration tool tries to read private keys from files at the paths stored in the legacy state (cert_file_path/cert_file_name).
If these files have been moved:
-
Use
-cert-dirto specify the current location. -
Or manually add the private key to the state after migration.
Terraform plan shows changes
If terraform plan shows changes after migration:
-
Missing attributes: Some computed attributes may need to be fetched. Run
terraform applyto sync. -
Type mismatches: Check that numeric values haven’t become strings or vice versa.
-
Null vs empty: Empty lists/strings may show as changes.
Support
For problems with the migration tool, please open an issue at: https://github.com/sectigo-eng/terraform-provider-sectigo/issues