This project is an experiment for deploying a static Next.js app to OVHcloud Object Storage using Terraform. It's a playground for cloud, infra-as-code, and static hosting. 😸
- Next.js app for the frontend
- Terraform for managing OVHcloud resources
- CDN for global content delivery and caching
- Makefile for easy commands
.
├── nextjs-app/ # Your Next.js frontend app
├── terraform/ # Terraform config for OVHcloud infra
├── Makefile # Root orchestrator for all tasks
├── README.md # This file
- Node.js & npm (official site or fnm on Homebrew)
- Terraform (Homebrew)
- AWS CLI for uploading (official site)
The following steps will take you through a simple flow to set up and deploy a static app to a bucket in OVHcloud.
-
Configure Terraform Variables
- Copy the example secrets file:
cp terraform/secrets.tfvars.example terraform/secrets.tfvars
- Get your API key from OVH Cloud
- Enter your OVHcloud API credentials in
terraform/secrets.tfvars
. - CDN cache rules in
terraform/cdn_cache_rules.tf
if you want to customize caching behavior. - The default CDN domain provided by OVHcloud will be shown in the Terraform outputs after deployment.
- Copy the example secrets file:
-
Initialize Terraform
make tf-init
-
Install Next.js App Dependencies
make app-install
-
Plan and Apply Terraform
make tf-plan # See what will be created make tf-apply # Actually create the resources
-
Build the (static) Next.js App
make app-build
-
Setup OVHcloud AWS CLI profile for uploading
make setup-profile
-
Deploy to OVHcloud
make deploy
Run these from the project root:
make tf-init
– Initialize Terraformmake tf-plan
– Preview Terraform changesmake tf-apply
– Apply Terraform changesmake tf-destroy
– Destroy all Terraform-managed resourcesmake app-install
– Install Next.js dependenciesmake app-build
– Build the Next.js appmake app-dev
– Run the Next.js dev servermake setup-profile
– Set up the AWS profile to deploy the appmake deploy
– Deploy the application to OVHcloud Object Storage
The CDN provides several advantages over serving directly from S3:
- Usual CDN advantages: Content caching, DDos Protection, faster loading
- Content Mapping: The CDN will map item with extensions to friendly urls:
/index.html
>/
The CDN is configured with optimized cache rules, which you can edit in terraform/cdn_cache_rules.tf
. You can add, remove, or change rules in that file to fit your needs.
- OVHcloud will provide a default CDN domain for you (see Terraform outputs after deployment).
- SST is awesome for AWS Lambda/serverless, but doesn't support OVHcloud or S3-compatible object storage as a first-class target. It's overkill for a static site on OVHcloud and some of the best features (like
sst.aws.Nextjs
in our case) aren't supported for OVHcloud. SST is designed for serverless architectures with Lambda, API Gateway, and other AWS services - perfect for dynamic apps but unnecessary complexity for a static site that just needs object storage. - Pulumi requires a Pulumi Cloud account and backend service for state management (unlike Terraform which can work locally with local state files). The OVHcloud provider is not as mature or well-documented as Terraform's. For simple, reproducible infra, Terraform is the most reliable and community-supported option for OVHcloud right now.
- Terraform is boring, but boring is good when you want your infra to just work. 😎