EC2 Container Service (ECS) is a highly scalable, fast, container management service that makes it easy to run, stop, and manage Docker containers on a cluster of Amazon EC2 instances. To run an application on ECS you need the following components:
- Docker image published to Docker Hub or EC2 Container Registry (ECR)
- ECS cluster
- ECS service referencing an ECS task definition
We provide you templates for the ECS cluster and the service. We also provide you with a way to create a task definition. You need to publish the Docker image.
This template describes a fault tolerant and scalable ECS cluster on AWS.
- This templates depends on our
vpc-*azs.yaml
template. Launch Stack - Launch Stack
- Click Next to proceed with the next step of the wizard.
- Specify a name and all parameters for the stack.
- Click Next to proceed with the next step of the wizard.
- Click Next to skip the Options step of the wizard.
- Check the I acknowledge that this template might cause AWS CloudFormation to create IAM resources. checkbox.
- Click Create to start the creation of the stack.
- Wait until the stack reaches the state CREATE_COMPLETE
vpc/vpc-*azs.yaml
(required)vpc/vpc-ssh-bastion.yaml
security/auth-proxy-*.yaml
This template describes a fault tolerant and scalable ECS service on AWS.
Before you can start with the ECS service, you need to create a task definition. The task definition references your Docker image from Docker Hub or ECR.
In the container-definitions.json file, replace:
$Image
with your published Docker image (e.g.nginx:1.11.5
or123456789012.dkr.ecr.us-east-1.amazonaws.com/demo:1.0.0
)$AWSRegion
with the region your ECS cluster runs in (e.g.eu-west-1
)$ClusterLogGroup
with theLogGroup
output from theecs-cluster
stack (e.g. via the CLIaws cloudformation describe-stacks --stack-name $ClusterName --query "Stacks[0].Outputs[?OutputKey=='LogGroup'].OutputValue" --output text
)$ServiceName
with the name of the service (e.g.demo
)
Other options can be found in the AWS docs: http://docs.aws.amazon.com/cli/latest/reference/ecs/
The following CLI command creates a task definition and outputs the unique ARN that you will need later when you create the service:
aws ecs register-task-definition --family $ServiceName --network-mode bridge --container-definitions file://container-definitions.json --query "taskDefinition.taskDefinitionArn" --output text
If you want to update your task definition because you want to deploy a new version of your image, just re run the aws ecs register-task-definition
command from above. This will create a new task definition because you can not change them. Take a note of the new ARN that the command returns.
We provide two service templates.
The first one (service-cluster-alb.yaml
) uses the cluster's load balancer and path based routing. If you want to run multiple services on the same cluster they all will use the same domain name but start with different paths (e.g. https://yourdomain.com/service1/
and https://yourdomain.com/service2/
).
The second one (service-dedicated-alb.yaml
) includes a dedicated load balancer (ALB). You can then use a separate domain name for each service.
This template describes a fault tolerant and scalable ECS service that uses the cluster's load balancer and path based routing.
- This templates depends on our
cluster.yaml
template. Launch Stack - Launch Stack
- Click Next to proceed with the next step of the wizard.
- Specify a name and all parameters for the stack.
- Click Next to proceed with the next step of the wizard.
- Click Next to skip the Options step of the wizard.
- Check the I acknowledge that this template might cause AWS CloudFormation to create IAM resources. checkbox.
- Click Create to start the creation of the stack.
- Wait until the stack reaches the state CREATE_COMPLETE
ecs/cluster.yaml
(required)
This template describes a fault tolerant and scalable ECS service that uses a dedicated load balancer for the service.
- This templates depends on our
cluster.yaml
template. Launch Stack - Launch Stack
- Click Next to proceed with the next step of the wizard.
- Specify a name and all parameters for the stack.
- Click Next to proceed with the next step of the wizard.
- Click Next to skip the Options step of the wizard.
- Check the I acknowledge that this template might cause AWS CloudFormation to create IAM resources. checkbox.
- Click Create to start the creation of the stack.
- Wait until the stack reaches the state CREATE_COMPLETE
vpc/vpc-*azs.yaml
(required)ecs/cluster.yaml
(required)
We offer support for our CloudFormation templates: setting up environments based on our templates, adopting templates to specific use cases, resolving issues in production environments. Hire us!
We are looking forward to your feedback. Mail to hello@widdix.de.
A cloudonaut.io project. Engineered by widdix.