Skip to main content
Type: rvn-ecs-worker / Latest version: 2.6.0

Dependencies and consumers

Every dependency input can be specified manually to reference existing external infrastructure rather than a Ravion module. Set the dependency input to null and set its mapped inputs directly; see Use existing infrastructure instead of a module reference.

Readme

Rolling deployment success

Rolling deploys always use AWS early success: by default, 100% of desired new tasks must be healthy and old tasks drain in the background. Wait for old tasks to drain selects blocking cleanup. Alarm bake time still applies. The success percentage must be at least Minimum healthy percent; lower the availability floor explicitly before choosing a lower threshold. Remaining tasks scale in the background and deployment rollback monitoring ends at ECS success. Background worker ECS service for running private container workloads without exposed ports.

Overview

The ECS Worker module creates an ECS service for background jobs, queue consumers, event processors, and other private workloads in an existing Ravion ECS cluster. It uses the same ECS service Terraform module as ECS Web Server, but does not create or attach a load balancer target group and does not expose a primary container port. Terraform source: ravionhq/modules/compute/ecs_service

Use cases

Networking

Workers do not expose a primary app port and are not registered with an Application Load Balancer. Run in private subnets is enabled by default so tasks stay private while using NAT or equivalent egress for outbound dependencies. Sidecars may still define port mappings for task-local agents, proxies, or helper containers. Those sidecar ports are not exposed through a load balancer by this module.

Build and deployment

Workers support Dockerfile, Railpack, Managed ECR repository, and Pull from image registry deployments. Deployments update the ECS service task definition with the selected image, generated container definition, logs, runtime environment variables, secrets, IAM roles, volumes, sidecars, and selected capacity provider settings. For Railpack builds, you can optionally pin the Railpack version and override install, build, and start commands. For Fargate and Fargate Spot, App ephemeral storage uses the AWS default of 20 GiB unless you increase it to 21-200 GiB. For Managed ECR repository, Ravion creates and manages the service ECR repository. Push the image from a pipeline build:image step, then provide its tag or digest at deploy time.

Override the start command

For Dockerfile, Pull from image registry, and Managed ECR repository builds, use Start command (image_start_command) to override the image’s CMD without changing its ENTRYPOINT. Leave it empty to keep the image default. Set a different command for each service to reuse one Dockerfile for your web app and background workers. Pass each argument as a separate array item, for example image_start_command: ["npm", "run", "start:worker"]. For Railpack builds, use Railpack start command instead.

Persistent storage

Enable the EFS file system setting, select a Ravion EFS module, and set the EFS mount path. Ravion adds the task volume, mounts it into the worker container, attaches the file system’s client security group to the service so NFS traffic is allowed, and mounts through the file system’s access point when one is enabled. Sidecars mount the same file system through their Mount points setting with efs as the source volume. EFS volumes work with Fargate and EC2 Linux tasks and keep data across task replacement. Transit encryption is enabled by default. Enable EFS IAM authorization to authorize file system access with the task role; the task role must allow elasticfilesystem:ClientMount, plus elasticfilesystem:ClientWrite or elasticfilesystem:ClientRootAccess as needed.

Autoscaling

Autoscaling is enabled by default with CPU and memory target tracking. Use custom metric scaling policies for queue depth, lag, backlog, or other workload-specific metrics that better represent worker demand. When autoscaling is disabled, Desired tasks controls how many worker tasks the ECS service keeps running. To stop the service without deleting it, keep autoscaling enabled and set Minimum tasks and Maximum tasks to 0. ECS scales the running tasks in to 0 while the service, load balancer routing, roles, and image repository stay in place. Deploys while stopped keep the task count at 0. Set the bounds back above 0 to start the service again. Scheduled scaling actions still apply, so remove or adjust any that would raise the bounds while the service should stay stopped.

Compliance

The Compliance section holds log retention and CloudWatch alarms. Log retention (days) defaults to the value configured on the ECS cluster’s Compliance section, so one cluster setting keeps every service consistent. Set a value here to override it for this service. Use 0 to retain logs indefinitely. CloudWatch alarms are enabled by default for average CPU utilization, average memory utilization, and running task count. Worker services have no load balancer, so only the service-level alarms apply. The running task alarm uses the Container Insights RunningTaskCount metric and stays silent when Container Insights is disabled on the cluster. Every alarm treats missing data as not breaching and must breach for the configured number of consecutive periods before it fires. Add SNS topic ARNs as Alarm actions and OK actions to be notified.

Application configuration

Use Runtime environment variables for plain values, as an array of {name, value} objects. Use Deploy-provided environment variables to allow a pipeline deploy step to set selected plain values. They cannot replace a Runtime environment variable or Runtime secret. Use Runtime secrets for sensitive values, as an array of {name, value_from} objects. value_from is an SSM Parameter Store or Secrets Manager ARN.

Configuration

Design decisions

  • The module intentionally creates an ECS service without load balancer attachment or primary container port mappings.
  • Sidecar port mappings are allowed for task-local communication, agents, and proxies.
  • The service uses the autoscaling minimum when autoscaling is enabled and the Desired tasks input when autoscaling is disabled.
  • Advanced Terraform variables exist for exceptional lower-level overrides. Prefer the typed Ravion fields whenever possible.

Learn more

Inputs reference

All inputs for rvn-ecs-worker version 2.6.0. Use the name shown for each field as the input key in module config.