-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
52 lines (40 loc) · 1.61 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
deploy_infrastructure() {
# Navigate to the infrastructure directory
cd game-dev-infrastructure
echo "Building lambda requirements"
rm -rf lambda_build
mkdir lambda_build
pip install -r lambda_code/requirements.txt -t lambda_build
cp lambda_code/*.py lambda_build
# Deploy the infrastructure
echo "Deploying AWS infrastructure..."
cdk deploy --outputs-file ./outputs.json --all
# Check if the deployment was successful
if [ $? -ne 0 ]; then
echo "Infrastructure deployment failed."
exit 1
fi
cd ..
}
deploy_frontend() {
# Read outputs (S3 bucket name and CloudFront distribution ID)
BUCKET_NAME=$(cat game-dev-infrastructure/outputs.json | jq -r '.["FrontendStack"].BucketName')
DISTRIBUTION_ID=$(cat game-dev-infrastructure/outputs.json | jq -r '.["FrontendStack"].DistributionId')
IDENTITY_POOL_ID=$(cat game-dev-infrastructure/outputs.json | jq -r '.["CognitoStack"].IdentityPoolId')
USER_POOL_ID=$(cat game-dev-infrastructure/outputs.json | jq -r '.["CognitoStack"].UserPoolId')
USER_POOL_CLIENT_ID=$(cat game-dev-infrastructure/outputs.json | jq -r '.["CognitoStack"].UserPoolClientId')
# Navigate to the frontend directory
cd game-dev-frontend
# Deploy the frontend
echo "Deploying the frontend..."
bash ./deploy.sh $BUCKET_NAME $DISTRIBUTION_ID $IDENTITY_POOL_ID $USER_POOL_ID $USER_POOL_CLIENT_ID
# Check deployment status
if [ $? -ne 0 ]; then
echo "Frontend deployment failed."
exit 1
fi
echo "Deployment completed successfully."
}
deploy_infrastructure
deploy_frontend