Skip to content

Commit 2dbc4bf

Browse files
committed
update secret manager example
Signed-off-by: Carlos Santana <csantana23@gmail.com>
1 parent b633c87 commit 2dbc4bf

File tree

5 files changed

+64
-37
lines changed

5 files changed

+64
-37
lines changed

argocd/iac/terraform/examples/eks/aws-secrets-manager/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ terraform init
99
terraform apply
1010
```
1111

12-
Access Terraform output to configure `kubectl` and `argocd`
12+
Access Terraform output to configure `kubectl` and `argocd` (it includes argocd password)
1313
```shell
1414
terraform output
1515
```
1616

17+
To get the argocd `admin` password stored in AWS Secret Manager
18+
```shell
19+
aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString
20+
```
21+
1722
Destroy EKS Cluster
1823
```shell
1924
cd hub
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1+
---
12
apiVersion: argoproj.io/v1alpha1
2-
kind: Application
3+
kind: ApplicationSet
34
metadata:
45
name: bootstrap-addons
5-
namespace: 'argocd'
6+
namespace: argocd
67
spec:
7-
destination:
8-
server: https://kubernetes.default.svc
9-
namespace: 'argocd'
10-
project: default
11-
source:
12-
path: ${path}
13-
repoURL: ${repoURL}
14-
targetRevision: ${targetRevision}
15-
directory:
16-
recurse: true
17-
exclude: exclude/*
188
syncPolicy:
19-
automated: {}
9+
preserveResourcesOnDeletion: true
10+
generators:
11+
- clusters:
12+
selector:
13+
matchExpressions:
14+
- key: akuity.io/argo-cd-cluster-name
15+
operator: NotIn
16+
values: [in-cluster]
17+
template:
18+
metadata:
19+
name: 'bootstrap-addons'
20+
spec:
21+
project: default
22+
source:
23+
repoURL: '{{metadata.annotations.addons_repo_url}}'
24+
path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
25+
targetRevision: '{{metadata.annotations.addons_repo_revision}}'
26+
directory:
27+
recurse: true
28+
exclude: exclude/*
29+
destination:
30+
namespace: 'argocd'
31+
name: '{{name}}'
32+
syncPolicy:
33+
automated: {}

argocd/iac/terraform/examples/eks/aws-secrets-manager/main.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ provider "kubernetes" {
4545
}
4646

4747
locals {
48-
name = "ex-${replace(basename(path.cwd), "_", "-")}"
49-
environment = "dev"
50-
region = "us-west-2"
51-
cluster_version = "1.27"
52-
gitops_url = var.gitops_url
53-
gitops_revision = var.gitops_revision
54-
gitops_path = var.gitops_path
48+
name = "ex-${replace(basename(path.cwd), "_", "-")}"
49+
environment = "dev"
50+
region = "us-west-2"
51+
cluster_version = "1.27"
52+
gitops_addons_url = "${var.gitops_addons_org}/${var.gitops_addons_repo}"
53+
gitops_addons_basepath = var.gitops_addons_basepath
54+
gitops_addons_path = var.gitops_addons_path
55+
gitops_addons_revision = var.gitops_addons_revision
56+
5557

5658
aws_addons = {
5759
enable_cert_manager = true
@@ -98,17 +100,15 @@ locals {
98100
aws_vpc_id = module.vpc.vpc_id
99101
},
100102
{
101-
gitops_bridge_repo_url = local.gitops_url
102-
gitops_bridge_repo_revision = local.gitops_revision
103+
addons_repo_url = local.gitops_addons_url
104+
addons_repo_basepath = local.gitops_addons_basepath
105+
addons_repo_path = local.gitops_addons_path
106+
addons_repo_revision = local.gitops_addons_revision
103107
}
104108
)
105109

106110
argocd_bootstrap_app_of_apps = {
107-
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
108-
repoURL = local.gitops_url
109-
targetRevision = local.gitops_revision
110-
path = local.gitops_path
111-
})
111+
addons = file("${path.module}/bootstrap/addons.yaml")
112112
workloads = file("${path.module}/bootstrap/workloads.yaml")
113113
}
114114

argocd/iac/terraform/examples/eks/aws-secrets-manager/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ output "configure_argocd" {
1313
aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_name}
1414
export ARGOCD_OPTS="--port-forward --port-forward-namespace argocd --grpc-web"
1515
kubectl config set-context --current --namespace argocd
16-
argocd login --port-forward --username admin --password $(argocd admin initial-password | head -1)
16+
argocd login --port-forward --username admin --password $(aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString)
1717
echo "ArgoCD Username: admin"
18-
echo "ArgoCD Password: $(kubectl get secrets argocd-initial-admin-secret -n argocd --template="{{index .data.password | base64decode}}")"
18+
echo "ArgoCD Password: $(aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString)"
1919
echo Port Forward: http://localhost:8080
2020
kubectl port-forward -n argocd svc/argo-cd-argocd-server 8080:80
2121
EOT
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
variable "gitops_url" {
1+
variable "gitops_addons_org" {
2+
description = "Git repository org/user contains for addons"
3+
default = "https://github.com/gitops-bridge-dev"
4+
}
5+
variable "gitops_addons_repo" {
26
description = "Git repository contains for addons"
3-
default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template"
7+
default = "gitops-bridge-argocd-control-plane-template"
48
}
5-
variable "gitops_revision" {
6-
description = "Git repository revision/branch/ref for addons"
7-
default = "HEAD"
9+
variable "gitops_addons_basepath" {
10+
description = "Git repository base path for addons"
11+
default = ""
812
}
9-
variable "gitops_path" {
13+
variable "gitops_addons_path" {
1014
description = "Git repository path for addons"
1115
default = "bootstrap/control-plane/addons"
1216
}
17+
variable "gitops_addons_revision" {
18+
description = "Git repository revision/branch/ref for addons"
19+
default = "HEAD"
20+
}

0 commit comments

Comments
 (0)