AgentSkillsCN

aws-cli-ecs

在使用AWS ECS命令时——集群、服务、任务、任务定义、容器实例、容量提供商、部署。在创建或管理ECS集群、部署与更新ECS服务、运行独立或计划任务、注册与管理任务定义、管理容器实例(EC2启动类型)、配置容量提供商与自动扩展,或监控部署与服务事件时使用此技能。

SKILL.md
--- frontmatter
name: aws-cli-ecs
description: Use when working with AWS ECS commands — clusters, services, tasks, task definitions, container instances, capacity providers, deployments. Use this skill when creating or managing ECS clusters, deploying and updating ECS services, running standalone or scheduled tasks, registering and managing task definitions, managing container instances (EC2 launch type), configuring capacity providers and auto scaling, or monitoring deployments and service events.

AWS CLI v2 — ECS (Elastic Container Service)

Overview

Complete reference for all aws ecs subcommands in AWS CLI v2. Covers cluster management, service orchestration, task execution, task definition registration, container instance management, and capacity providers.

Quick Reference — Common Workflows

Create a cluster

bash
aws ecs create-cluster --cluster-name my-cluster \
  --capacity-providers my-asg-cp \
  --default-capacity-provider-strategy capacityProvider=my-asg-cp,weight=1

Register a task definition

bash
aws ecs register-task-definition --cli-input-json file://task-def.json

Create a service

bash
aws ecs create-service --cluster my-cluster --service-name my-service \
  --task-definition my-task:1 --desired-count 2 \
  --launch-type EC2

Run a standalone task

bash
aws ecs run-task --cluster my-cluster --task-definition my-task:1 \
  --count 1 --launch-type EC2

Update service (deploy new task def revision)

bash
aws ecs update-service --cluster my-cluster --service-name my-service \
  --task-definition my-task:2
aws ecs wait services-stable --cluster my-cluster --services my-service

List container instances and drain

bash
aws ecs list-container-instances --cluster my-cluster --query 'containerInstanceArns'
aws ecs update-container-instances-state --cluster my-cluster \
  --container-instances arn:aws:ecs:... --status DRAINING

Create capacity provider linked to ASG

bash
aws ecs create-capacity-provider --name my-asg-cp \
  --auto-scaling-group-provider autoScalingGroupArn=arn:aws:autoscaling:...,managedScaling={status=ENABLED,targetCapacity=80},managedTerminationProtection=ENABLED

Command Reference

See references/index.md for the quick reference table and global options.

GroupFileCommands
Clustersclusters.mdcreate-cluster, delete-cluster, describe-clusters, list-clusters, update-cluster, update-cluster-settings, put-cluster-capacity-providers
Servicesservices.mdcreate-service, delete-service, describe-services, list-services, update-service, update-service-primary-task-set
Taskstasks.mdrun-task, start-task, stop-task, describe-tasks, list-tasks
Task Definitionstask-definitions.mdregister-task-definition, deregister-task-definition, describe-task-definition, list-task-definitions, list-task-definition-families, delete-task-definitions
Container Instancescontainer-instances.mdregister-container-instance, deregister-container-instance, describe-container-instances, list-container-instances, update-container-instances-state, update-container-agent
Capacity Providerscapacity-providers.mdcreate-capacity-provider, delete-capacity-provider, describe-capacity-providers, update-capacity-provider
Task Setstask-sets.mdcreate-task-set, delete-task-set, describe-task-sets, update-task-set
Account Settingsaccount-settings.mdlist-account-settings, put-account-setting, put-account-setting-default, delete-account-setting
Service Deploymentsservice-deployments.mdlist-service-deployments, describe-service-deployments, describe-service-revisions
Tagstags.mdtag-resource, untag-resource, list-tags-for-resource
Attributesattributes.mdput-attributes, delete-attributes, list-attributes
Execute Commandexecute-command.mdexecute-command
Task Protectiontask-protection.mdget-task-protection, update-task-protection