Skip to content

Commit 9da523a

Browse files
authored
Merge pull request #4 from lablabs/add_argocd_support
Add argocd support
2 parents 59baa99 + 9a2071a commit 9da523a

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ No modules.
5454
| [aws_iam_role_policy_attachment.cert_manager](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
5555
| [helm_release.cert_manager](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
5656
| [helm_release.default_cluster_issuer](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
57+
| [kubernetes_manifest.this](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
5758
| [time_sleep.default_cluster_issuer](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
5859
| [aws_iam_policy_document.cert_manager](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5960
| [aws_iam_policy_document.cert_manager_assume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
@@ -69,6 +70,12 @@ No modules.
6970
| <a name="input_cluster_identity_oidc_issuer"></a> [cluster\_identity\_oidc\_issuer](#input\_cluster\_identity\_oidc\_issuer) | The OIDC Identity issuer for the cluster | `string` | n/a | yes |
7071
| <a name="input_cluster_identity_oidc_issuer_arn"></a> [cluster\_identity\_oidc\_issuer\_arn](#input\_cluster\_identity\_oidc\_issuer\_arn) | The OIDC Identity issuer ARN for the cluster that can be used to associate IAM roles with a service account | `string` | n/a | yes |
7172
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the cluster | `string` | n/a | yes |
73+
| <a name="input_argo_application_enabled"></a> [argo\_application\_enabled](#input\_argo\_application\_enabled) | If set to true, the module will be deployed as ArgoCD application, otherwise it will be deployed as a Helm release | `bool` | `false` | no |
74+
| <a name="input_argo_destionation_server"></a> [argo\_destionation\_server](#input\_argo\_destionation\_server) | Destination server for ArgoCD Application | `string` | `"https://kubernetes.default.svc"` | no |
75+
| <a name="input_argo_info"></a> [argo\_info](#input\_argo\_info) | ArgoCD info manifest parameter | `list` | <pre>[<br> {<br> "name": "terraform",<br> "value": "true"<br> }<br>]</pre> | no |
76+
| <a name="input_argo_namespace"></a> [argo\_namespace](#input\_argo\_namespace) | Namespace to deploy ArgoCD application CRD to | `string` | `"argo"` | no |
77+
| <a name="input_argo_project"></a> [argo\_project](#input\_argo\_project) | ArgoCD Application project | `string` | `"default"` | no |
78+
| <a name="input_argo_sync_policy"></a> [argo\_sync\_policy](#input\_argo\_sync\_policy) | ArgoCD syncPolicy manifest parameter | `map` | `{}` | no |
7279
| <a name="input_cluster_issuer_enabled"></a> [cluster\_issuer\_enabled](#input\_cluster\_issuer\_enabled) | Variable indicating whether default ClusterIssuer CRD is enabled | `bool` | `false` | no |
7380
| <a name="input_cluster_issuer_settings"></a> [cluster\_issuer\_settings](#input\_cluster\_issuer\_settings) | Additional settings which will be passed to the Helm chart cluster\_issuer values, see https://github.com/lablabs/terraform-aws-eks-aws-cert-manager/blob/master/helm/defaultClusterIssuer/values.yaml | `map(any)` | `{}` | no |
7481
| <a name="input_cluster_issuers_values"></a> [cluster\_issuers\_values](#input\_cluster\_issuers\_values) | Additional values for cert manager cluster issuers helm chart. Values will be merged, in order, as Helm does with multiple -f options | `string` | `""` | no |

argo.tf

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
resource "kubernetes_manifest" "this" {
2+
count = var.argo_application_enabled ? 1 : 0
3+
manifest = {
4+
"apiVersion" = "argoproj.io/v1alpha1"
5+
"kind" = "Application"
6+
"metadata" = {
7+
"name" = var.helm_release_name
8+
"namespace" = var.argo_namespace
9+
}
10+
"spec" = {
11+
"project" = var.argo_project
12+
"source" = {
13+
"repoURL" = var.helm_repo_url
14+
"chart" = var.helm_chart_name
15+
"targetRevision" = var.helm_chart_version
16+
"helm" = {
17+
"releaseName" = var.helm_release_name
18+
"parameters" = [for k, v in var.settings : tomap({ "forceString" : true, "name" : k, "value" : v })]
19+
"values" = data.utils_deep_merge_yaml.values[0].output
20+
}
21+
}
22+
"destination" = {
23+
"server" = var.argo_destionation_server
24+
"namespace" = var.k8s_namespace
25+
}
26+
"syncPolicy" = var.argo_sync_policy
27+
"info" = var.argo_info
28+
}
29+
}
30+
}

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ data "utils_deep_merge_yaml" "default_cluster_issuer_values" {
5151

5252

5353
resource "helm_release" "cert_manager" {
54-
count = var.enabled ? 1 : 0
54+
count = var.enabled && !var.argo_application_enabled ? 1 : 0
5555

5656
chart = var.helm_chart_name
5757
create_namespace = var.helm_create_namespace

variables.tf

+38
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,41 @@ variable "policy_allowed_zone_ids" {
119119
default = ["*"]
120120
description = "List of the Route53 zone ids for service account IAM role access"
121121
}
122+
123+
variable "argo_namespace" {
124+
type = string
125+
default = "argo"
126+
description = "Namespace to deploy ArgoCD application CRD to"
127+
}
128+
129+
130+
variable "argo_application_enabled" {
131+
type = bool
132+
default = false
133+
description = "If set to true, the module will be deployed as ArgoCD application, otherwise it will be deployed as a Helm release"
134+
}
135+
136+
variable "argo_destionation_server" {
137+
type = string
138+
default = "https://kubernetes.default.svc"
139+
description = "Destination server for ArgoCD Application"
140+
}
141+
142+
variable "argo_project" {
143+
type = string
144+
default = "default"
145+
description = "ArgoCD Application project"
146+
}
147+
148+
variable "argo_info" {
149+
default = [{
150+
"name" = "terraform"
151+
"value" = "true"
152+
}]
153+
description = "ArgoCD info manifest parameter"
154+
}
155+
156+
variable "argo_sync_policy" {
157+
description = "ArgoCD syncPolicy manifest parameter"
158+
default = {}
159+
}

0 commit comments

Comments
 (0)