-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
211 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
terraform-modules/aws/helm/cert-manager-issuers/dns01-cluster-issuer.tpl.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# doc: https://cert-manager.io/docs/configuration/acme/dns01/route53/ | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: letsencrypt-prod-dns01 | ||
spec: | ||
acme: | ||
server: ${letsEncryptServer} | ||
email: ${emailAddress} | ||
privateKeySecretRef: | ||
name: dns01-issuer-account-key | ||
solvers: | ||
|
||
# example: cross-account zone management for example.com | ||
# this solver uses ambient credentials (i.e. inferred from the environment or EC2 Metadata Service) | ||
# to assume a role in a different account | ||
- selector: | ||
dnsZones: | ||
- "${domainName}" | ||
dns01: | ||
route53: | ||
region: ${awsRegion} | ||
hostedZoneID: ${dnsZhostedZoneIDone} # optional, see policy above | ||
# role: "arn:aws:iam::${awsAccountID}:role/${chartName}-${clusterName}" | ||
|
||
# this solver handles example.org challenges | ||
# and uses explicit credentials | ||
# - selector: | ||
# dnsZones: | ||
# - "example.org" | ||
# dns01: | ||
# route53: | ||
# region: eu-central-1 | ||
# accessKeyID: AKIAIOSFODNN7EXAMPLE | ||
# secretAccessKeySecretRef: | ||
# name: prod-route53-credentials-secret | ||
# key: secret-access-key | ||
# # you can also assume a role with these credentials | ||
# role: arn:aws:iam::YYYYYYYYYYYY:role/dns-manager |
16 changes: 16 additions & 0 deletions
16
terraform-modules/aws/helm/cert-manager-issuers/http01-cluster-issuer.tpl.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# doc: https://cert-manager.io/docs/configuration/acme/http01/ | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: letsencrypt-prod-http01 | ||
spec: | ||
acme: | ||
server: ${letsEncryptServer} | ||
email: ${emailAddress} | ||
privateKeySecretRef: | ||
name: http01-issuer-account-key | ||
solvers: | ||
- http01: | ||
ingress: | ||
class: ${ingressClass} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
locals { | ||
official_chart_name = "cert-manager" | ||
} | ||
|
||
data "aws_caller_identity" "current" {} | ||
|
||
############################# | ||
# cert-manager DNS01 cluster-issuer | ||
# https://cert-manager.io/docs/configuration/acme/dns01/route53/#creating-an-issuer-or-clusterissuer | ||
############################# | ||
# file templating | ||
data "template_file" "dns01_cluster_issuer_yaml" { | ||
template = file("${path.module}/dns01-cluster-issuer.tpl.yaml") | ||
|
||
vars = { | ||
awsRegion = var.aws_region | ||
letsEncryptServer = var.lets_encrypt_server | ||
emailAddress = var.lets_encrypt_email | ||
dnsZhostedZoneIDone = var.route53_hosted_zones | ||
domainName = var.domain_name | ||
awsAccountID = data.aws_caller_identity.current.account_id | ||
clusterName = var.cluster_name | ||
chartName = local.official_chart_name | ||
} | ||
} | ||
|
||
resource "kubernetes_manifest" "dns01_cluster_issuer" { | ||
count = var.enable_dns01_cluster_issuer | ||
manifest = yamldecode(data.template_file.dns01_cluster_issuer_yaml.rendered) | ||
} | ||
|
||
############################# | ||
# cert-manager HTTP01 cluster-issuer | ||
# https://cert-manager.io/docs/configuration/acme/http01/#configuring-the-http01-ingress-solver | ||
############################# | ||
# file templating | ||
data "template_file" "http01_cluster_issuer_yaml" { | ||
template = file("${path.module}/http01-cluster-issuer.tpl.yaml") | ||
|
||
vars = { | ||
emailAddress = var.lets_encrypt_email | ||
letsEncryptServer = var.lets_encrypt_server | ||
ingressClass = var.ingress_class | ||
} | ||
} | ||
|
||
resource "kubernetes_manifest" "http01_cluster_issuer" { | ||
count = var.enable_http01_cluster_issuer | ||
manifest = yamldecode(data.template_file.http01_cluster_issuer_yaml.rendered) | ||
} |
55 changes: 55 additions & 0 deletions
55
terraform-modules/aws/helm/cert-manager-issuers/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
|
||
variable "aws_region" { | ||
type = string | ||
default = "us-east-1" | ||
description = "AWS region" | ||
} | ||
|
||
variable "cluster_name" { | ||
type = string | ||
default = "cluster" | ||
description = "EKS cluster name" | ||
} | ||
|
||
variable "route53_hosted_zones" { | ||
type = string | ||
default = "*" | ||
description = "The hosted zone permissions granted to: arn:aws:route53:::hostedzone/<route53_hosted_zones ID" | ||
} | ||
|
||
variable "ingress_class" { | ||
type = string | ||
default = "nginx-external" | ||
description = "The ingress class that will be used for the http01 resolver to put the inbound check onto" | ||
} | ||
|
||
variable "enable_http01_cluster_issuer" { | ||
type = number | ||
default = 1 | ||
description = "Enable an http01 cluster issuer" | ||
} | ||
|
||
variable "enable_dns01_cluster_issuer" { | ||
type = number | ||
default = 1 | ||
description = "Enable an dns01 cluster issuer" | ||
} | ||
|
||
variable "lets_encrypt_server" { | ||
type = string | ||
default = "https://acme-v02.api.letsencrypt.org/directory" | ||
description = "The Lets Encrypt validation server to go to. The default is the live one." | ||
} | ||
|
||
variable "lets_encrypt_email" { | ||
type = string | ||
default = "" | ||
description = "An email address for cert administration purposes" | ||
} | ||
|
||
variable "domain_name" { | ||
type = string | ||
default = "example.com" | ||
description = "The domain name for DNS01 to resolve for" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters