Get the contents of the Let's Encrypt certificate
You can upload a certificate chain and a private key to use on your own, for example, when configuring a web server on a VM.
To get the contents of a certificate:
The command will display a certificate chain and a private key and save their contents to the --chain
and --key
files, respectively.
--id
: Certificate ID; make sure you set either the--id
or--name
flag.--name
: Name of the certificate; make sure you set either the--id
or--name
flag.--chain
: (Optional) File to save the certificate chain to in PEM format.--key
: (Optional) File to save the private key to, in PEM format.
yc certificate-manager certificate content \
--id fpqcsmn76v82fi446ri7 \
--chain certificate_full_chain.pem \
--key private_key.pem
With Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically determines which part of your configuration is already deployed and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To get the contents of a custom certificate using Terraform:
-
In the Terraform configuration file, describe the parameters of the resources you want to create:
data "yandex_cm_certificate_content" "cert_by_id" { certificate_id = "<certificate_ID>" } output "certificate_chain" { value = data.yandex_cm_certificate_content.cert_by_id.certificates } output "certificate_key" { value = data.yandex_cm_certificate_content.cert_by_id.private_key sensitive = true }
Where:
data "yandex_cm_certificate_content"
: Description of the data source for the certificate contents:certificate_id
: Certificate ID
output
sections: Output variables such ascertificate_chain
with a certificate chain and acertificate_key
private key:value
: Returned valuesensitive
: Label data as sensitive
For more information about the
yandex_cm_certificate_content
data source parameters, see the provider documentation . -
Create resources:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
Terraform will create all the required resources. To check the results, run these commands:
-
Get a certificate chain:
terraform output certificate_chain
-
Get the private key value:
terraform output -raw certificate_key
-
To get the certificate contents, use the get REST API method for the CertificateContent resource or the CertificateContentService/Get gRPC API call.
Note
To view the certificate contents, assign the certificate-manager.certificates.downloader
role to the service account.