Skip to content

nsbno/terraform-aws-ecs-anywhere-instance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECS Anywhere Instance

Register an on-premise instance for use in an AWS ECS Cluster

About

Need some workloads to run on-premise instead of in the cloud? Then this is most likely your solution. This module allows you to get your on-premise servers ready to use with ECS.

Do note that this assumes that you’re on RHEL 7 (though most Vy hosts are).

Examples

The examples directory has multiple examples to help you get going.

Automatic Instance Configuration

A setup where the terraform module configures your hosts. This requires that the host running the first terraform apply has access to on-prem.

Manual Instance Configuration

A straight forward setup where the instances are not automatically registered with ECS and SSM. If you use this approach, you’ll have to go through the manual setup section.

Manual Setup

Some manual steps must be taken if you don’t opt for the automatic configuration. These are the same steps that the terraform provisioner does, but done manually. This assumes that the server is running RHEL 7 (which all Vy hosts are).

Start off by logging into the host you want to add to your AWS environment.

ssh <username>@<host>

Now, let’s configure and install the relevant dependencies. This downloads and sets up docker using the CentOS 7 version.

# Enable RHEL repositories that contain some required packages
sudo subscription-manager repos \
  --enable=rhel-7-server-rpms \
  --enable=rhel-7-server-extras-rpms \
  --enable=rhel-7-server-optional-rpms

# Install required packages.
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

# Install container-selinux.
# Check for latest version: http://mirror.centos.org/centos/7/extras/x86_64/Packages/.
sudo yum install -y \
  http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm

# Set up Docker repository.
sudo yum-config-manager \
  --add-repo \
  https://download.docker.com/linux/centos/docker-ce.repo

# Install Docker CE and tools.
sudo yum install -y \
  docker-ce \
  docker-ce-cli \
  containerd.io

Finally, we’ll do the actual installation. This will download docker to the host and register it with both SSM and ECS. You can find the activation id and code in parameter store.

curl --proto https -o /tmp/ecs-anywhere-install.sh 'https://raw.githubusercontent.com/aws/amazon-ecs-init/v1.53.0-1/scripts/ecs-anywhere-install.sh'
echo '5ea39e5af247b93e77373c35530d65887857b8d14539465fa7132d33d8077c8c  /tmp/ecs-anywhere-install.sh' \
  | sha256sum -c - \
  || exit 1
sudo bash /tmp/ecs-anywhere-install.sh \
  --docker-install-source none \
  --region '<aws-region>' \
  --cluster '<ecs-cluster-name>' \
  --activation-id '<activation-id-from-ssm>' \
  --activation-code '<activation-code-from-ssm>'