Skip to content

Commit a2a1f7d

Browse files
authored
Merge pull request #103 from aws-samples/feat/tracking
feat: Adding Tracking Stack
2 parents 1ef19b4 + 250acd5 commit a2a1f7d

12 files changed

Lines changed: 103 additions & 17 deletions

File tree

gitops/control-plane/production/workflows/tenant-deployment-workflow-template.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ spec:
1313
container:
1414
image: "${ecr_argoworkflow_container}:0.1"
1515
command: ["/bin/sh","-c"]
16-
args: ['./01-tenant-clone-repo.sh {{workflow.parameters.REPO_URL}} {{workflow.parameters.GIT_BRANCH}} {{workflow.parameters.GIT_USERNAME}} {{workflow.parameters.GIT_TOKEN}} && cp -r eks-saas-gitops /mnt/vol/eks-saas-gitops']
16+
args: ['./01-tenant-clone-repo.sh "$REPO_URL" "$GIT_BRANCH" "$GIT_USERNAME" "$GIT_TOKEN" && cp -r eks-saas-gitops /mnt/vol/eks-saas-gitops']
1717
volumeMounts:
1818
- name: workdir
1919
mountPath: /mnt/vol
2020
env:
21+
- name: REPO_URL
22+
value: "{{workflow.parameters.REPO_URL}}"
23+
- name: GIT_BRANCH
24+
value: "{{workflow.parameters.GIT_BRANCH}}"
2125
- name: GIT_USERNAME
2226
value: "{{workflow.parameters.GIT_USERNAME}}"
2327
- name: GIT_TOKEN
@@ -26,13 +30,21 @@ spec:
2630
container:
2731
image: "${ecr_argoworkflow_container}:0.1"
2832
command: ["/bin/sh","-c"]
29-
args: ['./03-tenant-deployment.sh {{workflow.parameters.RELEASE_VERSION}} {{workflow.parameters.TENANT_TIER}} {{workflow.parameters.GIT_USER_EMAIL}} {{workflow.parameters.GIT_USERNAME}} {{workflow.parameters.GIT_BRANCH}} {{workflow.parameters.GIT_TOKEN}}']
33+
args: ['./03-tenant-deployment.sh "$RELEASE_VERSION" "$TENANT_TIER" "$GIT_USER_EMAIL" "$GIT_USERNAME" "$GIT_BRANCH" "$GIT_TOKEN"']
3034
volumeMounts:
3135
- name: workdir
3236
mountPath: /mnt/vol
3337
env:
38+
- name: RELEASE_VERSION
39+
value: "{{workflow.parameters.RELEASE_VERSION}}"
40+
- name: TENANT_TIER
41+
value: "{{workflow.parameters.TENANT_TIER}}"
42+
- name: GIT_USER_EMAIL
43+
value: "{{workflow.parameters.GIT_USER_EMAIL}}"
3444
- name: GIT_USERNAME
3545
value: "{{workflow.parameters.GIT_USERNAME}}"
46+
- name: GIT_BRANCH
47+
value: "{{workflow.parameters.GIT_BRANCH}}"
3648
- name: GIT_TOKEN
3749
value: "{{workflow.parameters.GIT_TOKEN}}"
3850
volumeClaimTemplates:

