Our Terraform module runs DocSpring Enterprise in your own AWS account on Amazon ECS with Fargate, so there are no
servers or Kubernetes cluster to manage. It works with Terraform or OpenTofu 1.6 or later. The module and its full
guide are in the aws-ecs folder of
DocSpring/docspring-enterprise.
What it creates
Section titled “What it creates”- A VPC with public and private subnets across two or three availability zones, or it uses your existing VPC.
- RDS PostgreSQL 17, encrypted, with 7 days of point-in-time recovery.
- ElastiCache Valkey (compatible with Redis), with TLS.
- A private, versioned, encrypted S3 bucket for files.
- An Application Load Balancer with HTTPS, using your ACM certificate or one it creates in your Route 53 zone.
- The
web,workerandworker_gjservices on Fargate, on Graviton (arm64) by default, with autoscaling. - The release command, and the three scheduled tasks on EventBridge Scheduler.
- The secrets in Secrets Manager, and IAM roles that can reach only what DocSpring needs.
With the defaults, it costs about $280 to $300 a month in us-east-1, plus data transfer. The module’s README breaks that down.
What you need
Section titled “What you need”- Terraform or OpenTofu 1.6 or later, and the AWS CLI v2, signed in with IAM Identity Center or a role that can create the resources above.
- Your license key and Docker Hub credentials, which we email you.
- A DNS name for DocSpring, with a Route 53 hosted zone or an ACM certificate for it.
- An email provider.
Install
Section titled “Install”- Copy the module’s
examplefolder, copyterraform.tfvars.exampletoterraform.tfvars, and fill it in: the region, your domain, the image version, your license key, the Docker Hub credentials and the first admin’s email address and password. Keepterraform.tfvarsout of version control. - Store the Terraform state in an encrypted S3 bucket that only your administrators can read: it holds the secrets the module generates, including the encryption key.
- Run
terraform initandterraform apply. It takes 15 to 20 minutes, mostly for RDS and ElastiCache. - Run the deploy command that
terraform output deploy_commandprints. It runs the release command, which creates the database schema and the admin user, then starts the services on that release and waits until they’re healthy. - Copy
DOCSPRING_SUBMISSION_DATA_ENCRYPTION_KEYfrom the app’s secret in Secrets Manager to somewhere outside AWS, such as your password manager. Without it, the data DocSpring stores can’t be read.
Then open your domain, sign in and change the admin password.
Settings
Section titled “Settings”Add settings that aren’t secret to extra_environment, and secret ones, such as an email provider’s token, to
extra_secrets. After changing them, run terraform apply and then the deploy command, so the tasks restart with
them. The tasks use their IAM role for S3, so there are no access keys to manage.
Upgrade
Section titled “Upgrade”- Read the release notes of the new version.
- Set
image_taginterraform.tfvarsand runterraform apply. This registers the new release’s task definitions without changing what’s running. - Run the deploy command. It runs the release command on the new release, and only if that succeeds moves the services and then the scheduled tasks to it. If a service’s rollout fails, ECS rolls it back.
To go back to the previous release, set image_tag back, apply and deploy again.
Notes for Fargate
Section titled “Notes for Fargate”- Fargate doesn’t let containers add the
NET_ADMINcapability, so the containers can’t add their firewall rule for the cloud metadata address, and log a warning at startup. Fargate tasks can’t reach that address anyway: their credentials come from the ECS task role. If your policies require the firewall rule, run the tasks on ECS with EC2 instances instead. - Fargate gives a stopping task at most 120 seconds, so a
webrequest that runs longer than that during a deploy is cut off. - Fargate doesn’t cache images, so every task that starts pulls the image, including each scheduled task run. An ECR pull-through cache cuts the NAT data charges: the module’s README explains how.
- For a shell or Rails console in a running task, use ECS Exec:
terraform output ecs_exec_command, thenrun_as_deploy rails console.