christianlempa-boilerplates/terraform/templates/kubernetes-automation-example/certmanager.tf

80 lines
1.5 KiB
Terraform
Raw Normal View History

2022-03-17 13:09:48 +01:00
resource "kubernetes_namespace" "certmanager" {
2022-04-01 09:25:19 +02:00
depends_on = [
time_sleep.wait_for_kubernetes
]
2022-03-17 13:09:48 +01:00
metadata {
name = "certmanager"
}
2022-04-01 09:25:19 +02:00
2022-03-17 13:09:48 +01:00
}
resource "helm_release" "certmanager" {
2022-04-01 09:25:19 +02:00
depends_on = [
kubernetes_namespace.certmanager
]
2022-03-17 13:09:48 +01:00
name = "certmanager"
namespace = "certmanager"
repository = "https://charts.jetstack.io"
2022-04-01 09:25:19 +02:00
chart = "cert-manager"
2022-03-17 13:09:48 +01:00
# Install Kubernetes CRDs
set {
name = "installCRDs"
value = "true"
2022-04-01 09:25:19 +02:00
}
2022-03-17 13:09:48 +01:00
}
resource "time_sleep" "wait_for_certmanager" {
2022-04-01 09:25:19 +02:00
depends_on = [
helm_release.certmanager
]
2022-03-17 13:09:48 +01:00
create_duration = "10s"
}
2022-04-01 09:25:19 +02:00
# Create a ClusterIssuer
resource "kubectl_manifest" "cloudflare_prod" {
depends_on = [
time_sleep.wait_for_certmanager
]
# TODO: add your mail address according to your configuration and API authentication settings!
# ---
yaml_body = <<YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: cloudflare-prod
spec:
acme:
email: your-mail-address
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: cloudflare-prod-account-key
solvers:
- dns01:
cloudflare:
email: your-mail-address
apiKeySecretRef:
name: cloudflare-api-key-secret
key: api-key
YAML
}
resource "time_sleep" "wait_for_clusterissuer" {
depends_on = [
kubectl_manifest.cloudflare_prod
]
create_duration = "30s"
}