Deploying to ECS»
This guide provides a way to quickly get Spacelift up and running on an Elastic Compute Service (ECS) Fargate cluster. In this guide we show a relatively simple networking setup where Spacelift is accessible via a public load balancer, but you can adjust this as long as you meet the basic networking requirements for Spacelift.
To deploy Spacelift on ECS you need to take the following steps:
- Deploy your basic infrastructure components.
- Push the Spacelift images to your Elastic Container Registry.
- Deploy the Spacelift backend services using our ECS Terraform module.
Overview»
The illustration below shows what the infrastructure looks like when running Spacelift in ECS.
Networking»
Info
More details regarding networking requirements for Spacelift can be found on this page.
This section will solely focus on how the ECS infrastructure will be configured to meet Spacelift's requirements.
In this guide we'll create a new VPC with public and private subnets. The public subnets will contain the following items to allow communication between Spacelift and the external internet:
- An Application Load Balancer to allow inbound HTTPS traffic to reach the Spacelift server instances.
- A Network Load Balancer to allow inbound MQTT traffic to reach the Spacelift server instances.
- An Internet Gateway to allow inbound access to those load balancers.
- A NAT Gateway to allow egress traffic from the Spacelift services.
The private subnets contain the Spacelift RDS Postgres database, along with the Spacelift ECS services and are not directly accessible via the internet.
Object Storage»
The Spacelift instance needs an object storage backend to store Terraform state files, run logs, and other things. Several S3 buckets will be created in this guide. This is a hard requirement for running Spacelift.
Spacelift uses the AWS SDK default credential provider chain for S3 authentication, supporting environment variables, shared credential files and IAM roles for ECS. More details about object storage requirements and authentication can be found here.
Database»
Spacelift requires a PostgreSQL database to operate. In this guide we'll create a new Aurora Serverless RDS instance. You can also reuse an existing instance and create a new database in it. In that case you'll have to adjust the database URL and other settings across the guide. It's also up to you to configure appropriate networking to expose this database to Spacelift's VPC.
You can switch the create_database option to false in the terraform module to disable creating an RDS instance.
More details about database requirements for Spacelift can be found here.
If you need to run SQL against the database for troubleshooting or maintenance, you can enable the RDS Data API by setting rds_enable_http_endpoint = true on the terraform-aws-spacelift-selfhosted module. This unlocks the query editor in the RDS console, so you can query the database from the AWS console without standing up a bastion host or a local client.
Warning
Enabling the Data API exposes the database over an IAM-authenticated HTTPS endpoint instead of keeping it reachable only from within the VPC. Consider the security implications before turning it on, and scope the relevant IAM permissions (rds-data:* and access to the database secret) tightly to the people who genuinely need them. To keep the exposure window small, you can enable it only when you need it (including directly in the RDS console), run your queries, and disable it again afterwards. The Data API is only available for Aurora Serverless v2 and provisioned clusters in supported regions.
ECS»
In this guide, we'll deploy a new ECS Fargate cluster to run Spacelift. The Spacelift application can be deployed using the terraform-aws-ecs-spacelift-selfhosted Terraform module.
The Terraform module will deploy the ECS cluster, associated resources like IAM roles, and the following Spacelift services:
- The scheduler.
- The drain.
- The server.
The scheduler is the component that handles recurring tasks. It creates new entries in a message queue when a new task needs to be performed.
The drain is an async background processing component that picks up items from the queue and processes events.
The server hosts the Spacelift GraphQL API, REST API and serves the embedded frontend assets. It also contains the MQTT server to handle interactions with workers. The server is exposed to the outside world using an Application Load Balancer for HTTP traffic, and a Network Load Balancer for MQTT traffic.
Workers»
In this guide Spacelift workers will be deployed as an EC2 autoscaling group, using the terraform-aws-spacelift-workerpool-on-ec2 Terraform module.
Requirements»
Before proceeding with the next steps, the following tools must be installed on your computer.
- AWS CLI v2.
- Docker.
- OpenTofu or Terraform.
Info
In the following sections of the guide, OpenTofu will be used to deploy the infrastructure needed for Spacelift. If you are using Terraform, simply swap tofu for terraform.
Server certificate»
To be able to reach your Spacelift installation using HTTPS, we need a valid certificate to serve it under secure endpoints. Before jumping into deploying Spacelift, we first need to create a valid ACM certificate.
We are going to use DNS validation to make sure the issued certificate is valid, so you need to have access to your DNS zone to add to it the ACM certificate validation CNAME entries.
The Spacelift infrastructure module will take as an input an ACM certificate ARN. You can either create one yourself manually or use the OpenTofu code snippets below to help you create one.
You can apply the following snippet of OpenTofu code with a credentials set allowed to configure your route53 zone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
You can apply the following snippet of OpenTofu code and then just go to your Route53 console to create the DNS entries specified in the output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
1 2 3 4 5 6 7 8 9 10 11 12 | |
Deploy infrastructure»
We provide Terraform modules to deploy Spacelift's infrastructure requirements as well as a module to deploy the Spacelift services to ECS.
Some parts of these modules can be customized to avoid deploying parts of the infra in case you want to handle that yourself. For example, you may want to disable the database if you already have a Postgres instance and want to reuse it, or you may want to provide your own IAM roles or enable CloudWatch logging.
Before you start, set a few environment variables that will be used by the Spacelift modules:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Note
The admin login/password combination is only used for the very first login to the Spacelift instance. It can be removed after the initial setup. More information can be found in the initial setup section.
Below is an example of how to use these modules:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
Feel free to take a look at the documentation for the terraform-aws-ecs-spacelift-selfhosted module before applying your infrastructure in case there are any settings that you wish to adjust. Once you are ready, apply your changes:
1 | |
Once applied, you should grab all variables that need to be exported in the shell that will be used in next steps. We expose a shell output in terraform that you can source directly for convenience.
1 2 3 4 5 6 | |
Info
During this guide you'll export shell variables that will be useful in future steps. So please keep the same shell open for the entire guide.
Push images to Elastic Container Registry»
Assuming you have sourced the shell output as described in the previous section, you can run the following commands to upload the container images to your container registries and the launcher binary to the binaries S3 bucket:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Deploy Spacelift»
In this section, we'll deploy the Spacelift services to your ECS cluster, and then deploy an initial worker pool.
Deploy application»
To deploy the services, set the following environment variable to enable the services module to be deployed:
1 | |
Now go ahead and run tofu apply again to deploy the ECS cluster and services.
Once this module has been applied successfully, you should be able to setup DNS entries for the server and MQTT broker endpoints using the server_lb_dns_name and mqtt_lb_dns_name outputs.
Configure your DNS zone»
You need to set two CNAMEs in your DNS zone. One for the main application and one for the MQTT endpoint for the workers.
You can add the following entries to your OpenTofu code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
1 2 3 4 5 6 7 | |
VCS Gateway Service»
Ideally, your VCS provider should be accessible from both the Spacelift backend and its workers. If direct access is not possible, you can use VCS Agent Pools to proxy the connections from the Spacelift backend to your VCS provider.
The VCS Agent Pool architecture introduces a separate ECS service, deployed alongside the Spacelift backend, and exposed via a dedicated Application Load Balancer. This load balancer listens on port 443 and requires a valid TLS certificate to be attached to it.
To support this setup, extend your module configuration with the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Don't forget to set up the DNS record for the VCS Gateway service, pointing to the load balancer's DNS name:
1 2 3 4 5 6 7 | |
With the backend now configured, proceed to the VCS Agent Pools guide to complete the setup.
Next steps»
Now that your Spacelift installation is up and running, take a look at the initial installation section for the next steps to take.
Create a worker pool»
This section will show you how to deploy an EC2 based worker using our terraform-aws-spacelift-workerpool-on-ec2 module.
The first step is to follow the instructions in our worker pool documentation to generate credentials for your worker pool, and to create a new pool in Spacelift.
Once you have a private key and token for your worker pool, set the following Terraform variables:
1 2 3 4 5 6 7 8 9 10 | |
Next, you can use the following code to deploy your worker pool. Note that this deploys the workers into the same VPC as Spacelift, but this is not required for the workers to function. Please refer to the worker network requirements for more details if you wish to adjust this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
Deletion / uninstall»
Before running tofu destroy on the infrastructure, you may want to set the following properties for the terraform-aws-spacelift-selfhosted module to allow the RDS, ECR and S3 resources to be cleaned up properly:
1 2 3 4 5 6 7 8 9 10 | |
Remember to apply those changes before running tofu destroy.

