AwsEcsExecutionModule
Hierarchy
- AModule<AwsEcsExecutionModuleSchema, Execution>
- AwsEcsExecutionModule
Index
Constructors
Properties
Methods
Resources
Constructors
constructor
Parameters
moduleId: string
The ID this module is loaded under.
Returns AwsEcsExecutionModule
Properties
readonlyinheritedmoduleId
The ID this module was loaded under. It scopes everything the module produces, so the same module class can be loaded more than once.
staticreadonlyinheritedMODULE_PACKAGE
The package the module is registered under, set by Module.
staticreadonlyinheritedMODULE_SCHEMA
The schema of the module's inputs, set by Module.
Methods
onInit
Creates the execution, resolves the anchors of its server, deployment, subnet, and any sidecars, and opens the security-group rules between them.
Parameters
inputs: AwsEcsExecutionModuleSchema
Returns Promise<(AwsEcsExecution | AwsEcsExecutionOverlay | AwsEcsExecutionServerSecurityGroupOverlay)[]>
inheritedregisterHooks
To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.
Returns { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
optionalpostCommitHooks?: PostHookSignature[]
optionalpostModelActionHooks?: PostHookSignature[]
optionalpostResourceActionHooks?: PostHookSignature[]
optionalpreCommitHooks?: PreHookSignature[]
optionalpreModelActionHooks?: PreHookSignature[]
optionalpreResourceActionHooks?: PreHookSignature[]
registerMetadata
Resolves the account, region, and the region model this execution is placed in.
Parameters
inputs: AwsEcsExecutionModuleSchema
Returns Promise<{ awsAccountId: string; awsRegionId: string; region: Region }>
AwsEcsExecutionModuleruns a server's deployments as a long-running ECS Fargate service in a subnet, withdesiredCounttasks,environmentVariables,securityGroupRulesandfilesystemsmounted.Fargate bills each task's vCPU and memory every second it runs, about $0.0405 per vCPU-hour and $0.0044 per GB-hour on x86_64 in us-east-1, about a fifth less on arm64. A task of 0.25 vCPU and 0.5 GB runs about $9 a month, multiplied by
desiredCount, and costs the same idle as busy. Its logs bill about $0.50 per GB written to CloudWatch.A new deployment rolls: ECS starts the new tasks, waits for them to pass the load balancer's health check, then drains the old ones for up to 300 seconds, so a release takes several minutes and serves throughout. Changing
desiredCountor the load balancers updates the service in place.TypeScript
Modules/Execution/AwsEcsExecution
The service runs in one subnet, so in one availability zone. A task's CPU is one of 256 to 16384 units, and its memory must be a size Fargate pairs with that CPU.
Tasks run all the time, so a service with
desiredCount0 serves nothing and one with 1 has nothing to fail over to.The service runs
desiredCounttasks and never scales with load: more or fewer tasks is a change ofdesiredCountin a run. Tasks run on Fargate only, never on Fargate Spot or on EC2 instances of your own.One IAM role both lets ECS pull the image and write logs, and is the role the containers run as, so the code holds every grant of its servers together with
AmazonECSTaskExecutionRolePolicy.Containers log to one CloudWatch log group per execution, through the
awslogsdriver; no other log destination can be set.The log group
/ecs/<executionId>must not exist before the first apply, which fails otherwise.Each filesystem is mounted read-write at
/mnt/<filesystemName>in every container of the task, over the filesystem's root.The service has no deployment circuit breaker: a release whose tasks never become healthy is not rolled back.
Whatever a task writes to its own disk is lost when the task stops; data meant to outlive it goes into an EFS filesystem (
filesystems) or a storage service. Its logs are kept forlogRetentionInDaysand deleted with it.Changing
executionIdor the environment replaces the service. A change to an image, its CPU, memory or environment variables registers a new task definition and rolls the service onto it.Executionmodel.