This tutorial covers setting up an ECS-integrated Elastigroup using Elastigroup’s Managed Containers Service (MCS). You can also import an existing ECS cluster – this action will fetch all the data needed in order to create a new ECS cluster on Elastigroup based on the configuration of the imported ECS cluster.
Prerequisites: Create an ECS IAM Role
- Before the Amazon ECS agent can register container instance into a cluster, the agent must have IAM Role with appropriate account credentials.
- If you haven’t done this already, here’s how to create an ECS IAM Role.
- Navigate to your IAM console
- Go to – Roles.
- Create a new Role and name it “ECS-ContainerInstance”
- Under “AWS Service Roles” choose: “Amazon EC2 Role for EC2 Container Service”
- Attach the policy and create the Role.
- On the Elastigroup setup, you should specify the newly created IAM Role under “Launch Specification”
Step 1: Select Your ECS Optimized AMI
- Enter the Elastigroup Creation Wizard and select ECS.
- Amazon ECS provides ECS Optimized AMIs which contain an Amazon ECS agent that automatically registers new instances to your desired ECS cluster. In the Compute tab under Launch Specifications enter the ID of your preferred ECS Optimized AMI.
Step 2: Set IP configuration for your Elastigroup instances
In order to register to your ECS cluster each instance in your Elastigroup needs to be associated with a public ip.
- Under the Compute tab go to Additional Configurations.
- Under Public IP choose one of the following:
- Associate public IP
- Subnet default
Step 3: Configure the new ECS cluster
By default, your container instances will launch into your default cluster. If you want to launch into a different cluster, use the following script for the User Data field in the Additional Configurations section of the Compute tab, replacing
CLUSTER_NAME with the name of your desired cluster.
#!/bin/bash echo ECS_CLUSTER=CLUSTER_NAME >> /etc/ecs/ecs.config
<powershell> Import-Module ECSTools Initialize-ECSAgent -Cluster CLUSTER_NAME -EnableTaskIAMRole -LoggingDrivers '["json-file","awslogs"]' </powershell>
Step 4: Set the ECS integration
- In the Compute tab, under the Integrations section, select ECS and provide your Cluster Name.
- Continue with the Creation Wizard and create your Elastigroup.
- Now that you have created an ECS-integrated Elastigroup, utilize the ECS Auto-Scaler to efficiently and automatically scale your cluster.