Skip to content

Commit bda75cb

Browse files
committed
feat: First code for module
1 parent 64ed197 commit bda75cb

File tree

6 files changed

+223
-2
lines changed

6 files changed

+223
-2
lines changed

.terraform-docs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
formatter: markdown document
2+
output:
3+
file: "README.md"
4+
settings:
5+
anchor: false

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 DO! DevOps
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,118 @@
1-
# terraform-azure-certmanager
2-
Highly opinionated Terraform management of cert manager on Azure Kubernetes Service (AKS)
1+
# Terraform managemen of cert-manager on AKS
2+
3+
## Introduction
4+
5+
This module manages cert-manager on AKS (Azure Kubernetes Service)
6+
7+
## K8S requirements
8+
9+
This module requires Kubernetes >= 1.19, see https://cert-manager.io/docs/installation/helm/#option-2-install-crds-as-part-of-the-helm-release
10+
11+
## Usage
12+
13+
Instantiate the module by calling it from Terraform like this:
14+
15+
```hcl
16+
module "azure-basics" {
17+
source = "dodevops/certmanager/azure"
18+
version = "<version>"
19+
}
20+
```
21+
22+
23+
<!-- BEGIN_TF_DOCS -->
24+
## Requirements
25+
26+
No requirements.
27+
28+
## Providers
29+
30+
The following providers are used by this module:
31+
32+
- azurerm
33+
34+
## Modules
35+
36+
No modules.
37+
38+
## Resources
39+
40+
The following resources are used by this module:
41+
42+
- [azurerm_management_lock.resource-group-level](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
43+
- [azurerm_proximity_placement_group.ppg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/proximity_placement_group) (resource)
44+
- [azurerm_resource_group.azure-resource-group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
45+
46+
## Required Inputs
47+
48+
The following input variables are required:
49+
50+
### location
51+
52+
Description: The azure location used for azure
53+
54+
Type: `string`
55+
56+
### project
57+
58+
Description: Three letter project key
59+
60+
Type: `string`
61+
62+
### stage
63+
64+
Description: Stage for this ressource group
65+
66+
Type: `string`
67+
68+
## Optional Inputs
69+
70+
The following input variables are optional (have default values):
71+
72+
### lock
73+
74+
Description: Lock ressource group for deletion
75+
76+
Type: `bool`
77+
78+
Default: `true`
79+
80+
### manage\_proximity\_placement\_group
81+
82+
Description: Manage a proximity placement group for the resource group
83+
84+
Type: `bool`
85+
86+
Default: `true`
87+
88+
### tags
89+
90+
Description: Map of tags for the resources
91+
92+
Type: `map(any)`
93+
94+
Default: `{}`
95+
96+
## Outputs
97+
98+
The following outputs are exported:
99+
100+
### location
101+
102+
Description: The location input variable (can be used for dependency resolution)
103+
104+
### ppg\_id
105+
106+
Description: The ID of the generated proximity placement group
107+
108+
### resource\_group
109+
110+
Description: The name of the generated resource group
111+
<!-- END_TF_DOCS -->
112+
113+
## Development
114+
115+
Use [terraform-docs](https://terraform-docs.io/) to generate the API documentation by running
116+
117+
terraform fmt .
118+
terraform-docs .

main.tf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Installs and configures cert-manager
2+
3+
resource "kubernetes_namespace" "cert-manager" {
4+
metadata {
5+
name = "cert-manager"
6+
}
7+
}
8+
9+
# documentation: https://cert-manager.io/docs/installation/helm/
10+
resource "helm_release" "cert-manager" {
11+
name = "cert-manager"
12+
repository = "https://charts.jetstack.io"
13+
chart = "cert-manager"
14+
version = "v1.5.4"
15+
namespace = kubernetes_namespace.cert-manager.metadata.0.name
16+
17+
set {
18+
name = "installCRDs"
19+
value = "true"
20+
}
21+
}
22+
23+
resource "helm_release" "cert-manager-clusterissuer" {
24+
name = "cert-manager-clusterissuer"
25+
chart = "../helm-charts/cert-manager-cluster-issuer"
26+
27+
set {
28+
name = "letsencryptEmail"
29+
value = var.email
30+
}
31+
32+
depends_on = [
33+
helm_release.cert-manager,
34+
]
35+
}
36+
37+
# TODO: to replaced by helm chart
38+
//
39+
//resource "kubernetes_manifest" "cluster-issuer-prod" {
40+
// manifest = {
41+
// apiVersion = "cert-manager.io/v1alpha2" # TODO, still correct?
42+
// kind = "ClusterIssuer"
43+
// metadata = {
44+
// name = "letsencrypt-prod"
45+
// }
46+
// }
47+
//}
48+
//
49+
//apiVersion: cert-manager.io/v1alpha2
50+
//kind: ClusterIssuer
51+
//metadata:
52+
// name: letsencrypt-prod
53+
//spec:
54+
// acme:
55+
// # The ACME server URL
56+
// server: https://acme-v02.api.letsencrypt.org/directory
57+
// # Email address used for ACME registration
58+
// email: {{ .Values.letsencryptEmail }}
59+
// # Name of a secret used to store the ACME account private key
60+
// privateKeySecretRef:
61+
// name: letsencrypt-prod
62+
// # Enable the HTTP-01 challenge provider
63+
// solvers:
64+
// - http01:
65+
// ingress:
66+
// class: nginx

terraform.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# setting required because we need helm >= 3.3, see https://cert-manager.io/docs/installation/helm/#option-2-install-crds-as-part-of-the-helm-release
2+
terraform {
3+
required_providers {
4+
helm = {
5+
source = "hashicorp/helm"
6+
version = ">= 1.3.1"
7+
}
8+
}
9+
}

vars.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable "email" {
2+
type = string
3+
description = "Notification-Address"
4+
}

0 commit comments

Comments
 (0)