AWS Worker Pool Not Displaying Active Members in Spacelift despite Availability on Console
You’ve encountered a situation where your private worker pool, created via Terraform for AWSSpacelift WorkerPool, shows as having 0 workers in the Spacelift dashboard, even though it appears on AWS Console under EC2 instances. This could be due to incorrect variable settings during Terraform execution or configuration file parsing errors.
Here’s what you should verify and set correctly:
-
SPACELIFT_TOKEN - Ensure the token from your initial worker pool creation (usually found in
worker-pool-x.config
) is being passed properly, which acts as a key to authenticate with Spacelift API for deploying workers on EC2 instances created by Terraform scripts.Include:
variable "SPACELIFT_TOKEN" { description = "Token received from the worker pool creation." type = string sensitive = true # if token is secret and should not be exposed in plain text within code repositories. }
-
Private Key - Validate that your private key’s content, converted into base64 format (using
base64
command-line tool), aligns with what Spacelift expects for SSH access to worker instances:Include this in the Terraform code or set as an environment variable before running it. For Mac users replace
| base64 -b
:export SPACELIFT_PRIVATE_KEY=$(cat spacelift-key | /usr/bin/base64 --decode)
-
TF Variables: Assign correct values for the below variables by extracting them from Spacelift’s interface, or set via environment variable as suggested above (prefixed with
TF_VAR
):TF_VAR_worker_pool_id
: Worker pool identifier found on your worker page in AWS Console.TF_VAR_spacelift_api_key_endpoint
,TF_VAR_spacelift_api_key_secret
and their respective keys, to set up Spacelift API authentication parameters with the secret key obtained when creating an account-specific new Key.- Copy your private config file content as a string into:
TF_VAR_worker_pool_config
. This is synonymous to SPACELIFT_TOKEN previously discussed and essential for worker pool configurations.
-
Security Groups & Subnets (
TF_VAR_security_groups
,TF02
): Confirm these are assigned correctly as per your network setup, allowing SSH access from EC2 instances into the Spacelift environment where workers operate (usually designated by private IP addresses). -
Properly Running Terraform Code: Ensure that you’ve properly run or reran
terraform apply
with required variables set before attempting to launch your worker pool in AWS EC2 instances under Spacelift control and observe workers being displayed correctly thereafter on the dashboard, confirming successful deployment.
Make these corrections carefully; incorrect configurations may hinder Terraform’s ability or block it from executing properly due to authentication errors with API keys used by Spacelift services for managing EC2 instances tied up as worker nodes within your pool setup in AWS CloudFormation orchestrated via HCL (HashiCorp Configuration Language).