gitops/control-plane/production/workflows/tenant-offboarding-workflow-template.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ spec:
1010
container:
1111
image: "${ecr_argoworkflow_container}:0.1"
1212
command: ["/bin/sh","-c"]
13-
args: ['./00-validate-tenant.sh {{workflow.parameters.TENANT_ID}}']
13+
args: ['./00-validate-tenant.sh "$TENANT_ID"']
1414
volumeMounts:
1515
- name: workdir
1616
mountPath: /mnt/vol
1717
env:
18+
- name: TENANT_ID
19+
value: "{{workflow.parameters.TENANT_ID}}"
1820
- name: GIT_USERNAME
1921
value: "{{workflow.parameters.GIT_USERNAME}}"
2022
- name: GIT_TOKEN
@@ -23,11 +25,15 @@ spec:
2325
container:
2426
image: "${ecr_argoworkflow_container}:0.1"
2527
command: ["/bin/sh","-c"]
26-
args: ['./01-tenant-clone-repo.sh {{workflow.parameters.REPO_URL}} {{workflow.parameters.GIT_BRANCH}} {{workflow.parameters.GIT_USERNAME}} {{workflow.parameters.GIT_TOKEN}} && cp -r eks-saas-gitops /mnt/vol/eks-saas-gitops']
28+
args: ['./01-tenant-clone-repo.sh "$REPO_URL" "$GIT_BRANCH" "$GIT_USERNAME" "$GIT_TOKEN" && cp -r eks-saas-gitops /mnt/vol/eks-saas-gitops']
2729
volumeMounts:
2830
- name: workdir
2931
mountPath: /mnt/vol
3032
env:
33+
- name: REPO_URL
34+
value: "{{workflow.parameters.REPO_URL}}"
35+
- name: GIT_BRANCH
36+
value: "{{workflow.parameters.GIT_BRANCH}}"
3137
- name: GIT_USERNAME
3238
value: "{{workflow.parameters.GIT_USERNAME}}"
3339
- name: GIT_TOKEN
@@ -36,13 +42,21 @@ spec:
3642
container:
3743
image: "${ecr_argoworkflow_container}:0.1"
3844
command: ["/bin/sh","-c"]
39-
args: ['./04-tenant-offboarding.sh {{workflow.parameters.TENANT_ID}} {{workflow.parameters.TENANT_TIER}} {{workflow.parameters.GIT_USER_EMAIL}} {{workflow.parameters.GIT_USERNAME}} {{workflow.parameters.GIT_BRANCH}} {{workflow.parameters.GIT_TOKEN}}']
45+
args: ['./04-tenant-offboarding.sh "$TENANT_ID" "$TENANT_TIER" "$GIT_USER_EMAIL" "$GIT_USERNAME" "$GIT_BRANCH" "$GIT_TOKEN"']
4046
volumeMounts:
4147
- name: workdir
4248
mountPath: /mnt/vol
4349
env:
50+
- name: TENANT_ID
51+
value: "{{workflow.parameters.TENANT_ID}}"
52+
- name: TENANT_TIER
53+
value: "{{workflow.parameters.TENANT_TIER}}"
54+
- name: GIT_USER_EMAIL
55+
value: "{{workflow.parameters.GIT_USER_EMAIL}}"
4456
- name: GIT_USERNAME
4557
value: "{{workflow.parameters.GIT_USERNAME}}"
58+
- name: GIT_BRANCH
59+
value: "{{workflow.parameters.GIT_BRANCH}}"
4660
- name: GIT_TOKEN
4761
value: "{{workflow.parameters.GIT_TOKEN}}"
4862
volumeClaimTemplates:

gitops/control-plane/production/workflows/tenant-onboarding-workflow-template.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ spec:
1010
container:
1111
image: "${ecr_argoworkflow_container}:0.1"
1212
command: ["/bin/sh","-c"]
13-
args: ['./00-validate-tenant.sh {{workflow.parameters.TENANT_ID}}']
13+
args: ['./00-validate-tenant.sh "$TENANT_ID"']
1414
volumeMounts:
1515
- name: workdir
1616
mountPath: /mnt/vol
1717
env:
18+
- name: TENANT_ID
19+
value: "{{workflow.parameters.TENANT_ID}}"
1820
- name: GIT_USERNAME
1921
value: "{{workflow.parameters.GIT_USERNAME}}"
2022
- name: GIT_TOKEN
@@ -23,11 +25,15 @@ spec:
2325
container:
2426
image: "${ecr_argoworkflow_container}:0.1"
2527
command: ["/bin/sh","-c"]
26-
args: ['./01-tenant-clone-repo.sh {{workflow.parameters.REPO_URL}} {{workflow.parameters.GIT_BRANCH}} {{workflow.parameters.GIT_USERNAME}} {{workflow.parameters.GIT_TOKEN}} && cp -r eks-saas-gitops /mnt/vol/eks-saas-gitops']
28+
args: ['./01-tenant-clone-repo.sh "$REPO_URL" "$GIT_BRANCH" "$GIT_USERNAME" "$GIT_TOKEN" && cp -r eks-saas-gitops /mnt/vol/eks-saas-gitops']
2729
volumeMounts:
2830
- name: workdir
2931
mountPath: /mnt/vol
3032
env:
33+
- name: REPO_URL
34+
value: "{{workflow.parameters.REPO_URL}}"
35+
- name: GIT_BRANCH
36+
value: "{{workflow.parameters.GIT_BRANCH}}"
3137
- name: GIT_USERNAME
3238
value: "{{workflow.parameters.GIT_USERNAME}}"
3339
- name: GIT_TOKEN
@@ -36,13 +42,23 @@ spec:
3642
container:
3743
image: "${ecr_argoworkflow_container}:0.1"
3844
command: ["/bin/sh","-c"]
39-
args: ['./02-tenant-onboarding.sh {{workflow.parameters.TENANT_ID}} {{workflow.parameters.RELEASE_VERSION}} {{workflow.parameters.TENANT_TIER}} {{workflow.parameters.GIT_USER_EMAIL}} {{workflow.parameters.GIT_USERNAME}} {{workflow.parameters.GIT_BRANCH}} {{workflow.parameters.GIT_TOKEN}}']
45+
args: ['./02-tenant-onboarding.sh "$TENANT_ID" "$RELEASE_VERSION" "$TENANT_TIER" "$GIT_USER_EMAIL" "$GIT_USERNAME" "$GIT_BRANCH" "$GIT_TOKEN"']
4046
volumeMounts:
4147
- name: workdir
4248
mountPath: /mnt/vol
4349
env:
50+
- name: TENANT_ID
51+
value: "{{workflow.parameters.TENANT_ID}}"
52+
- name: RELEASE_VERSION
53+
value: "{{workflow.parameters.RELEASE_VERSION}}"
54+
- name: TENANT_TIER
55+
value: "{{workflow.parameters.TENANT_TIER}}"
56+
- name: GIT_USER_EMAIL
57+
value: "{{workflow.parameters.GIT_USER_EMAIL}}"
4458
- name: GIT_USERNAME
4559
value: "{{workflow.parameters.GIT_USERNAME}}"
60+
- name: GIT_BRANCH
61+
value: "{{workflow.parameters.GIT_BRANCH}}"
4662
- name: GIT_TOKEN
4763
value: "{{workflow.parameters.GIT_TOKEN}}"
4864
volumeClaimTemplates:

helpers/vs-code-ec2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWSTemplateFormatVersion: 2010-09-09
22

3-
Description: This stack creates an EC2 instance with VS Code server environment for Guidance for Building SaaS Applications on Amazon EKS using GitOps (PLACEHOLDER).
3+
Description: This stack creates an EC2 instance with VS Code server environment for the Solution Guidace on Building SaaS applications on Amazon EKS using GitOps"
44

55
Parameters:
66
EnvironmentName:
@@ -183,7 +183,7 @@ Resources:
183183
- export TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds:60")
184184
- export AWS_REGION=$(curl -H "X-aws-ec2-metadata-token:${TOKEN}" -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/') && echo "export AWS_REGION=${AWS_REGION}" >> /home/ec2-user/.bashrc
185185
- export ALLOWED_IP="{{allowedIp}}"
186-
- "git clone https://github.com/aws-samples/eks-saas-gitops.git /home/ec2-user/environment/eks-saas-gitops"
186+
- "git clone https://github.com/aws-samples/eks-saas-gitops.git /home/ec2-user/environment/eks-saas-gitops; echo 'solution=true' > /home/ec2-user/environment/eks-saas-gitops/terraform/workshop/terraform.tfvars"
187187
- "chown -R ec2-user:ec2-user /home/ec2-user/environment"
188188
- "sudo -u ec2-user nohup /usr/bin/code-server --port 8080 --host 0.0.0.0 > /dev/null 2>&1 &"
189189
- "export WAIT_HANDLE_URL=$(aws ssm get-parameter --name '/eks-saas-gitops/waitcondition-url' --query 'Parameter.Value' --output text --region $AWS_REGION)"

tenant-microservices/payments/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Flask==3.0.0
44
itsdangerous==2.1.2
55
Jinja2==3.1.3
66
MarkupSafe==2.1.3
7-
Werkzeug==3.0.1
7+
Werkzeug==3.0.6

tenant-microservices/producer/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Flask==3.0.0
44
itsdangerous==2.1.2
55
Jinja2==3.1.3
66
MarkupSafe==2.1.3
7-
Werkzeug==3.0.1
7+
Werkzeug==3.0.6
88
boto3~=1.28.59
99
botocore~=1.31.59

terraform/install.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ apply_flux() {
138138
echo "Flux and GitOps infrastructure applied successfully."
139139
}
140140

141+
# Apply remaining Terraform resources
142+
apply_remaining_resources() {
143+
echo "Applying remaining Terraform resources..."
144+
terraform apply --auto-approve
145+
146+
echo "All Terraform resources created successfully."
147+
}
148+
149+
141150
# Print the setup information
142151
print_setup_info() {
143152
echo "=============================="
@@ -196,6 +205,7 @@ main() {
196205
create_gitea_repositories # Create Gitea repositories
197206
echo "Proceeding with Flux setup..."
198207
apply_flux
208+
apply_remaining_resources
199209
echo "=============================="
200210
echo "Flux Setup Complete!"
201211
echo "=============================="

terraform/modules/gitea/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ resource "aws_iam_role_policy" "ecr_access" {
169169
})
170170
}
171171

172-
resource "aws_iam_role_policy_attachment" "ssm_instance_connect" {
173-
role = aws_iam_role.gitea.name
174-
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
175-
}
172+
# resource "aws_iam_role_policy_attachment" "ssm_instance_connect" {
173+
# role = aws_iam_role.gitea.name
174+
# policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
175+
# }
176176

177177
resource "aws_iam_instance_profile" "gitea" {
178178
name = "${var.name}-profile"

terraform/workshop/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ locals {
1010
}
1111
}
1212

13+
################################################################################
14+
# Adding guidance solution ID via AWS CloudFormation resource
15+
################################################################################
16+
resource "random_bytes" "this" {
17+
count = var.solution ? 1 : 0
18+
length = 2
19+
}
20+
21+
resource "aws_cloudformation_stack" "guidance_deployment_metrics" {
22+
count = var.solution ? 1 : 0
23+
24+
name = "tracking-stack-${random_bytes.this[0].hex}"
25+
on_failure = "DO_NOTHING"
26+
template_body = <<STACK
27+
{
28+
"AWSTemplateFormatVersion": "2010-09-09",
29+
"Description": "(S09620) This is a CFN stack for Solution Guidance on Building SaaS applications on Amazon EKS using GitOps.",
30+
"Resources": {
31+
"EmptyResource": {
32+
"Type": "AWS::CloudFormation::WaitConditionHandle"
33+
}
34+
}
35+
}
36+
STACK
37+
}
38+
1339
################################################################################
1440
# VPC and Roles
1541
################################################################################

terraform/workshop/providers.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ provider "gitea" {
88
insecure = true
99
}
1010

11+
provider "random" {}
12+
1113
provider "aws" {
1214
region = var.aws_region
1315
}

0 commit comments

Comments
 (0)