lanoxx
lanoxx

Reputation: 13041

Provision ECS Instance with CloudFormation and install custom package

I am trying to provision an ECS Cluster using CloudFormation. The basic context is:

This works but for some reason it is quite slow. It seems that the Amazon ECS–optimized AMI comes with its own scripts that install software with yum and that the yum from my UserData script is blocked by that and needs to wait until it can install additional packages.

Is there a recommended way on how to install additional packages when using the ECS-Enhanced AMI?

I currently use a simple script:

#!/bin/bash
yum update -y
yum install -y nfs-utils

Upvotes: 0

Views: 416

Answers (1)

Laurent Jalbert Simard
Laurent Jalbert Simard

Reputation: 6329

I have almost the same setup but I use CloudInit instead of a simple script as UserData. I suggest you do the same considering I didn't experience any particular slowness when launching an instance.

#cloud-config

repo_upgrade: all


write_files:
 - path: /root/init.sh
   owner: root:root
   permissions: '0755'
   content: |
     #!/bin/bash

     set -e

     # ECS optimized instances are bare bones and we need to install a few packages
     yum install -y aws-cli wget gettext python-pip

     ...


cloud_final_modules:
 - runcmd
 - scripts-user


runcmd:
 - /root/init.sh

Upvotes: 1

Related Questions