Terraform configuration FAQ
This page answers common questions about configuring certificates for CDN accelerated domain names with Terraform.
How do I configure a certificate when creating a CDN accelerated domain name?
Set the alicloud_cdn_domain_newcertificate_config block inside the alicloud_cdn_domain_new resource. The block supports two certificate sources — use cert_type = "cas" to reference a certificate from Certificate Management Service, or cert_type = "upload" to supply the certificate content directly.
Use a certificate from Certificate Management Service
resource "alicloud_cdn_domain_new" "domain" {
scope = "overseas"
domain_name = "mycdndomain-${random_integer.default.result}.alicloud-provider.cn"
cdn_type = "download"
sources {
type = "ipaddr"
content = "1.1.x.x"
priority = 20
port = 80
weight = 15
}
certificate_config {
server_certificate_status = "on"
cert_type = "cas"
cert_id = "1111111"
cert_region = "cn-hangzhou"
}
}
Upload a certificate manually
resource "alicloud_cdn_domain_new" "domain" {
scope = "overseas"
domain_name = "mycdndomain-${random_integer.default.result}.alicloud-provider.cn"
cdn_type = "download"
sources {
type = "ipaddr"
content = "1.1.x.x"
priority = 20
port = 80
weight = 15
}
certificate_config {
server_certificate_status = "on"
cert_type = "upload"
cert_name = "cert-xxxxxxxxx"
server_certificate = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
private_key = "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
}
}
Does the certificate enable automatically after configuration?
Yes. Including the certificate_config block sets server_certificate_status = "on" by default. No additional steps are needed.
What are the supported values for cert_type?
Two values are supported:
upload— supply the certificate content directly. Requiresserver_certificate(public key in PEM format) andprivate_key(private key in PEM format). Specify this orcas.cas— reference an SSL certificate from Certificate Management Service. Requirescert_idandcert_region. Specify this orupload.
The free certificate type is no longer supported.What parameters are required when cert_type is upload?
Provide the following parameters in PEM format:
| Parameter | Required | Description |
|---|---|---|
cert_type | Yes | Set to upload. |
cert_name | No | A name for the certificate. |
server_certificate | Yes | The public key of the certificate in PEM format. |
private_key | Yes | The private key of the certificate in PEM format. |
certificate_config {
cert_type = "upload"
cert_name = "cert-xxxxxxxxx"
server_certificate = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
private_key = "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
}What parameters are required when cert_type is cas?
Provide the following parameters:
| Parameter | Required | Description |
|---|---|---|
cert_type | Yes | Set to cas. |
cert_id | Yes | The ID of the certificate in Certificate Management Service. Get it from the certificate's product page. |
cert_region | Yes | The region of Certificate Management Service. See How do I set cert_region? |
certificate_config {
server_certificate_status = "on"
cert_type = "cas"
cert_id = "1111111"
cert_region = "cn-hangzhou"
}What does cert_region do and how do I set it?
cert_region identifies which regional instance of Certificate Management Service holds your certificate. It is required when cert_type = "cas".
Set it based on the account that owns the certificate:
| Account type | cert_region value |
|---|---|
| Alibaba Cloud China site account | cn-hangzhou |
| Alibaba Cloud International site account | ap-southeast-1 |