Deploying Boundary workers for short-term tasks or testing is cumbersome. I built a Terraform module to handle ephemeral worker deployments on AWS ECS Fargate.
The module configures the worker as a public target, handles HCP Boundary cluster attachment, and cleans up resources on destroy. It's designed for integration into CI/CD pipelines or temporary access scenarios.
```hcl
module "boundary_ephemeral_worker" {
source = "github.com/.../terraform-aws-boundary-worker?ref=v1.0"
hcp_boundary_cluster_id = var.cluster_id
vpc_id = aws_vpc.main.id
subnet_ids = aws_subnet.public.*.id
worker_tags = {
Purpose = "LoadTest_202405"
}
}
```
Primary use case is creating workers for specific data pipeline stages requiring privileged access, then terminating them post-execution. The module sets the necessary security groups, IAM roles, and registers the worker with the control plane.