|  | 3 months ago | |
|---|---|---|
| .. | ||
| lib | 3 months ago | |
| .gitignore | 3 months ago | |
| .npmignore | 3 months ago | |
| README.md | 3 months ago | |
| app.js | 3 months ago | |
| cdk.context.json | 3 months ago | |
| cdk.json | 3 months ago | |
| package-lock.json | 3 months ago | |
| package.json | 3 months ago | |
| userdata.txt | 3 months ago | |
		
			
				
				README.md
			
		
		
			
			
		
	
	CP Docuseal CDK Infrastructure
This directory contains AWS CDK v2 infrastructure code for deploying the CP Docuseal app. At present it only deploys to development and staging; production will follow.
Architecture Overview
This infrastructure is basically nicked wholesale from the Integration Station application, just dialed down a notch as our needs are a bit less than theirs.
- Internal Application Load Balancer (ALB) - Routes traffic to ECS services within the VPC
- Amazon ECS Cluster - Runs containerized applications on EC2 instances (ARM64 t4g.small)
- ECS Service - Manages container deployment and scaling
- ECS Task Definition - Defines container configuration and resource requirements
- CloudWatch Logging - Centralized logging for application monitoring
- Security Groups - Network security controls
- ECR Integration - Uses existing "integration-station" ECR repository
Prerequisites
- AWS CLI configured with appropriate permissions
- Node.js (version 22 or later)
- AWS CDK v2 installed globally: npm install -g aws-cdk
- Existing AWS Infrastructure:
- VPC with public and private subnets
- ECR repository named "cp-docuseal"
- Appropriate IAM permissions for CDK deployment
 
Setup
- 
Install dependencies: cd cdk_deploy npm install
- 
Bootstrap CDK (application setup ONLY): npm run bootstrap
- 
Update VPC and Subnet IDs: Edit app.jsand replace the placeholder IDs with your actual VPC and subnet IDs:vpcId: 'vpc-your-actual-vpc-id', privateSubnetIds: ['subnet-your-private-1', 'subnet-your-private-2'], publicSubnetIds: ['subnet-your-public-1', 'subnet-your-public-2']
Environment Configuration
The infrastructure supports three environments with different resource allocations:
Development
- Instances: 1 ECS instance
- CPU: 512 units
- Memory: 1024 MB
Staging
- Instances: 1 ECS instance
- CPU: 512 units
- Memory: 1024 MB
Production
- N/A
Deployment
Deploy to Development
npm run deploy:dev
Deploy to Staging
npm run deploy:staging
Deploy to Production - NOT YET SUPPORTED
npm run deploy:prod
View CloudFormation Template
npm run synth
Compare Changes
npm run diff
Cleanup
Destroy Development Environment
npm run destroy:dev
Destroy Staging Environment
npm run destroy:staging
Destroy Production Environment - NOT YET SUPPORTED
npm run destroy:prod
Important Notes
- 
Internal ALB: The Application Load Balancer is configured as internal-only and deployed in private subnets for security. 
- 
ARM64 Instances: The ECS cluster uses t4g.small ARM64 instances for cost efficiency. Ensure your container images are built for ARM64 architecture. 
- 
Health Checks: The ALB target group is configured to perform health checks on /healthendpoint. Make sure your application responds to this endpoint.
- 
Logging: All ECS tasks automatically log to CloudWatch under /ecs/cp-docuseal-{environment}log groups.
- 
Security: Security groups are configured to allow: - ALB: HTTP (80) and HTTPS (443) traffic
- ECS: Traffic from ALB on port 3000
 
Troubleshooting
- 
VPC Lookup Issues: Ensure the VPC IDs and subnet IDs in app.jsare correct and exist in your AWS account.
- 
ECR Repository: Verify that the "cp-docuseal" ECR repository exists and contains the required Docker images. 
- 
Permissions: Ensure your AWS credentials have sufficient permissions for: - EC2 (VPC, Security Groups, Launch Templates)
- ECS (Clusters, Services, Tasks)
- ELB (Application Load Balancers, Target Groups)
- CloudWatch (Log Groups)
- IAM (Roles and Policies)
 
- 
Container Health: If services fail to start, check CloudWatch logs for container startup issues. 
Customization
You can modify the following aspects:
- Instance Types: Change ec2.InstanceClass.T4Gandec2.InstanceSize.SMALLin the stack
- Container Port: Update port mappings if your application uses a different port
- Resource Limits: Adjust CPU and memory allocations in the environment configurations
- Auto Scaling: Modify minCapacityandmaxCapacityfor different scaling behaviors
Stack Outputs
After deployment, the stack provides:
- ALB DNS Name: Internal DNS name for the Application Load Balancer
- ECS Cluster Name: Name of the created ECS cluster
- ECS Service Name: Name of the ECS service