Skip to content

Commit 73b419d

Browse files
committed
update ssh git example
Signed-off-by: Carlos Santana <csantana23@gmail.com>
1 parent 39fa6a1 commit 73b419d

File tree

5 files changed

+31
-48
lines changed

5 files changed

+31
-48
lines changed

argocd/iac/terraform/examples/eks/external-secrets/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
This example shows how to deploy Amazon EKS with addons configured via ArgoCD
44

5-
The example demonstrate how to use private git repository for workload apps
5+
The example demonstrate how to use private git repository for workload apps.
66

7-
Create an AWS Secret Manager secret with name `github-ssh-key` and the content in plain text of git private ssh key
7+
The example stores your ssh key in AWS Secret Manager, and External Secret Operator to create the secret
8+
for ArgoCD to access the git repositories.
9+
10+
## Prerequisites
11+
- Create a Github ssh key file, example assumes the file path `~/.ssh/id_rsa`, update `main.tf` if using a different location
812

913
Deploy EKS Cluster
1014
```shell
@@ -17,9 +21,16 @@ Access Terraform output to configure `kubectl` and `argocd`
1721
terraform output
1822
```
1923

20-
After cluster is deploy use the external secret operator to create the ArgoCD secret for git ssh access
24+
There is a file `github.yaml` located in the addons git repository `clusters/ex-external-secrets/secret/` this file creates the resources `ClusterSecretStore` and `ExternalSecret`. Update the git `url` this file when you change the git repository for the workloads specified in `bootstrap/workloads.yaml`
25+
26+
To verify that the ArgoCD secret with ssh key is created run the following command
2127
```shell
22-
kubectl apply -f secrets/github.yaml
28+
kubectl get secret private-repo-creds -n argocd
29+
```
30+
Expected output, should have 3 data items in secret
31+
```
32+
NAME TYPE DATA AGE
33+
private-repo-creds Opaque 3 6m45s
2334
```
2435

2536
Destroy EKS Cluster

argocd/iac/terraform/examples/eks/external-secrets/bootstrap/addons.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spec:
99
namespace: 'argocd'
1010
project: default
1111
source:
12-
path: bootstrap/control-plane/addons
12+
path: bootstrap/control-plane
1313
repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template
1414
targetRevision: HEAD
1515
directory:

argocd/iac/terraform/examples/eks/external-secrets/bootstrap/workloads.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ apiVersion: argoproj.io/v1alpha1
22
kind: Application
33
metadata:
44
name: bootstrap-workloads
5-
namespace: argocd
5+
namespace: 'argocd'
66
finalizers:
77
- resources-finalizer.argocd.argoproj.io
88
spec:
99
destination:
10-
namespace: default
1110
server: https://kubernetes.default.svc
11+
namespace: 'guestbook'
1212
project: default
1313
source:
14-
path: envs/dev
15-
repoURL: git@github.com:aws-samples/eks-blueprints-workloads.git
14+
path: helm-guestbook
15+
repoURL: git@github.com:argoproj/argocd-example-apps.git
1616
targetRevision: HEAD
1717
syncPolicy:
18+
automated: {}
1819
syncOptions:
1920
- CreateNamespace=true

argocd/iac/terraform/examples/eks/external-secrets/main.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ locals {
4848
region = "us-west-2"
4949
cluster_version = "1.27"
5050

51-
aws_secret_manager_secret_name = "github-ssh-key"
51+
aws_secret_manager_secret_name = "argocd-ssh-key"
52+
git_private_ssh_key = "~/.ssh/id_rsa" # Update with the git ssh key to be used by ArgoCD
5253

5354
aws_addons = {
5455
enable_cert_manager = true
@@ -135,8 +136,14 @@ module "gitops_bridge_bootstrap" {
135136
################################################################################
136137
# AWS Secret Manager
137138
################################################################################
138-
data "aws_secretsmanager_secret" "git_ssh_key" {
139-
name = local.aws_secret_manager_secret_name
139+
#tfsec:ignore:aws-ssm-secret-use-customer-key
140+
resource "aws_secretsmanager_secret" "git_ssh_key" {
141+
name = local.aws_secret_manager_secret_name
142+
recovery_window_in_days = 0 # Set to zero for this example to force delete during Terraform destroy
143+
}
144+
resource "aws_secretsmanager_secret_version" "git_ssh_key" {
145+
secret_id = aws_secretsmanager_secret.git_ssh_key.id
146+
secret_string = file(pathexpand(local.git_private_ssh_key))
140147
}
141148

142149

argocd/iac/terraform/examples/eks/external-secrets/secrets/github.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)