This project implements a secure S3 bucket infrastructure using AWS CDK (Cloud Development Kit) with TypeScript. It creates an S3 bucket with proper encryption, access controls, and logging capabilities.
This CDK application deploys an AWS S3 bucket with enterprise-grade security features including:
- Server-side encryption
- Access logging
- Lifecycle rules
- Intelligent tiering
- KMS encryption
- Public access blocking
- 🔒 KMS-managed encryption for both bucket and logs
- 📝 Server access logging with separate logging bucket
- 🚫 Complete public access blocking
- ♻️ Lifecycle rules for cost optimization
- 💰 Intelligent tiering configuration
- 🏷️ Automatic resource tagging
- 🔍 AWS Solutions security checks (cdk-nag)
- 🌍 Environment-based deployment configuration
- Node.js (v18 or later)
- AWS CLI configured with appropriate credentials
- AWS CDK CLI installed (
npm install -g aws-cdk) - TypeScript knowledge
- AWS account with necessary permissions
- Clone the repository
git clone <repository-url>
cd aws-s3- Install dependencies
npm install- Build the project
npm run buildCreate a .env file based on .env.example with your configuration:
APP_NAME=your-app-name
CDK_DEPLOY_REGION=your-region
ENVIRONMENT=development|staging|production
OWNER=your-team
S3_BUCKET_NAMES=your-bucket-name,your-bucket-name-2Required environment variables:
APP_NAME: Application identifierCDK_DEPLOY_REGION: AWS region for deploymentENVIRONMENT: Deployment environmentOWNER: Team/Owner identifierS3_BUCKET_NAMES: Base name for S3 buckets
- Bootstrap CDK (first time only)
npx cdk bootstrap- Review the changes
npx cdk diff- Deploy the stack
npx cdk deploynpm run build- Compile TypeScript to JavaScriptnpm run watch- Watch for changes and compilenpm run test- Run the jest unit testsnpx cdk deploy- Deploy this stack to AWSnpx cdk diff- Compare deployed stack with current statenpx cdk synth- Emit synthesized CloudFormation template
- All buckets are encrypted using KMS keys
- Public access is completely blocked
- SSL is enforced for all requests
- Server access logging is enabled
- Resource policies follow AWS best practices
- AWS Solutions security checks are implemented
The stack exports the following values:
- S3 Bucket Name
- S3 Bucket ARN
- KMS Key ARN
- KMS Key ID
These can be referenced in other stacks or applications using CloudFormation exports.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.