ivkcs_cert resource
The ivkcs_cert resource is designed for automatic creation and management of SSL certificates on virtual machines.
Name | Description | Format | Required | Resource recreation on value change |
|---|---|---|---|---|
| UUID of the image-based application instance | string | ||
| FQDN of the domain for which the certificate will be issued | string | ||
| Path to the directory where the certificate and key files will be saved | string | ||
| Path to the bash script that will be executed after each certificate renewal | string | ||
| Owner of the certificate and key files | string | ||
| Group of the certificate and key files | string | ||
| Certificate creation timeout. When the timeout expires, the process terminates with an error | string | ||
| Certificate update timeout. When the timeout expires, the process terminates with an error | string | ||
| Certificate deletion timeout. It is counted from the moment the user deleted their application instance. When the timeout expires, the process terminates with an error | string |
The script specified in the renewal_hook_path argument is executed after each certificate renewal:
- on behalf of the user specified in the
cert_files_ownerargument, if this argument is set; - on behalf of the
rootuser, if thecert_files_ownerargument is not set.
Example script for reloading the Nginx server:
#!/bin/bash# /opt/scripts/reload_nginx.sh# Проверяем конфигурацию nginxif nginx -t; then# Перезагружаем nginxsystemctl reload nginxecho "$(date): Nginx reloaded successfully after certificate renewal"elseecho "$(date): Nginx configuration test failed, not reloading"exit 1fi
Name | Description | Format |
|---|---|---|
| Unique certificate identifier | string |
| Certificate contents (confidential data) | string |
| Private key (confidential data) | string |
resource "ivkcs_cert" "website" {uuid = "550e8400-e29b-41d4-a716-446655440000"domain = "www.mysite.com"path_cert = "/etc/nginx/ssl/"renewal_hook_path = "/usr/local/bin/reload_nginx.sh"}# Использование сертификата в конфигурации nginxresource "ivkcs_user_data" "nginx_config" {uuid = ivkcs_cert.website.uuid# ... другие параметры}
Example 2. Microservice with access rights configuration:
resource "ivkcs_cert" "api_service" {uuid = var.deployment_uuiddomain = "api.service.internal"path_cert = "/opt/service/certs/"renewal_hook_path = "/opt/service/scripts/restart.sh"cert_files_owner = "service"cert_files_group = "service"timeouts {create = "45m"}}
Example 3. Multiple certificates:
variable "domains" {type = list(string)default = ["app.example.com", "api.example.com", "admin.example.com"]}resource "ivkcs_cert" "multi_certs" {for_each = toset(var.domains)uuid = var.instance_uuiddomain = each.valuepath_cert = "/etc/ssl/${each.value}/"renewal_hook_path = "/opt/scripts/reload_services.sh"cert_files_owner = "www-data"cert_files_group = "ssl-cert"}