This is a submission for the Pulumi Deploy and Document Challenge: Fast Static Website Deployment
What I Built
I created an automated deployment pipeline for a Hugo static website using Pulumi for infrastructure management. The solution uses AWS S3 for hosting and Cloudflare as a CDN, with GitHub Actions handling continuous deployment. This setup provides a fast, secure, and cost-effective way to host static websites.
Live Demo Link
Check out the live site at: https://afkprojects.online
Project Repo
The complete project is available on GitHub: pulumi-hugo-s3
Key features:
- Pulumi TypeScript for infrastructure management
- Hugo static site generator
- AWS S3 for hosting
- Cloudflare CDN integration
- GitHub Actions for CI/CD
- Automated SSL/TLS certificate management
My Journey
The Challenge
I wanted to create a simple but effective deployment pipeline for static websites that would be:
- Cost-effective for small projects
- Easily maintainable
- Secure by default
- Fast to deploy
Implementation
- Used Pulumi to provision AWS S3 infrastructure
- Integrated Cloudflare for CDN and DNS management
- Set up GitHub Actions for automated deployments
- Configured Hugo for static site generation
Challenges Faced
S3 Bucket Permissions: Initially struggled with correct bucket policies and public access settings. Solved by carefully configuring bucket ACLs and ownership controls.
CDN Integration: Chose Cloudflare over AWS CloudFront for better cost efficiency and simpler setup.
Deployment Automation: Created a GitHub Actions workflow that coordinates Hugo builds with Pulumi deployments.
Using Pulumi
Pulumi was instrumental in managing infrastructure as code. Key benefits included:
Type Safety: Using TypeScript provided better error catching and IDE support.
Resource Management: Pulumi handled all AWS and Cloudflare resources consistently:
const websiteBucket = new aws.s3.BucketV2("websiteBucket", {
bucket: config.require("bucketName"),
forceDestroy: true
});
const cloudflareRecord = new cloudflare.Record("cloudflareRecord", {
zoneId: config.require("zoneId"),
name: config.require("domain"),
type: "CNAME",
value: websiteBucketConfiguration.websiteEndpoint,
proxied: true
});
- State Management: Pulumi's state management made it easy to track and update infrastructure changes.
Key Learnings
- Infrastructure as Code principles with Pulumi
- AWS S3 static website hosting configuration
- CDN integration and DNS management
- CI/CD pipeline setup with GitHub Actions
The project demonstrates how modern IaC tools like Pulumi can simplify complex deployments while maintaining security and performance.