All checks were successful
Setup EC2 Tools / setup-server (push) Successful in 2m40s
1.9 KiB
1.9 KiB
Trypost Media AWS CDK Stack
This CDK stack sets up the AWS cloud infrastructure for media asset hosting for Trypost:
- S3 Bucket (
trypostmedia):- Secure private bucket with
BlockPublicAccess.BLOCK_ALLandBucketEncryption.S3_MANAGED - Configured CORS headers for web uploads and downloads
- SSL enforced (
enforceSSL: true)
- Secure private bucket with
- CloudFront Distribution:
- Integrated with S3 using modern Origin Access Control (OAC)
- HTTPS redirect policy
- Optimized caching policy and CORS security response headers
- Generates the CloudFront URL for distribution
- CloudFormation Outputs:
BucketName: Name of the S3 bucket (trypostmedia)DistributionDomainName&DistributionUrl: CloudFront CDN endpoint to use in.env(AWS_URL)
Deployment Instructions
1. Install Dependencies
Navigate to this directory and install dependencies:
cd cdk
npm install
2. Configure AWS Credentials
Ensure your AWS credentials and region are configured:
export AWS_ACCESS_KEY_ID="<your-access-key-id>"
export AWS_SECRET_ACCESS_KEY="<your-secret-access-key>"
export AWS_DEFAULT_REGION="ap-south-2"
3. Synthesize and Review CloudFormation Template
npx cdk synth
4. Deploy Stack
npx cdk deploy
Deployed Stack Details (ap-south-2)
- Bucket ARN:
arn:aws:s3:::trypostmedia - Bucket Name:
trypostmedia - Distribution ID:
E1R40XT0UHR7NK - Distribution Domain:
d28qhqo5myc2wf.cloudfront.net - Distribution URL:
https://d28qhqo5myc2wf.cloudfront.net
Laravel .env Configuration
Configure your Laravel .env with the deployed outputs:
FILESYSTEM_DISK=s3
AWS_ACCESS_KEY_ID=<your-iam-access-key>
AWS_SECRET_ACCESS_KEY=<your-iam-secret-key>
AWS_DEFAULT_REGION=ap-south-2
AWS_BUCKET=trypostmedia
AWS_URL=https://d28qhqo5myc2wf.cloudfront.net