Skip to content

Commit e20e713

Browse files
committed
Add deploy cdk script
1 parent 2a4e13c commit e20e713

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

bin/deploy_cdk.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
AWS_CMD=${AWS_CMD:-aws}
6+
CDK_CMD=${CDK_CMD:-cdk}
7+
8+
# deploy bulk of the application
9+
(cd cdk
10+
npm run cdk -- deploy --require-approval never QuizAppStack
11+
)
12+
13+
# get the backend API url
14+
API_URL=$($AWS_CMD cloudformation describe-stacks --stack-name QuizAppStack --query Stacks[0].Outputs[0].OutputValue --output text)
15+
echo "Backend API URL: $API_URL"
16+
17+
# build the frontend code
18+
(cd frontend
19+
echo "REACT_APP_API_ENDPOINT=$API_URL" > .env.local
20+
npx react-scripts build
21+
)
22+
23+
# deploy the frontend stack
24+
(cd cdk
25+
npm run ${CDK_CMD} -- deploy --require-approval never FrontendStack
26+
)

0 commit comments

Comments
 (0)