|
| 1 | +# Javabuilder Dev Environment Deployment Guide |
| 2 | + |
| 3 | +Comprehensive guide for deploying and managing the JavaBuilder AWS Lambda environment for development. |
| 4 | + |
| 5 | +## 🎯 Quick Start |
| 6 | + |
| 7 | +For a complete no-SSL deployment (recommended for dev): |
| 8 | +```bash |
| 9 | +./deploy-javabuilder-dev-no-ssl-fixed.sh |
| 10 | +``` |
| 11 | + |
| 12 | +For modular deployment: |
| 13 | +```bash |
| 14 | +./01-deploy-base-infrastructure.sh # Deploy IAM roles first |
| 15 | +./02-build-java-components.sh # Build Java artifacts |
| 16 | +./03-deploy-application.sh # Deploy application stack |
| 17 | +``` |
| 18 | + |
| 19 | +## 📋 Current Environment Status |
| 20 | + |
| 21 | +- **AWS Account**: 165336972514 |
| 22 | +- **Profile**: codeorg-dev |
| 23 | +- **Region**: us-east-1 |
| 24 | +- **Stack Name**: javabuilder-dev |
| 25 | +- **Bucket**: javabuilder-dev-artifacts-* |
| 26 | + |
| 27 | +### ✅ Working Components |
| 28 | +- ✅ AWS CLI configured with `codeorg-dev` profile |
| 29 | +- ✅ S3 bucket creation for artifacts |
| 30 | +- ✅ ERB template processing with SSL removal |
| 31 | +- ✅ CloudFormation template packaging and deployment |
| 32 | +- ✅ Java artifacts built and packaged correctly |
| 33 | +- ✅ Lambda functions deployed and active |
| 34 | + |
| 35 | +### 🔧 Key Components |
| 36 | +- **javabuilder-authorizer**: Handles API Gateway authorization |
| 37 | +- **api-gateway-routes**: API Gateway interaction logic |
| 38 | +- **org-code-javabuilder**: Core Java logic built with Gradle |
| 39 | +- **WebSocket API**: Real-time communication for build sessions |
| 40 | +- **CloudFront**: Content delivery for build artifacts |
| 41 | + |
| 42 | +## 🚀 Deployment Options |
| 43 | + |
| 44 | +### Option 1: No-SSL Deployment (Recommended for Dev) |
| 45 | +**Best for development environments without Route53 permissions** |
| 46 | +```bash |
| 47 | +./deploy-javabuilder-dev-no-ssl-fixed.sh |
| 48 | +``` |
| 49 | +- Removes SSL certificates and custom domains |
| 50 | +- Uses CloudFront default domain |
| 51 | +- Faster deployment, fewer permissions needed |
| 52 | + |
| 53 | +### Option 2: Full SSL Deployment |
| 54 | +**For production-like environments with Route53 access** |
| 55 | +```bash |
| 56 | +./01-deploy-base-infrastructure.sh |
| 57 | +./02-build-java-components.sh |
| 58 | +./03-deploy-application.sh |
| 59 | +``` |
| 60 | + |
| 61 | +### Option 3: Clean Slate Deployment |
| 62 | +**If stack exists but needs complete refresh** |
| 63 | +```bash |
| 64 | +./cleanup-javabuilder-dev.sh # Remove existing stack |
| 65 | +./deploy-javabuilder-dev-no-ssl-fixed.sh # Deploy fresh |
| 66 | +``` |
| 67 | + |
| 68 | +## 🔧 Prerequisites |
| 69 | + |
| 70 | +### Required Software |
| 71 | +- **AWS CLI**: Configure with `codeorg-dev` profile |
| 72 | +- **Ruby**: For ERB template processing |
| 73 | +- **Java/Gradle**: For building org-code-javabuilder components |
| 74 | + |
| 75 | +### Required Permissions |
| 76 | +- CloudFormation stack management |
| 77 | +- S3 bucket creation and object management |
| 78 | +- Lambda function deployment |
| 79 | +- IAM role creation (for base infrastructure) |
| 80 | +- API Gateway management |
| 81 | + |
| 82 | +### Pre-Deployment Check |
| 83 | +```bash |
| 84 | +./pre-deploy-check.sh # Verify all prerequisites |
| 85 | +``` |
| 86 | + |
| 87 | +## 📁 Required Artifacts |
| 88 | + |
| 89 | +### Java Build Artifacts |
| 90 | +- ✅ `org-code-javabuilder/lib/build/distributions/lib.zip` |
| 91 | +- ✅ `org-code-javabuilder/font_config.zip` |
| 92 | +- ✅ `org-code-javabuilder/change_runtime_directory/` (directory) |
| 93 | + |
| 94 | +### CloudFormation Templates |
| 95 | +- `../cicd/3-app/javabuilder/template.yml.erb` (source) |
| 96 | +- `process-template-no-ssl.rb` (SSL removal script) |
| 97 | +- Generated templates: `template-no-ssl.yml`, `packaged-*.yml` |
| 98 | + |
| 99 | +## 🔍 Deployment Process Details |
| 100 | + |
| 101 | +### 1. Template Processing |
| 102 | +- Processes ERB template with environment variables |
| 103 | +- Removes SSL resources for no-SSL deployment |
| 104 | +- Handles large template packaging via S3 |
| 105 | + |
| 106 | +### 2. Artifact Packaging |
| 107 | +- Creates S3 bucket for deployment artifacts |
| 108 | +- Packages Lambda code from local directories |
| 109 | +- Uploads packaged template to S3 |
| 110 | + |
| 111 | +### 3. CloudFormation Deployment |
| 112 | +- Uses `--template-url` for large templates |
| 113 | +- Includes `CAPABILITY_AUTO_EXPAND` for SAM transforms |
| 114 | +- Provides all required parameters via JSON file |
| 115 | + |
| 116 | +### 4. Post-Deployment Verification |
| 117 | +- Validates stack creation status |
| 118 | +- Tests WebSocket API endpoint |
| 119 | +- Verifies CloudFront distribution |
| 120 | +- Confirms Lambda function deployment |
| 121 | + |
| 122 | +## 🚨 Common Issues & Solutions |
| 123 | + |
| 124 | +### Template Too Large |
| 125 | +**Error**: Template body exceeds 51200 characters |
| 126 | +**Solution**: Script automatically uploads to S3 and uses `--template-url` |
| 127 | + |
| 128 | +### SSL Certificate Errors |
| 129 | +**Error**: Certificate validation or Route53 permissions |
| 130 | +**Solution**: Use no-SSL deployment script |
| 131 | + |
| 132 | +### Missing IAM Roles |
| 133 | +**Error**: Stack exports not found |
| 134 | +**Solution**: Deploy base infrastructure first with `01-deploy-base-infrastructure.sh` |
| 135 | + |
| 136 | +### Java Artifacts Missing |
| 137 | +**Error**: CodeUri points to non-existent files |
| 138 | +**Solution**: Run `02-build-java-components.sh` or ensure artifacts exist |
| 139 | + |
| 140 | +### Stack in ROLLBACK_COMPLETE State |
| 141 | +**Error**: Cannot update stack in failed state |
| 142 | +**Solution**: Use `cleanup-javabuilder-dev.sh` to delete and recreate |
| 143 | + |
| 144 | +## 🧪 Testing & Verification |
| 145 | + |
| 146 | +### Health Check Script |
| 147 | +```bash |
| 148 | +./test-deployment-health.sh # Verify deployment status |
| 149 | +``` |
| 150 | + |
| 151 | +### Manual Verification |
| 152 | +```bash |
| 153 | +# Check stack status |
| 154 | +aws cloudformation describe-stacks --stack-name javabuilder-dev --profile codeorg-dev |
| 155 | + |
| 156 | +# Test WebSocket endpoint |
| 157 | +aws apigatewayv2 get-apis --profile codeorg-dev |
| 158 | + |
| 159 | +# Verify Lambda functions |
| 160 | +aws lambda list-functions --profile codeorg-dev | grep -i javabuilder |
| 161 | +``` |
| 162 | + |
| 163 | +## 🧹 Cleanup & Maintenance |
| 164 | + |
| 165 | +### Clean Failed Deployments |
| 166 | +```bash |
| 167 | +./cleanup-failed-stack.sh # Remove failed stacks |
| 168 | +./cleanup-javabuilder-dev.sh # Remove specific dev stack |
| 169 | +``` |
| 170 | + |
| 171 | +### Artifact Management |
| 172 | +- S3 buckets are created with unique suffixes |
| 173 | +- Old artifacts remain in S3 (manual cleanup needed) |
| 174 | +- CloudFormation stacks are idempotent (safe to redeploy) |
| 175 | + |
| 176 | +## 📖 File Reference |
| 177 | + |
| 178 | +### Main Scripts |
| 179 | +- `deploy-javabuilder-dev-no-ssl-fixed.sh` - Complete no-SSL deployment |
| 180 | +- `01-deploy-base-infrastructure.sh` - IAM roles and base resources |
| 181 | +- `02-build-java-components.sh` - Build Java artifacts |
| 182 | +- `03-deploy-application.sh` - Deploy application stack |
| 183 | + |
| 184 | +### Configuration Files |
| 185 | +- `dev-deployment-params.json` - CloudFormation parameters |
| 186 | +- `dev.config.json` - Environment configuration |
| 187 | +- `process-template-no-ssl.rb` - SSL removal script |
| 188 | + |
| 189 | +### Generated Files |
| 190 | +- `template-no-ssl.yml` - Processed template without SSL |
| 191 | +- `packaged-*.yml` - CloudFormation packaged templates |
| 192 | +- `runtime.zip` - Lambda runtime artifacts |
| 193 | + |
| 194 | +For issues or questions, consult AWS CloudFormation logs or reach out to the DevOps team. |
| 195 | + |
0 commit comments