An open API service indexing awesome lists of open source software.

https://github.com/spacelift-io/terraform-aws-spacelift-workerpool-on-ec2

Terraform module deploying a Spacelift worker pool on AWS EC2 using an autoscaling group
https://github.com/spacelift-io/terraform-aws-spacelift-workerpool-on-ec2

Last synced: 2 months ago
JSON representation

Terraform module deploying a Spacelift worker pool on AWS EC2 using an autoscaling group

Awesome Lists containing this project

README

        

# ☁️ Terraform AWS Spacelift Workerpool On EC2

Terraform module deploying a Spacelift worker pool on AWS EC2 using an autoscaling group.

This module can optionally deploy [a Lambda function](https://github.com/spacelift-io/ec2-workerpool-autoscaler) to auto-scale the worker pool. The function adds or removes workers depending on the worker pool queue length.

> 🚨 **Breaking changes in v3.0.0** 🚨
>
> See the [release notes](https://github.com/spacelift-io/terraform-aws-spacelift-workerpool-on-ec2/releases/tag/v3.0.0) for more information on the breaking changes in v3.0.0.

## ✨ Usage

More examples can be found in the [examples](./examples) directory.

### SaaS

The most important is that you should provide `SPACELIFT_TOKEN` and `SPACELIFT_POOL_PRIVATE_KEY` environmental variables in the `secure_env_vars` variable to the module. More information can be found in the [docs](https://docs.spacelift.io/concepts/worker-pools).

```hcl
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}

provider "aws" {
region = "eu-west-1"
}

module "my_workerpool" {
source = "github.com/spacelift-io/terraform-aws-spacelift-workerpool-on-ec2?ref=v3.0.0"

secure_env_vars = {
SPACELIFT_TOKEN = var.worker_pool_config
SPACELIFT_POOL_PRIVATE_KEY = var.worker_pool_private_key
}
configuration = < ❗️ Previous versions of this module (` Note: the module will parse the `s3_uri` and set `s3:GetObject` IAM permission accordingly. However, if the S3 bucket is KMS encrypted, it will fail. In that case, you can create a custom instance profile for yourself and provide it via the `custom_iam_role_name` variable.

## Default AMI

The default AMI used by this module comes from the [spacelift-worker-image](https://github.com/spacelift-io/spacelift-worker-image)
repository. You can find the full list of AMIs on the [releases](https://github.com/spacelift-io/spacelift-worker-image/releases)
page.

## ARM-based AMI

You can use an ARM-based AMI by setting the `ami_id` variable to an arm64 AMI, and `ec2_instance_type` to an ARM-based instance type (e.g. `t4g.micro`).

We recommend using [Spacelift AMIs](https://github.com/spacelift-io/spacelift-worker-image/releases) because they come with every required tool preinstalled.

You can find an example of ARM-based workerpool in the [examples](./examples/) directory.

>❗️ If you use [custom runner images](https://docs.spacelift.io/concepts/stack/stack-settings.html#runner-image), make sure they support ARM. The default Spacelift images do support it.

## Module registries

The module is also available [on the OpenTofu registry](https://search.opentofu.org/module/spacelift-io/spacelift-workerpool-on-ec2/aws/latest) where you can browse the input and output variables.