Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

Commit 048b421

Browse files
committed
gitops-bridge metadata as module
Signed-off-by: Carlos Santana <[email protected]>
1 parent e3695bf commit 048b421

File tree

7 files changed

+203
-0
lines changed

7 files changed

+203
-0
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
local/
2+
build/
3+
plan.out
4+
plan.out.json
5+
6+
# Local .terraform directories
7+
.terraform/
8+
9+
# .tfstate files
10+
*.tfstate
11+
*.tfstate.*
12+
13+
# Crash log files
14+
crash.log
15+
16+
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
17+
# password, private keys, and other secrets. These should not be part of version
18+
# control as they are data points which are potentially sensitive and subject
19+
# to change depending on the environment.
20+
#
21+
*.tfvars
22+
23+
# Ignore override files as they are usually used to override resources locally and so
24+
# are not checked in
25+
override.tf
26+
override.tf.json
27+
*_override.tf
28+
*_override.tf.json
29+
30+
# Include override files you do wish to add to version control using negated pattern
31+
#
32+
# !example_override.tf
33+
34+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
35+
# example: *tfplan*
36+
37+
# Ignore CLI configuration files
38+
.terraformrc
39+
terraform.rc
40+
.terraform.lock.hcl
41+
42+
go.mod
43+
go.sum
44+
45+
.DS_Store

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
args: ['--markdown-linebreak-ext=md']
7+
- id: end-of-file-fixer
8+
- id: check-merge-conflict
9+
- id: detect-private-key
10+
- repo: https://github.com/antonbabenko/pre-commit-terraform
11+
rev: v1.77.1
12+
hooks:
13+
- id: terraform_fmt
14+
- id: terraform_docs
15+
args:
16+
- '--args=--lockfile=false'
17+
- id: terraform_tflint
18+
args:
19+
- '--args=--only=terraform_deprecated_interpolation'
20+
- '--args=--only=terraform_deprecated_index'
21+
- '--args=--only=terraform_unused_declarations'
22+
- '--args=--only=terraform_comment_syntax'
23+
- '--args=--only=terraform_documented_outputs'
24+
- '--args=--only=terraform_documented_variables'
25+
- '--args=--only=terraform_typed_variables'
26+
- '--args=--only=terraform_module_pinned_source'
27+
- '--args=--only=terraform_naming_convention'
28+
- '--args=--only=terraform_required_version'
29+
- '--args=--only=terraform_required_providers'
30+
- '--args=--only=terraform_standard_module_structure'
31+
- '--args=--only=terraform_workspace_remote'
32+
- '--args=--only=terraform_empty_list_equality'
33+
- '--args=--only=terraform_unused_required_providers'
34+
- id: terraform_validate
35+

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
11
# gitops-bridge-argocd-metadata-terraform
22
Terraform module for gitops-bridge argocd metadata
3+
4+
It generates the argocd cluster secret that contains the metadata for argocd application sets
5+
6+
To be use with [gitops-bridge](https://github.com/gitops-bridge-dev/) project, see example [here](https://github.com/gitops-bridge-dev/gitops-bridge/blob/main/argocd/iac/terraform/examples/eks/hello-world/main.tf)
7+
8+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9+
## Requirements
10+
11+
| Name | Version |
12+
|------|---------|
13+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
14+
15+
## Providers
16+
17+
No providers.
18+
19+
## Modules
20+
21+
No modules.
22+
23+
## Resources
24+
25+
No resources.
26+
27+
## Inputs
28+
29+
| Name | Description | Type | Default | Required |
30+
|------|-------------|------|---------|:--------:|
31+
| <a name="input_addons"></a> [addons](#input\_addons) | ArgoCD cluster additional addons labels to be extracted by application sets | `map(string)` | `{}` | no |
32+
| <a name="input_argocd"></a> [argocd](#input\_argocd) | Overrides for ArgoCD cluster secret like name, namespace, data server, data config, take a look at main.tf | `map(string)` | `{}` | no |
33+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | ArgoCD cluster name | `string` | `"in-cluster"` | no |
34+
| <a name="input_environment"></a> [environment](#input\_environment) | ArgoCD cluster label environment | `string` | `"dev"` | no |
35+
| <a name="input_metadata"></a> [metadata](#input\_metadata) | ArgoCD cluster additional metadata annotations to be extracted by application sets | `map(string)` | `{}` | no |
36+
37+
## Outputs
38+
39+
| Name | Description |
40+
|------|-------------|
41+
| <a name="output_argocd"></a> [argocd](#output\_argocd) | Argocd cluster secret |
42+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

main.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
locals {
3+
4+
argocd_labels = merge({
5+
cluster_name = var.cluster_name
6+
environment = var.environment
7+
enable_argocd = true
8+
"argocd.argoproj.io/secret-type" = "cluster"
9+
},
10+
var.addons
11+
)
12+
argocd_annotations = merge(
13+
{
14+
cluster_name = var.cluster_name
15+
environment = var.environment
16+
},
17+
var.metadata
18+
)
19+
}
20+
21+
locals {
22+
argocd_server_config = <<-EOT
23+
{
24+
"tlsClientConfig": {
25+
"insecure": false
26+
}
27+
}
28+
EOT
29+
argocd = {
30+
apiVersion = "v1"
31+
kind = "Secret"
32+
metadata = {
33+
name = try(var.argocd.secret_name, var.cluster_name)
34+
namespace = try(var.argocd.secret_namespace, "argocd")
35+
annotations = local.argocd_annotations
36+
labels = local.argocd_labels
37+
}
38+
stringData = {
39+
name = var.cluster_name
40+
server = try(var.argocd.server, "https://kubernetes.default.svc")
41+
config = try(var.argocd.argocd_server_config, local.argocd_server_config)
42+
}
43+
}
44+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "argocd" {
2+
description = "Argocd cluster secret"
3+
value = local.argocd
4+
}

variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
variable "cluster_name" {
2+
description = "ArgoCD cluster name"
3+
type = string
4+
default = "in-cluster"
5+
}
6+
variable "environment" {
7+
description = "ArgoCD cluster label environment"
8+
type = string
9+
default = "dev"
10+
}
11+
variable "metadata" {
12+
description = "ArgoCD cluster additional metadata annotations to be extracted by application sets"
13+
type = map(string)
14+
default = {}
15+
}
16+
variable "addons" {
17+
description = "ArgoCD cluster additional addons labels to be extracted by application sets"
18+
type = map(string)
19+
default = {}
20+
}
21+
variable "argocd" {
22+
description = "Overrides for ArgoCD cluster secret like name, namespace, data server, data config, take a look at main.tf"
23+
type = map(string)
24+
default = {}
25+
}

versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
# ## Used for end-to-end testing on project; update to suit your needs
5+
# backend "s3" {
6+
# bucket = "terraform-ssp-github-actions-state"
7+
# region = "us-west-2"
8+
# key = "e2e/ipv4-prefix-delegation/terraform.tfstate"
9+
# }
10+
}

0 commit comments

Comments
 (0)