Skip to content

Certificate CA

The certificate_ca resource generates Certificate Authority (CA) certificates and keys. This is used to create root certificates that can sign other certificates in your lab environment.

resource "certificate_ca" "root" {
output = "./certs"
}
resource "certificate_ca" "root" {
output = "./certificates"
}
FieldTypeRequiredDescription
outputstringOutput directory to write the certificate and key files
FieldTypeDescription
meta.idstringFull resource identifier
meta.typestringResource type (always "certificate_ca")
meta.namestringResource name
private_keyFileThe private key of the generated CA certificate
public_key_pemFileThe PEM-formatted public key
public_key_sshFileThe SSH-formatted public key
certificateFileThe generated CA certificate

The File object contains information about generated certificate files:

FieldTypeDescription
filenamestringThe name of the file
directorystringThe directory where the file is written
pathstringThe full path to the file
contentsstringThe contents of the file
resource "certificate_ca" "root" {
output = "./certs"
}
resource "certificate_ca" "root" {
output = "./certificates"
}
resource "certificate_leaf" "server" {
ca_key = resource.certificate_ca.root.private_key.path
ca_cert = resource.certificate_ca.root.certificate.path
output = "./server-certs"
dns_names = ["localhost", "server.local"]
ip_addresses = ["127.0.0.1", "192.168.1.100"]
}