Skip to content

add ecs agent install/uninstall/status commands with --max-learning-period#32

Closed
matthyx wants to merge 3 commits into
mainfrom
ecs-agent-install
Closed

add ecs agent install/uninstall/status commands with --max-learning-period#32
matthyx wants to merge 3 commits into
mainfrom
ecs-agent-install

Conversation

@matthyx

@matthyx matthyx commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds armoctl ecs agent install/uninstall/status commands mirroring the existing ecs operator pattern
  • Embeds the ECS agent CloudFormation template (from private-node-agent) so armoctl can deploy it directly
  • install exposes --max-learning-period to set the agent's maximum container learning period at deploy time

Usage

# Install with default learning period (24h)
armoctl ecs agent install -c arn:aws:ecs:us-east-1:123456789:cluster/my-cluster

# Install with custom learning period
armoctl ecs agent install -c arn:aws:ecs:us-east-1:123456789:cluster/my-cluster --max-learning-period 6h

# Check status
armoctl ecs agent status -c arn:aws:ecs:us-east-1:123456789:cluster/my-cluster

# Uninstall
armoctl ecs agent uninstall -c arn:aws:ecs:us-east-1:123456789:cluster/my-cluster -y

Test plan

  • armoctl ecs agent install deploys the CloudFormation stack successfully
  • --max-learning-period 5m is passed through to the stack parameter
  • armoctl ecs agent status shows stack status and ARNs
  • armoctl ecs agent uninstall -y deletes the stack

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added armoctl ecs agent install command to deploy ARMO agent and operator to ECS clusters via CloudFormation, with configurable cluster selection, CloudWatch logging, and learning period settings.
    • Added armoctl ecs agent status command to check deployment status, including stack health, resource ARNs, and failed event details with colorized status display.
    • Added armoctl ecs agent uninstall command to remove deployments with confirmation prompts.

Review Change Stack

Copilot AI review requested due to automatic review settings May 13, 2026 10:45
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: a671a0bb-237b-4c4f-9721-ddf8b2608c8d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces a complete ECS agent installation and management CLI feature. It adds an install subcommand for deploying ARMO agents via CloudFormation, a status subcommand for checking stack health, and an uninstall subcommand for cleanup. The implementation includes CloudFormation stack orchestration with polling, ARN validation, and a parametrized YAML template that deploys an agent daemon service and operator replica service to ECS clusters.

Changes

ECS Agent Installation and Management

Layer / File(s) Summary
Agent CLI foundation
ecs/agent/agent.go
AgentCmd parent command, ECS cluster ARN parsing with validation (parseClusterARN), stack name generation, and authentication enforcement.
CloudFormation stack orchestration
ecs/agent/cloudformation.go
AWS SDK client creation, StackParams and StackOutput contracts, stack create/delete/describe operations, 5-second polling loops with progress callbacks, and failed event extraction for error reporting.
CloudFormation template asset
ecs/agent/template.go, ecs/agent/template.yaml
Embedded YAML template defining IAM roles, ECS agent daemon and operator replica services, task definitions with host networking and mounted volumes, conditional CloudWatch logging and learning period tuning, and output exports for created resource ARNs.
Install subcommand
ecs/agent/install.go
armoctl ecs agent install command with required --cluster and optional flags for CloudWatch logs, stack name, and max learning period. Orchestrates authentication, parameter construction, stack creation, and polling with progress output.
Status subcommand
ecs/agent/status.go
armoctl ecs agent status command that describes CloudFormation stacks, prints colorized status, and conditionally reports failed resource events on rollback/failure.
Uninstall subcommand
ecs/agent/uninstall.go
armoctl ecs agent uninstall command with optional confirmation prompt, CloudFormation stack deletion, and deletion polling with status output.
CLI command registration
ecs/ecs.go
Imports and registers the agent parent command under the top-level ECS CLI.

🐰 A cluster comes alive,
Daemon and operator dance,
CloudFormation builds—
Stack by stack, agents rise,
Safety woven in the cloud. 🌩️


🎯 3 (Moderate) | ⏱️ ~25 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new armoctl ecs agent command group that deploys and manages an ECS Agent (daemon) plus an ECS Operator (single replica) via an embedded CloudFormation template, mirroring the existing ecs operator UX and flow. It also introduces a --max-learning-period install flag that is passed through to the agent as a stack parameter/environment variable.

Changes:

  • Add armoctl ecs agent install|status|uninstall subcommands under the existing ecs root command.
  • Embed and deploy a CloudFormation template for agent + operator, including a MaxLearningPeriod parameter.
  • Add CloudFormation helpers to create/describe/delete stacks and wait on stack lifecycle.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ecs/ecs.go Registers the new ecs agent command under the existing ECS command tree.
ecs/agent/agent.go Introduces AgentCmd, default stack naming, and ECS cluster ARN parsing utilities.
ecs/agent/install.go Implements ecs agent install, including --max-learning-period passthrough and stack creation/wait.
ecs/agent/status.go Implements ecs agent status with colored status output and failed-resource listing.
ecs/agent/uninstall.go Implements ecs agent uninstall with confirmation prompt and stack deletion/wait.
ecs/agent/cloudformation.go Adds CloudFormation client helpers for stack CRUD, polling, and failed event retrieval.
ecs/agent/template.go Embeds the CloudFormation YAML into the binary.
ecs/agent/template.yaml Defines IAM roles, agent daemon service/task, operator service/task, parameters, and outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ecs/agent/install.go
Comment on lines +58 to +70
cloudwatchLogs, _ := cmd.Flags().GetString("cloudwatch-logs")
maxLearningPeriod, _ := cmd.Flags().GetString("max-learning-period")

params := StackParams{
StackName: stackName,
Region: cluster.Region,
ClusterName: cluster.ClusterName,
CustomerGUID: viper.GetString("customer-guid"),
AccessKey: viper.GetString("access-key"),
APIUrl: viper.GetString("api-url"),
CloudWatchLogs: cloudwatchLogs,
MaxLearningPeriod: maxLearningPeriod,
}
Comment thread ecs/agent/agent.go Outdated
Comment on lines +64 to +66
// defaultStackName returns the default CloudFormation stack name for a cluster.
func defaultStackName(clusterName string) string {
return StackNamePrefix + clusterName
Comment thread ecs/agent/uninstall.go Outdated
Comment on lines +18 to +19
- The ECS Agent daemon service
- The ECS Operator service
Comment thread ecs/agent/template.yaml Outdated
- Name: API_URL
Value: !Ref ApiUrl
- Name: KS_LOGGER_LEVEL
Value: debug
…iod support

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@matthyx
matthyx force-pushed the ecs-agent-install branch from 60ec451 to 1776aff Compare May 13, 2026 14:29
matthyx and others added 2 commits May 13, 2026 18:55
…eployment

- Add requireAuth() guard to install so empty credentials are caught before
  any AWS call is made
- Replace shell-command printer with AWS SDK CreateStack + polling wait,
  eliminating the access-key leak into shell history and terminal logs
- Add status and uninstall subcommands (CloudFormation describe / delete +
  wait, colour-coded output, failure diagnostics with CloudWatch log tail)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@YakirOren YakirOren closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants