ecs

package
v0.0.1-alpha.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package ecs provides emulation of Amazon Elastic Container Service (ECS).

Supported: CreateCluster, DescribeClusters, ListClusters, DeleteCluster,

RegisterTaskDefinition, DescribeTaskDefinition, ListTaskDefinitions,
DeregisterTaskDefinition, RunTask, StopTask, DescribeTasks, ListTasks,
CreateService, UpdateService, DeleteService, DescribeServices, ListServices

Unsupported: See docs/services/ecs.md (stub operations return 501).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountSetting

type AccountSetting struct {
	Name         string `json:"name"`
	Value        string `json:"value"`
	PrincipalArn string `json:"principalArn"`
}

AccountSetting holds a user-level ECS account setting override.

type Attachment

type Attachment struct {
	Id      string         `json:"id"`
	Type    string         `json:"type"`
	Status  string         `json:"status"`
	Details []KeyValuePair `json:"details,omitempty"`
}

Attachment represents a network interface (ENI) or other resource attached to a task.

type AwsvpcConfiguration

type AwsvpcConfiguration struct {
	Subnets        []string `json:"subnets,omitempty"`
	SecurityGroups []string `json:"securityGroups,omitempty"`
	AssignPublicIp string   `json:"assignPublicIp,omitempty"`
}

AwsvpcConfiguration specifies VPC subnets and security groups for a task.

type CapacityProvider

type CapacityProvider struct {
	CapacityProviderArn string `json:"capacityProviderArn"`
	Name                string `json:"name"`
	Status              string `json:"status"`
	UpdateStatus        string `json:"updateStatus,omitempty"`
	Tags                []Tag  `json:"tags,omitempty"`
}

CapacityProvider represents an ECS capacity provider resource.

type CapacityProviderStrategyItem

type CapacityProviderStrategyItem struct {
	CapacityProvider string `json:"capacityProvider"`
	Weight           int    `json:"weight,omitempty"`
	Base             int    `json:"base,omitempty"`
}

CapacityProviderStrategyItem specifies a capacity provider and its weight/base.

type Cluster

type Cluster struct {
	ClusterName                       string                         `json:"clusterName"`
	ClusterArn                        string                         `json:"clusterArn"`
	Status                            string                         `json:"status"`
	RegisteredContainerInstancesCount int                            `json:"registeredContainerInstancesCount"`
	RunningTasksCount                 int                            `json:"runningTasksCount"`
	PendingTasksCount                 int                            `json:"pendingTasksCount"`
	ActiveServicesCount               int                            `json:"activeServicesCount"`
	CapacityProviders                 []string                       `json:"capacityProviders,omitempty"`
	DefaultCapacityProviderStrategy   []CapacityProviderStrategyItem `json:"defaultCapacityProviderStrategy,omitempty"`
}

Cluster represents a stored ECS cluster.

type Container

type Container struct {
	ContainerArn string `json:"containerArn"`
	Name         string `json:"name"`
	Image        string `json:"image"`
	LastStatus   string `json:"lastStatus"`
	ExitCode     *int   `json:"exitCode,omitempty"`
	Reason       string `json:"reason,omitempty"`
	RuntimeId    string `json:"runtimeId,omitempty"`
	DockerID     string `json:"dockerId,omitempty"` // Docker container ID when backed by Docker
}

Container represents a container within a running task.

type ContainerDefinition

type ContainerDefinition struct {
	Name             string            `json:"name"`
	Image            string            `json:"image"`
	Cpu              int               `json:"cpu,omitempty"`
	Memory           int               `json:"memory,omitempty"`
	Essential        *bool             `json:"essential,omitempty"`
	PortMappings     []PortMapping     `json:"portMappings,omitempty"`
	Environment      []KeyValuePair    `json:"environment,omitempty"`
	Command          []string          `json:"command,omitempty"`
	LogConfiguration *LogConfiguration `json:"logConfiguration,omitempty"`
}

ContainerDefinition represents a container within a task definition.

type ContainerInstance

type ContainerInstance struct {
	ContainerInstanceArn string `json:"containerInstanceArn"`
	Ec2InstanceId        string `json:"ec2InstanceId,omitempty"`
	Status               string `json:"status"`
	AgentConnected       bool   `json:"agentConnected"`
	RunningTasksCount    int    `json:"runningTasksCount"`
	PendingTasksCount    int    `json:"pendingTasksCount"`
	RegisteredAt         int64  `json:"registeredAt"`
	ClusterName          string `json:"clusterName"`
}

ContainerInstance represents a registered ECS container instance.

type ContainerOverride

type ContainerOverride struct {
	Name        string         `json:"name,omitempty"`
	Command     []string       `json:"command,omitempty"`
	Environment []KeyValuePair `json:"environment,omitempty"`
}

ContainerOverride holds per-container overrides.

type Deployment

type Deployment struct {
	ID                   string                `json:"id"`
	Status               string                `json:"status"`
	TaskDefinition       string                `json:"taskDefinition"`
	DesiredCount         int                   `json:"desiredCount"`
	RunningCount         int                   `json:"runningCount"`
	PendingCount         int                   `json:"pendingCount"`
	CreatedAt            int64                 `json:"createdAt"`
	UpdatedAt            int64                 `json:"updatedAt"`
	NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"`
	PlatformVersion      string                `json:"platformVersion,omitempty"`
	PlatformFamily       string                `json:"platformFamily,omitempty"`
}

Deployment represents a deployment within an ECS service.

type DeploymentController

type DeploymentController struct {
	Type string `json:"type"`
}

DeploymentController specifies the controller type for an ECS service deployment.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler holds ECS handler dependencies.

func (*Handler) CreateCapacityProvider

func (h *Handler) CreateCapacityProvider(w http.ResponseWriter, r *http.Request)

CreateCapacityProvider handles AmazonEC2ContainerServiceV20141113.CreateCapacityProvider.

func (*Handler) CreateCluster

func (h *Handler) CreateCluster(w http.ResponseWriter, r *http.Request)

CreateCluster handles AmazonEC2ContainerServiceV20141113.CreateCluster.

func (*Handler) CreateService

func (h *Handler) CreateService(w http.ResponseWriter, r *http.Request)

CreateService handles AmazonEC2ContainerServiceV20141113.CreateService.

func (*Handler) CreateTaskSet

func (h *Handler) CreateTaskSet(w http.ResponseWriter, r *http.Request)

CreateTaskSet handles AmazonEC2ContainerServiceV20141113.CreateTaskSet.

func (*Handler) DeleteAccountSetting

func (h *Handler) DeleteAccountSetting(w http.ResponseWriter, r *http.Request)

DeleteAccountSetting handles AmazonEC2ContainerServiceV20141113.DeleteAccountSetting.

func (*Handler) DeleteCluster

func (h *Handler) DeleteCluster(w http.ResponseWriter, r *http.Request)

DeleteCluster handles AmazonEC2ContainerServiceV20141113.DeleteCluster.

func (*Handler) DeleteService

func (h *Handler) DeleteService(w http.ResponseWriter, r *http.Request)

DeleteService handles AmazonEC2ContainerServiceV20141113.DeleteService.

func (*Handler) DeleteTaskSet

func (h *Handler) DeleteTaskSet(w http.ResponseWriter, r *http.Request)

DeleteTaskSet handles AmazonEC2ContainerServiceV20141113.DeleteTaskSet.

func (*Handler) DeregisterContainerInstance

func (h *Handler) DeregisterContainerInstance(w http.ResponseWriter, r *http.Request)

DeregisterContainerInstance handles AmazonEC2ContainerServiceV20141113.DeregisterContainerInstance.

func (*Handler) DeregisterTaskDefinition

func (h *Handler) DeregisterTaskDefinition(w http.ResponseWriter, r *http.Request)

DeregisterTaskDefinition handles AmazonEC2ContainerServiceV20141113.DeregisterTaskDefinition.

func (*Handler) DescribeCapacityProviders

func (h *Handler) DescribeCapacityProviders(w http.ResponseWriter, r *http.Request)

DescribeCapacityProviders handles AmazonEC2ContainerServiceV20141113.DescribeCapacityProviders.

func (*Handler) DescribeClusters

func (h *Handler) DescribeClusters(w http.ResponseWriter, r *http.Request)

DescribeClusters handles AmazonEC2ContainerServiceV20141113.DescribeClusters.

func (*Handler) DescribeContainerInstances

func (h *Handler) DescribeContainerInstances(w http.ResponseWriter, r *http.Request)

DescribeContainerInstances handles AmazonEC2ContainerServiceV20141113.DescribeContainerInstances.

func (*Handler) DescribeServices

func (h *Handler) DescribeServices(w http.ResponseWriter, r *http.Request)

DescribeServices handles AmazonEC2ContainerServiceV20141113.DescribeServices.

func (*Handler) DescribeTaskDefinition

func (h *Handler) DescribeTaskDefinition(w http.ResponseWriter, r *http.Request)

DescribeTaskDefinition handles AmazonEC2ContainerServiceV20141113.DescribeTaskDefinition.

func (*Handler) DescribeTaskSets

func (h *Handler) DescribeTaskSets(w http.ResponseWriter, r *http.Request)

DescribeTaskSets handles AmazonEC2ContainerServiceV20141113.DescribeTaskSets.

func (*Handler) DescribeTasks

func (h *Handler) DescribeTasks(w http.ResponseWriter, r *http.Request)

DescribeTasks handles AmazonEC2ContainerServiceV20141113.DescribeTasks.

func (*Handler) GetTaskContainerLogs

func (h *Handler) GetTaskContainerLogs(w http.ResponseWriter, r *http.Request)

GetTaskContainerLogs returns the last 200 lines of logs for a specific container in a task. This is an emulator-only endpoint.

func (*Handler) ListAccountSettings

func (h *Handler) ListAccountSettings(w http.ResponseWriter, r *http.Request)

ListAccountSettings handles AmazonEC2ContainerServiceV20141113.ListAccountSettings.

func (*Handler) ListClusterTasks

func (h *Handler) ListClusterTasks(w http.ResponseWriter, r *http.Request)

ListClusterTasks returns all tasks for a given cluster. This is an emulator-only endpoint.

func (*Handler) ListClusters

func (h *Handler) ListClusters(w http.ResponseWriter, r *http.Request)

ListClusters handles AmazonEC2ContainerServiceV20141113.ListClusters.

func (*Handler) ListContainerInstances

func (h *Handler) ListContainerInstances(w http.ResponseWriter, r *http.Request)

ListContainerInstances handles AmazonEC2ContainerServiceV20141113.ListContainerInstances.

func (*Handler) ListServices

func (h *Handler) ListServices(w http.ResponseWriter, r *http.Request)

ListServices handles AmazonEC2ContainerServiceV20141113.ListServices.

func (*Handler) ListTagsForResource

func (h *Handler) ListTagsForResource(w http.ResponseWriter, r *http.Request)

ListTagsForResource handles AmazonEC2ContainerServiceV20141113.ListTagsForResource.

func (*Handler) ListTaskDefinitionFamilies

func (h *Handler) ListTaskDefinitionFamilies(w http.ResponseWriter, r *http.Request)

ListTaskDefinitionFamilies handles AmazonEC2ContainerServiceV20141113.ListTaskDefinitionFamilies.

func (*Handler) ListTaskDefinitions

func (h *Handler) ListTaskDefinitions(w http.ResponseWriter, r *http.Request)

ListTaskDefinitions handles AmazonEC2ContainerServiceV20141113.ListTaskDefinitions.

func (*Handler) ListTasks

func (h *Handler) ListTasks(w http.ResponseWriter, r *http.Request)

ListTasks handles AmazonEC2ContainerServiceV20141113.ListTasks.

func (*Handler) PutAccountSetting

func (h *Handler) PutAccountSetting(w http.ResponseWriter, r *http.Request)

PutAccountSetting handles AmazonEC2ContainerServiceV20141113.PutAccountSetting.

func (*Handler) PutAccountSettingDefault

func (h *Handler) PutAccountSettingDefault(w http.ResponseWriter, r *http.Request)

PutAccountSettingDefault handles AmazonEC2ContainerServiceV20141113.PutAccountSettingDefault. Behaves identically to PutAccountSetting in the emulator (no per-principal scoping).

func (*Handler) PutClusterCapacityProviders

func (h *Handler) PutClusterCapacityProviders(w http.ResponseWriter, r *http.Request)

PutClusterCapacityProviders handles AmazonEC2ContainerServiceV20141113.PutClusterCapacityProviders.

func (*Handler) RegisterContainerInstance

func (h *Handler) RegisterContainerInstance(w http.ResponseWriter, r *http.Request)

RegisterContainerInstance handles AmazonEC2ContainerServiceV20141113.RegisterContainerInstance.

func (*Handler) RegisterTaskDefinition

func (h *Handler) RegisterTaskDefinition(w http.ResponseWriter, r *http.Request)

RegisterTaskDefinition handles AmazonEC2ContainerServiceV20141113.RegisterTaskDefinition.

func (*Handler) RunTask

func (h *Handler) RunTask(w http.ResponseWriter, r *http.Request)

RunTask handles AmazonEC2ContainerServiceV20141113.RunTask.

func (*Handler) StopTask

func (h *Handler) StopTask(w http.ResponseWriter, r *http.Request)

StopTask handles AmazonEC2ContainerServiceV20141113.StopTask.

func (*Handler) TagResource

func (h *Handler) TagResource(w http.ResponseWriter, r *http.Request)

TagResource handles AmazonEC2ContainerServiceV20141113.TagResource.

func (*Handler) UntagResource

func (h *Handler) UntagResource(w http.ResponseWriter, r *http.Request)

UntagResource handles AmazonEC2ContainerServiceV20141113.UntagResource.

func (*Handler) UpdateCapacityProvider

func (h *Handler) UpdateCapacityProvider(w http.ResponseWriter, r *http.Request)

UpdateCapacityProvider handles AmazonEC2ContainerServiceV20141113.UpdateCapacityProvider.

func (*Handler) UpdateCluster

func (h *Handler) UpdateCluster(w http.ResponseWriter, r *http.Request)

UpdateCluster handles AmazonEC2ContainerServiceV20141113.UpdateCluster.

func (*Handler) UpdateClusterSettings

func (h *Handler) UpdateClusterSettings(w http.ResponseWriter, r *http.Request)

UpdateClusterSettings handles AmazonEC2ContainerServiceV20141113.UpdateClusterSettings.

func (*Handler) UpdateService

func (h *Handler) UpdateService(w http.ResponseWriter, r *http.Request)

UpdateService handles AmazonEC2ContainerServiceV20141113.UpdateService.

func (*Handler) UpdateServicePrimaryTaskSet

func (h *Handler) UpdateServicePrimaryTaskSet(w http.ResponseWriter, r *http.Request)

UpdateServicePrimaryTaskSet handles AmazonEC2ContainerServiceV20141113.UpdateServicePrimaryTaskSet.

func (*Handler) UpdateTaskSet

func (h *Handler) UpdateTaskSet(w http.ResponseWriter, r *http.Request)

UpdateTaskSet handles AmazonEC2ContainerServiceV20141113.UpdateTaskSet.

type KeyValuePair

type KeyValuePair struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

KeyValuePair is a name-value pair used for environment variables.

type LogConfiguration

type LogConfiguration struct {
	LogDriver string            `json:"logDriver"`
	Options   map[string]string `json:"options,omitempty"`
}

LogConfiguration specifies the log driver and options for a container.

type NetworkConfiguration

type NetworkConfiguration struct {
	AwsvpcConfiguration *AwsvpcConfiguration `json:"awsvpcConfiguration,omitempty"`
}

NetworkConfiguration holds VPC networking settings for awsvpc mode.

type PortMapping

type PortMapping struct {
	ContainerPort int    `json:"containerPort"`
	HostPort      int    `json:"hostPort,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
}

PortMapping maps a container port to a host port.

type Scale

type Scale struct {
	Unit  string  `json:"unit"`
	Value float64 `json:"value"`
}

Scale specifies a percentage-based scale value for a task set.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements router.Service and router.TargetDispatcher for ECS.

func New

func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock) *Service

New returns a configured ECS Service.

func (*Service) Dispatch

func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)

Dispatch satisfies router.TargetDispatcher.

func (*Service) InitBus

func (s *Service) InitBus(bus *events.Bus)

InitBus wires the event bus for ECS lifecycle events.

func (*Service) Name

func (s *Service) Name() string

Name satisfies router.Service.

func (*Service) Operations

func (s *Service) Operations() []op.Operation

Operations implements router.ProtocolService.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(r chi.Router)

RegisterRoutes satisfies router.Service. Registers emulator-only endpoints.

func (*Service) SetDocker

func (s *Service) SetDocker(dc *docker.Client)

SetDocker wires a Docker client into the ECS handler, enabling container execution for RunTask/StopTask. Called after Docker availability is confirmed.

func (*Service) SetVPCResolver

func (s *Service) SetVPCResolver(r VPCNetworkResolver)

SetVPCResolver wires the EC2 VPC resolver for awsvpc task placement.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context)

Stop cancels pending lifecycle transitions and cleans up Docker containers via the GC. The GC does a Docker-level sweep so even orphaned containers (whose task record was already deleted) are caught and removed.

func (*Service) SupportedProtocols

func (s *Service) SupportedProtocols() []codec.Codec

SupportedProtocols implements router.ProtocolService.

func (*Service) TargetPrefix

func (s *Service) TargetPrefix() string

TargetPrefix satisfies router.TargetDispatcher.

type ServiceEvent

type ServiceEvent struct {
	ID        string `json:"id"`
	CreatedAt int64  `json:"createdAt"`
	Message   string `json:"message"`
}

ServiceEvent represents a timestamped event in a service's history.

type Tag

type Tag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Tag is a key-value pair attached to an ECS resource.

type Task

type Task struct {
	TaskArn              string                `json:"taskArn"`
	TaskDefinitionArn    string                `json:"taskDefinitionArn"`
	ClusterArn           string                `json:"clusterArn"`
	LastStatus           string                `json:"lastStatus"`
	DesiredStatus        string                `json:"desiredStatus"`
	LaunchType           string                `json:"launchType"`
	Cpu                  string                `json:"cpu,omitempty"`
	Memory               string                `json:"memory,omitempty"`
	PlatformVersion      string                `json:"platformVersion,omitempty"`
	PlatformFamily       string                `json:"platformFamily,omitempty"`
	StartedAt            *int64                `json:"startedAt,omitempty"`
	StoppedAt            *int64                `json:"stoppedAt,omitempty"`
	StoppedReason        string                `json:"stoppedReason,omitempty"`
	CreatedAt            int64                 `json:"createdAt"`
	Group                string                `json:"group,omitempty"`
	Containers           []Container           `json:"containers"`
	Overrides            *TaskOverride         `json:"overrides,omitempty"`
	NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"`
	Attachments          []Attachment          `json:"attachments,omitempty"`
}

Task represents a running ECS task.

type TaskDefinition

type TaskDefinition struct {
	TaskDefinitionArn       string                `json:"taskDefinitionArn"`
	Family                  string                `json:"family"`
	Revision                int                   `json:"revision"`
	Status                  string                `json:"status"`
	NetworkMode             string                `json:"networkMode,omitempty"`
	RequiresCompatibilities []string              `json:"requiresCompatibilities,omitempty"`
	Cpu                     string                `json:"cpu,omitempty"`
	Memory                  string                `json:"memory,omitempty"`
	ContainerDefinitions    []ContainerDefinition `json:"containerDefinitions"`
}

TaskDefinition represents a stored ECS task definition.

type TaskOverride

type TaskOverride struct {
	ContainerOverrides []ContainerOverride `json:"containerOverrides,omitempty"`
}

TaskOverride holds overrides applied at RunTask time.

type TaskSet

type TaskSet struct {
	Id                   string                `json:"id"`
	TaskSetArn           string                `json:"taskSetArn"`
	ServiceArn           string                `json:"serviceArn"`
	ClusterArn           string                `json:"clusterArn"`
	TaskDefinition       string                `json:"taskDefinition"`
	Status               string                `json:"status"`
	LaunchType           string                `json:"launchType"`
	PlatformVersion      string                `json:"platformVersion,omitempty"`
	PlatformFamily       string                `json:"platformFamily,omitempty"`
	NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"`
	Scale                Scale                 `json:"scale"`
	StabilityStatus      string                `json:"stabilityStatus"`
	StabilityStatusAt    *int64                `json:"stabilityStatusAt,omitempty"`
	CreatedAt            int64                 `json:"createdAt"`
	UpdatedAt            int64                 `json:"updatedAt"`
	ExternalId           string                `json:"externalId,omitempty"`
	Tags                 []Tag                 `json:"tags,omitempty"`
	RunningCount         int                   `json:"runningCount"`
	PendingCount         int                   `json:"pendingCount"`
	ComputedDesiredCount int                   `json:"computedDesiredCount"`
}

TaskSet represents an ECS task set within a service (CODE_DEPLOY or EXTERNAL controller).

type VPCNetworkResolver

type VPCNetworkResolver interface {
	VpcIDForSubnet(ctx context.Context, subnetID string) string
	VPCNetworkStatus(ctx context.Context, vpcID string) string
	DockerNetworkForVpc(ctx context.Context, vpcID string) string
	AllocatePrivateIPForSubnet(ctx context.Context, subnetID string) string
}

VPCNetworkResolver resolves subnet-backed ECS awsvpc placement against EC2.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL