Skip to content

Commit

Permalink
Updates for WorkshopStudio compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
brtrvn committed Mar 1, 2024
1 parent f51df64 commit 6c9f2fd
Show file tree
Hide file tree
Showing 16 changed files with 384 additions and 287 deletions.
10 changes: 8 additions & 2 deletions Lab2/Part1/product-manager/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AWS_REGION=$(aws configure list | grep region | awk '{print $2}')
CODEBUILD_PROJECT="saas-bootcamp-product-svc"
CODE_PIPELINE="saas-bootcamp-product-svc"
BOOTCAMP_BUCKET=$(aws ssm get-parameter --name "saas-bootcamp-bucket" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue-${AWS_REGION}" | jq -r '.Parameter.Value')
BOOTCAMP_BUCKET_PREFIX=$(aws ssm get-parameter --name "saas-bootcamp-bucket-prefix" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue" | jq -r '.Parameter.Value')

if [ -z "$BOOTCAMP_BUCKET" ]; then
echo "Error: Can't determine SaaS Bootcamp S3 bucket name"
Expand All @@ -34,7 +35,12 @@ if [ -z "$DEPLOY_MONITOR_QUEUE" ]; then
exit 1
fi

if [ "N/A" == "$BOOTCAMP_BUCKET_PREFIX" ]; then
BOOTCAMP_BUCKET_PREFIX=""
fi

echo "SaaS Bootcamp S3 bucket: $BOOTCAMP_BUCKET"
echo "SaaS Bootcamp S3 bucket prefix: $BOOTCAMP_BUCKET_PREFIX"
echo "SaaS Bootcamp SQS queue: $DEPLOY_MONITOR_QUEUE"
echo

Expand All @@ -43,7 +49,7 @@ aws sqs purge-queue --queue-url "$DEPLOY_MONITOR_QUEUE" > /dev/null

# Upload the updated code to S3
echo "Uploading code to S3"
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/source/product-manager/
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/${BOOTCAMP_BUCKET_PREFIX}source/product-manager/

# Trigger a new build to create a fresh docker image with the updated code
BUILD_PROJECT=$(aws codebuild start-build --project-name ${CODEBUILD_PROJECT})
Expand Down
10 changes: 8 additions & 2 deletions Lab2/Part2/product-manager/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AWS_REGION=$(aws configure list | grep region | awk '{print $2}')
CODEBUILD_PROJECT="saas-bootcamp-product-svc"
CODE_PIPELINE="saas-bootcamp-product-svc"
BOOTCAMP_BUCKET=$(aws ssm get-parameter --name "saas-bootcamp-bucket" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue-${AWS_REGION}" | jq -r '.Parameter.Value')
BOOTCAMP_BUCKET_PREFIX=$(aws ssm get-parameter --name "saas-bootcamp-bucket-prefix" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue" | jq -r '.Parameter.Value')

if [ -z "$BOOTCAMP_BUCKET" ]; then
echo "Error: Can't determine SaaS Bootcamp S3 bucket name"
Expand All @@ -34,7 +35,12 @@ if [ -z "$DEPLOY_MONITOR_QUEUE" ]; then
exit 1
fi

if [ "N/A" == "$BOOTCAMP_BUCKET_PREFIX" ]; then
BOOTCAMP_BUCKET_PREFIX=""
fi

echo "SaaS Bootcamp S3 bucket: $BOOTCAMP_BUCKET"
echo "SaaS Bootcamp S3 bucket prefix: $BOOTCAMP_BUCKET_PREFIX"
echo "SaaS Bootcamp SQS queue: $DEPLOY_MONITOR_QUEUE"
echo

Expand All @@ -43,7 +49,7 @@ aws sqs purge-queue --queue-url "$DEPLOY_MONITOR_QUEUE" > /dev/null

# Upload the updated code to S3
echo "Uploading code to S3"
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/source/product-manager/
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/${BOOTCAMP_BUCKET_PREFIX}source/product-manager/

# Trigger a new build to create a fresh docker image with the updated code
BUILD_PROJECT=$(aws codebuild start-build --project-name ${CODEBUILD_PROJECT})
Expand Down
10 changes: 8 additions & 2 deletions Lab2/Part3/product-manager/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AWS_REGION=$(aws configure list | grep region | awk '{print $2}')
CODEBUILD_PROJECT="saas-bootcamp-product-svc"
CODE_PIPELINE="saas-bootcamp-product-svc"
BOOTCAMP_BUCKET=$(aws ssm get-parameter --name "saas-bootcamp-bucket" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue-${AWS_REGION}" | jq -r '.Parameter.Value')
BOOTCAMP_BUCKET_PREFIX=$(aws ssm get-parameter --name "saas-bootcamp-bucket-prefix" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue" | jq -r '.Parameter.Value')

if [ -z "$BOOTCAMP_BUCKET" ]; then
echo "Error: Can't determine SaaS Bootcamp S3 bucket name"
Expand All @@ -34,7 +35,12 @@ if [ -z "$DEPLOY_MONITOR_QUEUE" ]; then
exit 1
fi

if [ "N/A" == "$BOOTCAMP_BUCKET_PREFIX" ]; then
BOOTCAMP_BUCKET_PREFIX=""
fi

echo "SaaS Bootcamp S3 bucket: $BOOTCAMP_BUCKET"
echo "SaaS Bootcamp S3 bucket prefix: $BOOTCAMP_BUCKET_PREFIX"
echo "SaaS Bootcamp SQS queue: $DEPLOY_MONITOR_QUEUE"
echo

Expand All @@ -43,7 +49,7 @@ aws sqs purge-queue --queue-url "$DEPLOY_MONITOR_QUEUE" > /dev/null

# Upload the updated code to S3
echo "Uploading code to S3"
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/source/product-manager/
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/${BOOTCAMP_BUCKET_PREFIX}source/product-manager/

# Trigger a new build to create a fresh docker image with the updated code
BUILD_PROJECT=$(aws codebuild start-build --project-name ${CODEBUILD_PROJECT})
Expand Down
10 changes: 8 additions & 2 deletions Lab3/Part1/product-manager/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AWS_REGION=$(aws configure list | grep region | awk '{print $2}')
CODEBUILD_PROJECT="saas-bootcamp-product-svc"
CODE_PIPELINE="saas-bootcamp-product-svc"
BOOTCAMP_BUCKET=$(aws ssm get-parameter --name "saas-bootcamp-bucket" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue-${AWS_REGION}" | jq -r '.Parameter.Value')
BOOTCAMP_BUCKET_PREFIX=$(aws ssm get-parameter --name "saas-bootcamp-bucket-prefix" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue" | jq -r '.Parameter.Value')

if [ -z "$BOOTCAMP_BUCKET" ]; then
echo "Error: Can't determine SaaS Bootcamp S3 bucket name"
Expand All @@ -34,7 +35,12 @@ if [ -z "$DEPLOY_MONITOR_QUEUE" ]; then
exit 1
fi

if [ "N/A" == "$BOOTCAMP_BUCKET_PREFIX" ]; then
BOOTCAMP_BUCKET_PREFIX=""
fi

echo "SaaS Bootcamp S3 bucket: $BOOTCAMP_BUCKET"
echo "SaaS Bootcamp S3 bucket prefix: $BOOTCAMP_BUCKET_PREFIX"
echo "SaaS Bootcamp SQS queue: $DEPLOY_MONITOR_QUEUE"
echo

Expand All @@ -43,7 +49,7 @@ aws sqs purge-queue --queue-url "$DEPLOY_MONITOR_QUEUE" > /dev/null

# Upload the updated code to S3
echo "Uploading code to S3"
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/source/product-manager/
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/${BOOTCAMP_BUCKET_PREFIX}source/product-manager/

# Trigger a new build to create a fresh docker image with the updated code
BUILD_PROJECT=$(aws codebuild start-build --project-name ${CODEBUILD_PROJECT})
Expand Down
10 changes: 8 additions & 2 deletions Lab3/Part4/product-manager/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AWS_REGION=$(aws configure list | grep region | awk '{print $2}')
CODEBUILD_PROJECT="saas-bootcamp-product-svc"
CODE_PIPELINE="saas-bootcamp-product-svc"
BOOTCAMP_BUCKET=$(aws ssm get-parameter --name "saas-bootcamp-bucket" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue-${AWS_REGION}" | jq -r '.Parameter.Value')
BOOTCAMP_BUCKET_PREFIX=$(aws ssm get-parameter --name "saas-bootcamp-bucket-prefix" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue" | jq -r '.Parameter.Value')

if [ -z "$BOOTCAMP_BUCKET" ]; then
echo "Error: Can't determine SaaS Bootcamp S3 bucket name"
Expand All @@ -34,7 +35,12 @@ if [ -z "$DEPLOY_MONITOR_QUEUE" ]; then
exit 1
fi

if [ "N/A" == "$BOOTCAMP_BUCKET_PREFIX" ]; then
BOOTCAMP_BUCKET_PREFIX=""
fi

echo "SaaS Bootcamp S3 bucket: $BOOTCAMP_BUCKET"
echo "SaaS Bootcamp S3 bucket prefix: $BOOTCAMP_BUCKET_PREFIX"
echo "SaaS Bootcamp SQS queue: $DEPLOY_MONITOR_QUEUE"
echo

Expand All @@ -43,7 +49,7 @@ aws sqs purge-queue --queue-url "$DEPLOY_MONITOR_QUEUE" > /dev/null

# Upload the updated code to S3
echo "Uploading code to S3"
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/source/product-manager/
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/${BOOTCAMP_BUCKET_PREFIX}source/product-manager/

# Trigger a new build to create a fresh docker image with the updated code
BUILD_PROJECT=$(aws codebuild start-build --project-name ${CODEBUILD_PROJECT})
Expand Down
10 changes: 8 additions & 2 deletions Lab3/Part5/product-manager/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ AWS_REGION=$(aws configure list | grep region | awk '{print $2}')
CODEBUILD_PROJECT="saas-bootcamp-product-svc"
CODE_PIPELINE="saas-bootcamp-product-svc"
BOOTCAMP_BUCKET=$(aws ssm get-parameter --name "saas-bootcamp-bucket" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue-${AWS_REGION}" | jq -r '.Parameter.Value')
BOOTCAMP_BUCKET_PREFIX=$(aws ssm get-parameter --name "saas-bootcamp-bucket-prefix" | jq -r '.Parameter.Value')
DEPLOY_MONITOR_QUEUE=$(aws ssm get-parameter --name "saas-bootcamp-ci-cd-queue" | jq -r '.Parameter.Value')

if [ -z "$BOOTCAMP_BUCKET" ]; then
echo "Error: Can't determine SaaS Bootcamp S3 bucket name"
Expand All @@ -34,7 +35,12 @@ if [ -z "$DEPLOY_MONITOR_QUEUE" ]; then
exit 1
fi

if [ "N/A" == "$BOOTCAMP_BUCKET_PREFIX" ]; then
BOOTCAMP_BUCKET_PREFIX=""
fi

echo "SaaS Bootcamp S3 bucket: $BOOTCAMP_BUCKET"
echo "SaaS Bootcamp S3 bucket prefix: $BOOTCAMP_BUCKET_PREFIX"
echo "SaaS Bootcamp SQS queue: $DEPLOY_MONITOR_QUEUE"
echo

Expand All @@ -43,7 +49,7 @@ aws sqs purge-queue --queue-url "$DEPLOY_MONITOR_QUEUE" > /dev/null

# Upload the updated code to S3
echo "Uploading code to S3"
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/source/product-manager/
aws s3 cp server.js s3://${BOOTCAMP_BUCKET}/${BOOTCAMP_BUCKET_PREFIX}source/product-manager/

# Trigger a new build to create a fresh docker image with the updated code
BUILD_PROJECT=$(aws codebuild start-build --project-name ${CODEBUILD_PROJECT})
Expand Down
23 changes: 16 additions & 7 deletions resources/auth-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
AWSTemplateFormatVersion: 2010-09-09
Description: AWS SaaS Factory Bootcamp Auth Service
Parameters:
BootcampBucket:
WorkshopBucket:
Description: The S3 bucket with bootcamp resources
Type: String
AssetsBucketPrefix:
Description: S3 folder containing workshop assets. Leave blank if you did not put the assets in a subfolder.
Type: String
Default: ''
ArtifactBucket:
Description: The S3 bucket for CodeBuild to store built artifacts
Type: String
Expand Down Expand Up @@ -74,6 +78,9 @@ Resources:
Path: '/'
Name: auth-manager
Packaging: ZIP
Cache:
Type: S3
Location: !Sub ${WorkshopBucket}/${AssetsBucketPrefix}codebuild-cache
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
Expand All @@ -82,17 +89,19 @@ Resources:
EnvironmentVariables:
- Name: REPOSITORY_URI
Value: !Sub ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${ECSRepository}
- Name: BOOTCAMP_BUCKET
Value: !Ref BootcampBucket
- Name: SOURCE_BUCKET
Value: !Ref WorkshopBucket
- Name: SOURCE_BUCKET_PREFIX
Value: !Ref AssetsBucketPrefix
Source:
Type: NO_SOURCE
BuildSpec: |
version: 0.2
phases:
pre_build:
commands:
- aws s3 cp --recursive s3://$BOOTCAMP_BUCKET/source/auth-manager ./auth-manager
- aws s3 cp --recursive s3://$BOOTCAMP_BUCKET/source/shared-modules ./auth-manager/shared-modules
- aws s3 cp --recursive s3://$SOURCE_BUCKET/${SOURCE_BUCKET_PREFIX}source/auth-manager ./auth-manager
- aws s3 cp --recursive s3://$SOURCE_BUCKET/${SOURCE_BUCKET_PREFIX}source/shared-modules ./auth-manager/shared-modules
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI
build:
commands:
Expand Down Expand Up @@ -184,7 +193,7 @@ Resources:
Type: AWS::IAM::Role
DependsOn: ECSLogGroup
Properties:
RoleName: saas-bootcamp-auth-svc-exec-role
RoleName: !Sub saas-bootcamp-auth-svc-exec-role-${AWS::Region}
Path: '/'
AssumeRolePolicyDocument:
Version: 2012-10-17
Expand Down Expand Up @@ -228,7 +237,7 @@ Resources:
ECSTaskRole:
Type: AWS::IAM::Role
Properties:
RoleName: saas-bootcamp-auth-svc-task-role
RoleName: !Sub saas-bootcamp-auth-svc-task-role-${AWS::Region}
Path: '/'
AssumeRolePolicyDocument:
Version: 2012-10-17
Expand Down
Loading

0 comments on commit 6c9f2fd

Please sign in to comment.