0
votes

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

  • I am using the Amazon ECS–optimized AMI (e.g. ami-8fcc32f6).
  • I am using an auto scaling group and a launch configuration
  • I am setting UserData for the launch configuration to install some packages with yum.

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
1

1 Answers

1
votes

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