Skip to content

Commit

Permalink
github repo config updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sfdevops committed Aug 23, 2024
1 parent cb41ca6 commit 2c439cf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
4 changes: 4 additions & 0 deletions files/tenant-samples/silo/terraform/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ data "aws_ssm_parameter" "github_user" {
name = "/github_user"
}

data "aws_ssm_parameter" "github_repo" {
name = "/github_saas_repo"
}

data "aws_caller_identity" "current" {}

data "aws_eks_cluster" "EKScluster" {
Expand Down
4 changes: 2 additions & 2 deletions files/tenant-samples/silo/terraform/eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ spec:
server: 'https://kubernetes.default.svc'
source:
path: onboarded-tenants/silo/application
repoURL: 'https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_user.value}/${var.namespace}-saas-management-repository.git'
repoURL: 'https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_repo.value}.git'
targetRevision: main
helm:
valueFiles:
Expand Down Expand Up @@ -213,7 +213,7 @@ spec:
- name: terraform
path: /home/terraform
git:
repo: https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_user.value}/${var.namespace}-saas-management-repository.git
repo: https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_repo.value}.git
depth: 1
usernameSecret:
name: github-secret
Expand Down
9 changes: 8 additions & 1 deletion files/tenant-samples/silo/terraform/push-values.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ if [ -z "$GITHUB_TOKEN" ]; then
exit 1
fi

# Retrieve GitHub Repo from SSM Parameter Store
GITHUB_REPO=$(aws ssm get-parameter --name "/github_saas_repo" --with-decryption --region "${AWS_REGION}" --query "Parameter.Value" --output text)
if [ -z "$GITHUB_REPO" ]; then
echo "Failed to retrieve GitHub repo from SSM Parameter Store"
exit 1
fi

# Construct the GitHub repository URL
GITHUB_REPO_URL="https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_USERNAME}/${NAMESPACE}-saas-management-repository.git"
GITHUB_REPO_URL="https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_REPO}.git"

# Check if the directory already exists and remove it if necessary
if [ -d "${NAMESPACE}-saas-management-repository" ]; then
Expand Down
4 changes: 4 additions & 0 deletions terraform/control-plane-application/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ data "aws_ssm_parameter" "github_user" {
name = "/github_user"
}

data "aws_ssm_parameter" "github_repo" {
name = "/github_saas_repo"
}

############################################################################
## EKS data
############################################################################
Expand Down
4 changes: 2 additions & 2 deletions terraform/control-plane-application/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ resource "kubectl_manifest" "argocd_reposiotry_secret" {
labels:
argocd.argoproj.io/secret-type: repository
stringData:
url: https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_user.value}/${var.namespace}-saas-management-repository.git
url: https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_repo.value}.git
password: ${data.aws_ssm_parameter.github_token.value}
username: ${data.aws_ssm_parameter.github_user.value}
insecure: "true" # Ignore validity of server's TLS certificate. Defaults to "false"
Expand Down Expand Up @@ -309,7 +309,7 @@ resource "kubectl_manifest" "argo_workflow_repository_secret" {
labels:
argocd.argoproj.io/secret-type: repository
stringData:
url: https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_user.value}/${var.namespace}-saas-management-repository.git
url: https://${data.aws_ssm_parameter.github_user.value}@github.com/${data.aws_ssm_parameter.github_repo.value}.git
password: ${data.aws_ssm_parameter.github_token.value}
username: ${data.aws_ssm_parameter.github_user.value}
insecure: "true" # Ignore validity of server's TLS certificate. Defaults to "false"
Expand Down
9 changes: 8 additions & 1 deletion terraform/tenant-codebuilds/saas-repo-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ if [ -z "$GITHUB_TOKEN" ]; then
exit 1
fi

# Retrieve GitHub Repo from SSM Parameter Store
GITHUB_REPO=$(aws ssm get-parameter --name "/github_saas_repo" --with-decryption --region "${AWS_REGION}" --query "Parameter.Value" --output text)
if [ -z "$GITHUB_REPO" ]; then
echo "Failed to retrieve GitHub repo from SSM Parameter Store"
exit 1
fi

# Construct the GitHub repository URL
GITHUB_REPO_URL="https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_USERNAME}/${NAMESPACE}-saas-management-repository.git"
GITHUB_REPO_URL="https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_REPO}.git"

# Change directory
cd ../../files/ || { echo "Failed to change directory"; exit 1; }
Expand Down

0 comments on commit 2c439cf

Please sign in to comment.