🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

ecs-rails

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecs-rails

bundlerRubygems
Version
0.0.8
Version published
Maintainers
1
Created
Source

If you are hosting your Rails app on ECS Fargate and want to connect to the Rails console or launch a bash session, you need to use AWS cli like so :

aws ecs execute-command --region eu-west-3 --cluster CLUSTER_ARN --task TASK_ARN --container CONTAINER_NAME --command 'bundle exec rails console' --interactive

This gem helps to get the correct cluster arn and task id so that you don't have to get them yourself.

ecs console
ecs bash
ecs logs
ecs scale

Installation

Install AWS cli

Install AWS Session Manager plugin

Install gem

gem install 'ecs-rails'

Configuration

environment variables

Via environment variables:

export ENV['AWS_REGION'] = 'us-east-1'
export ENV['AWS_ACCESS_KEY_ID'] = 'your-access-key-id'
export ENV['AWS_SECRET_ACCESS_KEY'] = 'your-secret-access-key'
export ENV['CONTAINER_NAME'] = 'your-container-name'

AWS SSO

aws sso login

Usage

Console

Connect to Rails console on a running Task.

ecs console

Select a cluster:
1) cluster-prod
2) cluster-staging
Choose 1-2 [1]:

Select a service:
1) app
2) worker
Choose 1-2 [1]:

irb(main)>

You can specify cluster name via -c option by giving a string included in cluster arn. You can specify service name via -s option by giving a string included in service arn.

# with cluster name: webapp-cluster-prod-e950a13
# with service name: webapp-app-prod-7c7cad7
ecs console -c prod -s app
irb(main)>

Bash

Connect to bash session on a running Task.

ecs bash -c prod -s app
bash-4.2#

Logs

Tail CloudWatch logs for a service.

ecs logs -c prod -s app

Fetching log group from task definition...
Log group: webapp-app-log-group-prod-827a419
Executing command: aws logs tail webapp-app-log-group-prod-827a419 --region us-east-1 --follow --format short

The logs command will:

  • Automatically discover the CloudWatch log group from your ECS task definition
  • Tail logs in real-time with --follow flag
  • Display logs in a short, readable format
  • Press Ctrl-C to exit

Scale

View the current scaling status of a service (refreshes every 5 seconds):

ecs scale -c prod -s app

Press Ctrl-C to exit

Fetching service status... (refreshes every 5 seconds)

Service: webapp-app-prod-7c7cad7
Cluster: webapp-cluster-prod
Status: ACTIVE

Task counts:
  Desired: 2
  Running: 2
  Pending: 0

Scale a service up or down by changing the desired task count:

ecs scale -c prod -s app --count 5

Fetching service status...
Current desired count: 2
Scaling service 'webapp-app-prod-7c7cad7' to 5 tasks...
âś“ Service scaled successfully!
New desired count: 5

The scale command will:

  • Without --count: Show the current status including desired, running, and pending task counts, refreshing every 5 seconds. Press Ctrl-C to exit.
  • With --count: Update the service's desired count to the specified number and confirm the operation

FAQs

Package last updated on 16 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts