К основному содержанию
скилл CX Codex

aws-cloudformation-ecs — скилл для Claude Code: установка

Скилл aws-cloudformation-ecs генерирует готовые шаблоны CloudFormation для кластеров Amazon ECS, задач Fargate и сервисов за балансировщиком нагрузки.

MIT ★ 372 обновлён 2026-09-10

Установить в Claude Code · Через маркетплейс плагинов Все способы и платформы ↓
/plugin marketplace add giuseppe-trisciuoglio/developer-kit
/plugin install developer-kit-aws@developer-kit
Открыть на GitHub

Что делает aws-cloudformation-ecs

Скилл содержит готовые фрагменты CloudFormation для описания инфраструктуры Amazon ECS. Он помогает составить параметры стека, объявить кластер с поддержкой Container Insights и настроить TaskDefinition с нужными лимитами процессора, оперативной памяти и сетевым режимом awsvpc.

Внутрь шаблона добавляются роли IAM для исполнения задач, параметры сервиса за балансировщиком ALB, а также правила автоскейлинга TargetTrackingScaling с целевой загрузкой CPU 70.0. Для отладки готового файла скилл предлагает запустить aws cloudformation validate-template --template-body file://template.yaml через Bash до старта развёртывания.

Какие задачи решает

  • составить шаблон CloudFormation для запуска контейнеров в ECS на Fargate или EC2
  • сконфигурировать роли ExecutionRole и TaskRole для разграничения доступов контейнера
  • подключить сервис ECS к Application Load Balancer и настроить целевую группу
  • настроить масштабирование сервиса ECS по загрузке процессора

Примеры запросов агенту

  • Сгенерируй шаблон CloudFormation для ECS-сервиса на Fargate с подключением к ALB
  • Добавь в TaskDefinition переменные окружения и сбор логов в CloudWatch
  • Настрой Application Auto Scaling для сервиса ECS с целевой нагрузкой CPU 70%

Как установить aws-cloudformation-ecs

1Через маркетплейс плагинов

/plugin marketplace add giuseppe-trisciuoglio/developer-kit
/plugin install developer-kit-aws@developer-kit

Команда ставит плагин developer-kit-aws целиком, со всеми его скиллами

2Через Skills CLI (Vercel)

npx skills add giuseppe-trisciuoglio/developer-kit --skill aws-cloudformation-ecs -a claude-code

3Вручную: положить файлы

~/.claude/skills/aws-cloudformation-ecs/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/aws-cloudformation-ecs/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы об aws-cloudformation-ecs

Как установить aws-cloudformation-ecs в Claude Code?

В интерфейсе Claude Code выполните по очереди две команды: сначала /plugin marketplace add giuseppe-trisciuoglio/developer-kit, затем /plugin install developer-kit-aws@developer-kit.

Что делает aws-cloudformation-ecs?

Скилл передаёт агенту правила и структуры CloudFormation для создания кластеров ECS, описания задач, подключения балансировщиков и мониторинга Container Insights.

Как проверить сгенерированный шаблон на синтаксические ошибки?

Скилл рекомендует локальную валидацию через AWS CLI командой aws cloudformation validate-template --template-body file://template.yaml.

Исходный текст

SKILL.md · MIT
---
name: aws-cloudformation-ecs
description: Provides AWS CloudFormation patterns for ECS clusters, task definitions, services, container definitions, auto scaling, blue/green deployments, CodeDeploy integration, ALB integration, service discovery, monitoring, logging, template structure, parameters, outputs, and cross-stack references. Use when creating ECS clusters with CloudFormation, configuring Fargate and EC2 launch types, implementing blue/green deployments, managing auto scaling, integrating with ALB and NLB, and implementing ECS best practices.
allowed-tools: Read, Write, Bash
---

# AWS CloudFormation ECS

## Overview

Provides CloudFormation patterns for ECS clusters, task definitions, services, container definitions, auto scaling, blue/green deployments, ALB integration, monitoring, and cross-stack references.

## When to Use

- Creating or updating ECS clusters with CloudFormation
- Configuring Fargate/EC2 launch types and capacity providers
- Deploying services with ALB/NLB integration or blue/green deployments
- Implementing auto scaling for ECS services
- Setting up monitoring with Container Insights

## Instructions

Follow these steps to create ECS infrastructure with CloudFormation:

### 1. Define ECS Cluster Parameters

Specify launch type, networking, and capacity settings:

```yaml
Parameters:
  LaunchType:
    Type: String
    Default: FARGATE
    AllowedValues:
      - EC2
      - FARGATE
    Description: ECS launch type

  ContainerPort:
    Type: Number
    Default: 80
    Description: Container port

  TaskCPU:
    Type: String
    Default: 256
    AllowedValues:
      - 256
      - 512
      - 1024
      - 2048
      - 4096
    Description: Task CPU units

  TaskMemory:
    Type: String
    Default: 512
    AllowedValues:
      - 512
      - 1024
      - 2048
      - 3072
      - 4096
      - 5120
      - 6144
      - 7168
      - 8192
      - 9216
      - 10240
    Description: Task memory in MB
```

### 2. Create ECS Cluster

Define the cluster infrastructure:

```yaml
Resources:
  ECSCluster:
    Type: AWS::ECS::Cluster
    Properties:
      ClusterName: !Sub "${AWS::StackName}-cluster"
      ClusterSettings:
        - Name: containerInsights
          Value: enabled
      CapacityProviders:
        - FARGATE
        - FARGATE_SPOT
      DefaultCapacityProviderStrategy:
        - CapacityProvider: FARGATE
          Weight: 1
        - CapacityProvider: FARGATE_SPOT
          Weight: 0
```

### 3. Create Task Definition

Define container configurations:

```yaml
Resources:
  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Sub "${AWS::StackName}-task"
      NetworkMode: awsvpc
      RequiresCompatibilities:
        - FARGATE
      Cpu: !Ref TaskCPU
      Memory: !Ref TaskMemory
      ExecutionRoleArn: !Ref ExecutionRole
      TaskRoleArn: !Ref TaskRole
      ContainerDefinitions:
        - Name: application
          Image: !Ref ImageUrl
          PortMappings:
            - ContainerPort: !Ref ContainerPort
              Protocol: tcp
          Environment:
            - Name: LOG_LEVEL
              Value: INFO
          LogConfiguration:
            LogDriver: awslogs
            Options:
              awslogs-group: !Ref LogGroup
              awslogs-region: !Ref AWS::Region
              awslogs-stream-prefix: ecs
          Memory: !Ref TaskMemory
```

**Validate task definition syntax before proceeding:**
```bash
aws cloudformation validate-template --template-body file://template.yaml
```

### 4. Configure Execution Roles

Set up IAM roles for task execution:

```yaml
Resources:
  ExecutionRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service: ecs-tasks.amazonaws.com
            Action: sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy

  TaskRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service: ecs-tasks.amazonaws.com
            Action: sts:AssumeRole
      Policies:
        - PolicyName: S3Access
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect: Allow
                Action:
                  - s3:GetObject
                Resource: !Sub "${DataBucket.Arn}/*"
```

### 5. Create ECS Service

Define the service configuration:

```yaml
Resources:
  ECSService:
    Type: AWS::ECS::Service
    Properties:
      ServiceName: !Sub "${AWS::StackName}-service"
      Cluster: !Ref ECSCluster
      TaskDefinition: !Ref TaskDefinition
      DesiredCount: 2
      LaunchType: FARGATE
      NetworkConfiguration:
        AwsvpcConfiguration:
          Subnets:
            - !Ref PrivateSubnet1
            - !Ref PrivateSubnet2
          SecurityGroups:
            - !Ref SecurityGroup
          AssignPublicIp: DISABLED
      LoadBalancers:
        - TargetGroupArn: !Ref TargetGroup
          ContainerName: application
          ContainerPort: !Ref ContainerPort
```

### 6. Configure Load Balancer

Set up ALB for traffic distribution:

```yaml
Resources:
  LoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Name: !Sub "${AWS::StackName}-alb"
      Scheme: internet-facing
      Type: application
      Subnets:
        - !Ref PublicSubnet1
        - !Ref PublicSubnet2
      SecurityGroups:
        - !Ref ALBSecurityGroup

  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Port: 80
      Protocol: HTTP
      VpcId: !Ref VPC
      TargetType: ip

  Listener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      DefaultActions:
        - TargetGroupArn: !Ref TargetGroup
          Type: forward
      LoadBalancerArn: !Ref LoadBalancer
      Port: 80
      Protocol: HTTP
```

### 7. Implement Auto Scaling

Configure Application Auto Scaling:

```yaml
Resources:
  ScalableTarget:
    Type: AWS::ApplicationAutoScaling::ScalableTarget
    Properties:
      MaxCapacity: 10
      MinCapacity: 1
      ResourceId: !Sub "service/${ECSCluster}/${ECSService}"
      ScalableDimension: ecs:service:DesiredCount
      ServiceNamespace: ecs

  ScalingPolicy:
    Type: AWS::ApplicationAutoScaling::ScalingPolicy
    Properties:
      PolicyName: !Sub "${AWS::StackName}-scaling"
      PolicyType: TargetTrackingScaling
      ScalingTargetId: !Ref ScalableTarget
      TargetTrackingScalingPolicyConfiguration:
        TargetValue: 70.0
        PredefinedMetricSpecification:
          PredefinedMetricType: ECSServiceAverageCPUUtilization
```

### 8. Configure Monitoring

Enable CloudWatch Container Insights:

```yaml
Resources:
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub "/ecs/${AWS::StackName}"
      RetentionInDays: 7
```

**Before deployment:** Create a change set to preview changes:
```bash
aws cloudformation create-change-set \
  --stack-name my-ecs-stack \
  --template-body file://template.yaml \
  --change-set-type CREATE
aws cloudformation execute-change-set --change-set-name <arn>
```

## Best Practices

### Task Definition
- Use `Family` naming for version tracking and immutable deployments
- Keep task definition under 1 KB (CloudFormation limit) by referencing external configs
- Configure `HealthCheck` in container definitions for ECS health monitoring
- Set both `Cpu` and `Memory` at task level for Fargate

### Service Deployment
- Enable `DeploymentCircuitBreaker` for automatic rollback on failures
- Use `HealthCheckGracePeriodSeconds` matching application startup time
- Configure `MinimumHealthyPercent` (100) and `MaximumPercent` (200) for zero-downtime updates
- Reference task definition by logical ID only—ECS automatically uses latest revision

### Networking
- Always use `awsvpc` network mode for Fargate
- Place tasks in private subnets with NAT gateway for outbound access
- Configure security groups to allow only required ports (not 0.0.0.0/0)

### Scaling
- Use Fargate Spot with base capacity of 1 on-demand for cost optimization
- Set `MaxHealthyDuration` on capacity provider strategy for Spot interruption handling
- Monitor `STEADY_STATE` failures in CloudWatch for task startup issues

## Constraints and Warnings

### Resource Limits
- Task definition size limit: 1 KB when using CloudFormation (use ParameterStore/Secrets Manager for large configs)
- Maximum 10 containers per task definition in Fargate
- CPU must be specified for Fargate tasks (256-4096 units, in 1024 increments)
- Memory must be allocated (512-30720 MB depending on CPU)

### Operational Limits
- ENI limits apply per subnet—plan for at least 1 ENI per task in each AZ
- Fargate Spot tasks receive 2-minute interruption notice—implement graceful shutdown signals (SIGTERM)
- Service updates require new task definition revision—cannot modify existing versions
- `DesiredCount` updates during deployment may conflict with auto scaling policies

### CloudFormation-Specific
- Cross-stack references required for VPC IDs, Subnet IDs, and Security Group IDs passed between stacks
- Use `!GetAtt` for referencing stack outputs in same template
- Ensure IAM role ARNs use `Fn::Sub` with stack name for portability

## Examples

### Minimal Fargate Service
```yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: Minimal ECS Fargate service

Resources:
  Cluster:
    Type: AWS::ECS::Cluster
    Properties:
      ClusterName: !Sub "${AWS::StackName}-cluster"

  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Sub "${AWS::StackName}-task"
      NetworkMode: awsvpc
      RequiresCompatibilities: [FARGATE]
      Cpu: 256
      Memory: 512
      ContainerDefinitions:
        - Name: app
          Image: nginx:latest
          PortMappings:
            - ContainerPort: 80

  Service:
    Type: AWS::ECS::Service
    Properties:
      Cluster: !Ref Cluster
      ServiceName: !Sub "${AWS::StackName}-svc"
      TaskDefinition: !Ref TaskDefinition
      DesiredCount: 2
      LaunchType: FARGATE
      DeploymentCircuitBreaker:
        Enable: true
        Rollback: true
```

### ECS with ALB Integration
```yaml
Resources:
  Service:
    Type: AWS::ECS::Service
    Properties:
      Cluster: !Ref ECSCluster
      TaskDefinition: !Ref TaskDefinition
      DesiredCount: 2
      LaunchType: FARGATE
      HealthCheckGracePeriodSeconds: 30
      NetworkConfiguration:
        AwsvpcConfiguration:
          Subnets: [!Ref PrivateSubnet1, !Ref PrivateSubnet2]
          SecurityGroups: [!Ref TaskSecurityGroup]
      LoadBalancers:
        - TargetGroupArn: !Ref TargetGroup
          ContainerName: app
          ContainerPort: 8080

  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Port: 80
      Protocol: HTTP
      VpcId: !Ref VPC
      TargetType: ip
      HealthCheckPath: /health
```

## References

For detailed implementation guidance, see:

- **[constraints.md](references/constraints.md)** - Resource limits (task definition size, container limits, memory limits, CPU limits), operational constraints (service updates, ENI limits, task start time, scaling delays), security constraints (IAM roles, network mode, security groups, secrets rotation), cost considerations (Fargate pricing, data transfer, ECR storage, monitoring), deployment constraints (blue/green requirements, CodeDeploy integration, rollbacks, task drift), and availability constraints (Fargate Spot, multi-AZ, health checks, service discovery)

## Related Resources

- [AWS ECS Documentation](https://docs.aws.amazon.com/ecs/)
- [ECS Task Definitions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html)
- [ECS Services](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html)
- [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/)
- [ECS Blue/Green Deployments](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-steps-ecs.html)
- [CloudFormation Stack Policies](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html)
- [CloudFormation Drift Detection](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/detect-drift-stack.html)
- [CloudFormation Change Sets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html)

© Giuseppe Trisciuoglio · MIT · giuseppe-trisciuoglio/developer-kit

Похожие скиллы

Все скиллы по теме «Облака: AWS, Azure, GCP» →
aws-ecs-fargate devops-skills Скилл aws-ecs-fargate разворачивает контейнеры в Amazon ECS и Fargate. Помогает настроить описания задач, сервисы с балансировщиком нагрузки и автоматическое масштабирование. CX Codex +1 385установок aws-ecs sanjeed5 С гайдлайнами по AWS ECS: образы, секреты, логи и лимиты ресурсов. Включается в работу при каждом обращении к проекту и подсказывает агенту, как строить контейнеры и таск-дефинишены правильно. CX Codex +1 ★ 3 589звёзд репо aws-cloudformation aws Скилл aws-cloudformation ведёт шаблоны CloudFormation от написания до разбора упавших стеков: валидация, проверки cfn-guard и поиск причины сбоя по событиям и CloudTrail. CX Codex +1 10 000установок AWS CloudFormation awslabs Управляет ресурсами AWS CloudFormation через Cloud Control API прямо из интерфейса ИИ-ассистента. Пригодится при настройке облачной инфраструктуры. CX Codex +1 ★ 9 939звёзд репо cloudformation-to-pulumi pulumi Скилл cloudformation-to-pulumi переносит шаблоны и активные стеки CloudFormation в код Pulumi. Помогает подготовить TypeScript-ресурсы для cdk-importer и сверить импорт без расхождений. CX Codex +1 918установок cloudformation devops-skills Скилл для развёртывания AWS-ресурсов через CloudFormation: стеки, change sets, вложенные стеки и drift detection. CX Codex +1 344установок

Из того же набора191

Весь набор →
aws-drawio-architecture-diagrams Скилл aws-drawio-architecture-diagrams для Claude Code генерирует AWS-архитектуры в формате .drawio с официальными иконками aws4 по описанию инфраструктуры. CX Codex +1 ★ 372звёзд репо devkit.java.code-review Команда devkit.java.code-review проводит ревью Java-кода на Spring Boot: ищет уязвимости по OWASP, проверяет архитектуру, чинит проблемы производительности и инъекцию зависимостей перед мерджем. CX Codex +1 ★ 372звёзд репо devkit.java.write-integration-tests Команда devkit.java.write-integration-tests для Claude Code генерирует интеграционные тесты для классов Spring Boot. Запускайте её для сервисов и репозиториев, передав путь к классу. CX Codex +1 ★ 372звёзд репо devkit.ts.security-review Слэш-команда devkit.ts.security-review прогоняет безопасность TypeScript/Node.js приложения: npm audit, Semgrep, Snyk, потом ручная проверка по OWASP Top 10 и отчёт с приоритетами. CX Codex +1 ★ 372звёзд репо aws-cloudformation-auto-scaling Скилл aws-cloudformation-auto-scaling для Claude Code помогает собирать CloudFormation-шаблоны для Auto Scaling в EC2, ECS и Lambda. Описывает группы масштабирования, политики и хуки жизненного цикла. CX Codex +1 ★ 372звёзд репо wordpress-sage-theme Скилл wordpress-sage-theme подсказывает, как собрать тему WordPress на Sage: Blade-шаблоны, Vite или Bud, поля ACF. Заранее нужны PHP 8.0+, Node.js 18+ и Composer. CX Codex +1 ★ 372звёзд репо php-code-review-expert Субагент php-code-review-expert проверяет код на PHP 8.3+, Laravel и Symfony. Находит уязвимости, проблемы с типами и ошибки в ORM, отсеивая сомнительные замечания. CX Codex ★ 372звёзд репо aws-cost-optimization Скилл aws-cost-optimization помогает разбирать расходы AWS по пяти направлениям и находить способы сократить счета за EC2, EBS и S3. Подходит для cost review и FinOps-задач. CX Codex +1 ★ 372звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой