This project provisions a secure, scalable WireGuard VPN server infrastructure on AWS using AWS CDK (TypeScript). It includes:
- WireGuard VPN server: Deployed in a private subnet, accessible via a Network Load Balancer (NLB) and protected by security groups.
- Malware Protection DNS: Optional DNS server that filters traffic for malware domains, integrated with the VPN for enhanced security.
- Automated Subdomain Management: Creates and manages subdomains and DNS records for VPN endpoints.
- Provisions a WireGuard VPN server in a private subnet.
- Exposes the VPN via an AWS Network Load Balancer (NLB).
- Integrates with Route53 to create DNS records for the VPN endpoint.
- Optionally uses a custom DNS server for malware protection.
- Deploys a DNS server that filters out known malware domains.
- Whitelist domains can be managed via AWS SSM Parameter Store.
- The DNS server's private IP is exported for use by the VPN stack.
- Automates creation of subdomains and hosted zones for different environments (e.g., dev, prod).
- Exports hosted zone IDs and domain names for cross-stack usage.
The scripts/wireguard-setup.sh script configures the WireGuard server, generates client/server keys, sets up the VPN, and integrates with the malware protection DNS if enabled. It also provides a QR code for easy mobile client configuration.
This project uses a GitHub Actions workflow for automated deployment to AWS. You can trigger the deployment manually from the GitHub Actions tab using the Deploy CDK Stack workflow.
To deploy:
- Go to the Actions tab in your GitHub repository.
- Select the Deploy CDK Stack workflow.
- Click Run workflow and provide:
- The branch to deploy (e.g., main)
- The environment (devorprod)
 
- The branch to deploy (e.g., 
The workflow will handle installing dependencies, configuring AWS credentials, and running the CDK deployment with the appropriate parameters and secrets.
- Install dependencies:
npm install 
- Build the project:
npm run build 
- Deploy to AWS:
- For development:
npx cdk deploy -c config=dev --all --debug 
- For production:
npx cdk deploy -c config=prod --all 
 
- For development:
- npm run buildcompile typescript to js
- npm run watchwatch for changes and compile
- npm run testperform the jest unit tests
- npx cdk deploydeploy this stack to your default AWS account/region
- npx cdk diffcompare deployed stack with current state
- npx cdk synthemits the synthesized CloudFormation template
For more details, see the source code and comments in each stack and script file.
