|
| 1 | +# Interacting Bear Static Website CDK Deployment |
| 2 | + |
| 3 | +This CDK project deploys the infrastructure for the Interacting Bear static website at `interactingbear.jackjapar.com`. |
| 4 | + |
| 5 | +## Infrastructure Components |
| 6 | + |
| 7 | +- **S3 Bucket**: Stores the static website files |
| 8 | +- **CloudFront Distribution**: CDN for global content delivery |
| 9 | +- **SSL Certificate**: Automatic SSL certificate for the custom domain |
| 10 | +- **Route53 Record**: DNS record pointing to CloudFront distribution |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +1. AWS CLI configured with appropriate permissions |
| 15 | +2. AWS CDK CLI installed (`npm install -g aws-cdk`) |
| 16 | +3. Python 3.7+ |
| 17 | +4. The `jackjapar.com` domain already configured in Route53 |
| 18 | + |
| 19 | +## Setup and Deployment |
| 20 | + |
| 21 | +1. **Install CDK dependencies:** |
| 22 | + ```bash |
| 23 | + cd cdk |
| 24 | + python3 -m venv .venv |
| 25 | + source .venv/bin/activate |
| 26 | + pip install --upgrade pip |
| 27 | + pip install -r requirements.txt |
| 28 | + ``` |
| 29 | + |
| 30 | +2. **Bootstrap CDK (first time only):** |
| 31 | + ```bash |
| 32 | + cdk bootstrap |
| 33 | + ``` |
| 34 | + |
| 35 | +3. **Deploy the stack:** |
| 36 | + ```bash |
| 37 | + cdk deploy |
| 38 | + ``` |
| 39 | + |
| 40 | +4. **Manual Website Upload:** |
| 41 | + After deployment, upload your website files from `./build/web` to the S3 bucket: |
| 42 | + ```bash |
| 43 | + aws s3 sync ../build/web s3://interacting-bear-static-website --delete |
| 44 | + ``` |
| 45 | + |
| 46 | +5. **Invalidate CloudFront cache (if needed):** |
| 47 | + ```bash |
| 48 | + aws cloudfront create-invalidation --distribution-id <DISTRIBUTION_ID> --paths "/*" |
| 49 | + ``` |
| 50 | + |
| 51 | +## Stack Outputs |
| 52 | + |
| 53 | +After deployment, you'll see: |
| 54 | +- **BucketName**: S3 bucket name for manual uploads |
| 55 | +- **DistributionId**: CloudFront distribution ID for cache invalidation |
| 56 | +- **WebsiteURL**: Your website URL (https://interactingbear.jackjapar.com) |
| 57 | + |
| 58 | +## Manual Upload Process |
| 59 | + |
| 60 | +Since the website files are not automatically deployed by CDK, you'll need to: |
| 61 | + |
| 62 | +1. Build your Flutter web app: |
| 63 | + ```bash |
| 64 | + flutter build web |
| 65 | + ``` |
| 66 | + |
| 67 | +2. Upload to S3: |
| 68 | + ```bash |
| 69 | + aws s3 sync ./build/web s3://interacting-bear-static-website --delete |
| 70 | + ``` |
| 71 | + |
| 72 | +3. Invalidate CloudFront cache: |
| 73 | + ```bash |
| 74 | + aws cloudfront create-invalidation --distribution-id <DISTRIBUTION_ID> --paths "/*" |
| 75 | + ``` |
| 76 | + |
| 77 | +## Security Features |
| 78 | + |
| 79 | +- S3 bucket blocks all public access |
| 80 | +- CloudFront uses Origin Access Control (OAC) for secure S3 access |
| 81 | +- SSL/TLS certificate automatically provisioned and renewed |
| 82 | +- HTTPS redirect enforced |
| 83 | + |
| 84 | +## Cost Optimization |
| 85 | + |
| 86 | +- CloudFront compression enabled |
| 87 | +- Optimized caching policies |
| 88 | +- Versioned S3 bucket for backup and rollback capabilities |
0 commit comments