-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuildspec.yml
More file actions
152 lines (136 loc) · 5.81 KB
/
buildspec.yml
File metadata and controls
152 lines (136 loc) · 5.81 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
version: 0.2
# Hotline QA - Simplified CodeBuild Deployment
# This buildspec works with the deploy.sh script
phases:
install:
runtime-versions:
nodejs: 18
commands:
- echo "🚀 Hotline QA Deployment Started"
- echo "Installing AWS CDK CLI..."
- npm install -g aws-cdk@2.87.0
- echo "Installing project dependencies..."
- npm ci
pre_build:
commands:
- echo "📋 Pre-build phase started on $(date)"
- echo "Checking AWS CLI configuration..."
- aws sts get-caller-identity
- echo ""
- echo "📋 Environment Configuration:"
- echo "COMPANY_NAME:$COMPANY_NAME"
- echo "GITHUB_OWNER:$GITHUB_OWNER"
- echo "GITHUB_REPO:$GITHUB_REPO"
- echo "GITHUB_TOKEN_SECRET:$GITHUB_TOKEN_SECRET"
- echo "AWS_REGION:$AWS_REGION"
- echo "ACTION:$ACTION"
- echo ""
- echo "📦 Building TypeScript project..."
- npm run build
- echo "✅ TypeScript build completed"
build:
commands:
- echo "🏗️ Build phase started on $(date)"
- echo "Setting up CDK environment..."
- ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
- echo "Account:$ACCOUNT, Region:$AWS_REGION"
- echo "🔧 Checking CDK bootstrap status..."
- |
if ! aws cloudformation describe-stacks --stack-name CDKToolkit --region $AWS_REGION > /dev/null 2>&1; then
echo "🔧 Bootstrapping CDK..."
cdk bootstrap aws://$ACCOUNT/$AWS_REGION
else
echo "✅ CDK already bootstrapped"
fi
- echo "🔐 Validating GitHub token secret..."
- |
if ! aws secretsmanager describe-secret --secret-id "$GITHUB_TOKEN_SECRET" --region "$AWS_REGION" > /dev/null 2>&1; then
echo "❌ ERROR: GitHub token secret '$GITHUB_TOKEN_SECRET' not found"
echo "This should have been created by the deploy.sh script"
exit 1
fi
echo "✅ GitHub token secret validated"
- |
if [ "$ACTION" = "destroy" ]; then
echo "🗑️ Destroying Hotline QA system..."
echo "Destroying main application stack..."
cdk destroy HotlineQaStack-prod \
--context envName=prod \
--context bucketNamePrefix=${COMPANY_NAME}-hotline-qa \
--context deployFrontend=true \
--context githubOwner=$GITHUB_OWNER \
--context githubRepo=$GITHUB_REPO \
--context githubTokenSecretName=$GITHUB_TOKEN_SECRET \
--force || echo "Stack may not exist or already destroyed"
echo "🗑️ Cleaning up GitHub token secret..."
aws secretsmanager delete-secret \
--secret-id "$GITHUB_TOKEN_SECRET" \
--region "$AWS_REGION" \
--force-delete-without-recovery || echo "Secret may not exist"
echo "✅ Destroy process completed"
else
echo "🚀 Deploying Hotline QA system..."
echo "This will take 10-15 minutes to complete..."
cdk deploy HotlineQaStack-prod \
--context envName=prod \
--context bucketNamePrefix=${COMPANY_NAME}-hotline-qa \
--context deployFrontend=true \
--context githubOwner=$GITHUB_OWNER \
--context githubRepo=$GITHUB_REPO \
--context githubTokenSecretName=$GITHUB_TOKEN_SECRET \
--require-approval never
echo "✅ Deployment completed successfully!"
fi
post_build:
commands:
- echo "📋 Post-build phase started on $(date)"
- |
if [ "$ACTION" = "deploy" ]; then
echo "📊 Deployment Summary:"
echo "======================"
echo ""
echo "🔗 CloudFormation Stack Outputs:"
aws cloudformation describe-stacks \
--stack-name HotlineQaStack-prod \
--region $AWS_REGION \
--query 'Stacks[0].Outputs' \
--output table || echo "Stack outputs not available yet"
echo ""
echo "🎉 Hotline QA System Deployed Successfully!"
echo ""
echo "📋 What was deployed:"
echo "✅ S3 bucket for audio files and results"
echo "✅ Lambda functions for processing pipeline"
echo "✅ Step Functions workflow orchestration"
echo "✅ DynamoDB tables for counselor data"
echo "✅ API Gateway for REST endpoints"
echo "✅ Amplify frontend application"
echo "✅ Transcribe Call Analytics integration"
echo "✅ Bedrock AI analysis capabilities"
echo ""
echo "📋 Next Steps:"
echo "1. Access your frontend via the Amplify URL (shown above)"
echo "2. Test API endpoints using the API Gateway URL"
echo "3. Upload test audio files (.wav format) to S3 bucket 'records/' folder"
echo "4. Monitor processing in Step Functions console"
echo "5. View results in DynamoDB tables and frontend interface"
echo ""
echo "🔗 Management Console URLs:"
echo "CloudFormation: https://console.aws.amazon.com/cloudformation/home?region=$AWS_REGION"
echo "Step Functions: https://console.aws.amazon.com/states/home?region=$AWS_REGION"
echo "API Gateway: https://console.aws.amazon.com/apigateway/home?region=$AWS_REGION"
echo "Amplify: https://console.aws.amazon.com/amplify/home?region=$AWS_REGION"
else
echo "🗑️ Destruction completed successfully!"
echo "All AWS resources have been removed."
fi
- echo "📋 CDK $ACTION process completed on $(date)"
artifacts:
files:
- '**/*'
base-directory: 'cdk.out'
name: hotline-qa-artifacts
cache:
paths:
- 'node_modules/**/*'
- 'frontend/node_modules/**/*'