How can I install AWS CloudFormation helper scripts on Ubuntu 16.04 LTS or RHEL 7 AMIs?

Last updated: 2019-08-09

How can I install AWS CloudFormation helper scripts on Ubuntu 16.04 LTS or RHEL 7 Amazon Machine Images (AMIs)?

Short Description

You must install helper scripts for Ubuntu 16.04 LTS or RHEL 7 AMIs during the boot process. Use the UserData property to automatically download and install the AMIs. Then, start the cfn-hup service automatically at launch.

Resolution

1.    Add the Ubuntu 16.04 LTS script or the RHEL 7 script to the UserData property of your instance.

2.    Create a service in systemd to allow the cfn-hup helper daemon to start automatically at boot.

Important: You must make systemd a dependency of an existing boot target. Use multi-user.target to create the dependency.

3.    Set the instructions in the files key to create the cfn-hup configuration file, cfn-hup hook, and systemd file for cfn-hup /lib/systemd/systemcfn-hup.service.

4.    Use the commands key to enable the service in systemd, and then start the service.

5.    To confirm that the cfn-hup service started after launching the stack, run the following command:

systemctl status cfn-hup

If cfn-hup is running, you receive output similar to the following:

cfn-hup.service - cfn-hup daemon
   Loaded: loaded (/usr/lib/systemd/system/cfn-hup.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2016-10-12 08:10:26 EDT; 1min 11s ago
 Main
PID: 4852 (cfn-hup)
   CGroup: /system.slice/cfn-hup.service            
           └─4852 /usr/bin/python /opt/aws/bin/cfn-hup
Oct 12 08:10:26 ip-172-31-44-180.ec2.internal systemd[1]: Started cfn-hup daemon. 
Oct 12 08:10:26 ip-172-31-44-180.ec2.internal systemd[1]: Starting cfn-hup daemon...

Note: If you're using systemd, the cfn-init helper script doesn't support the services key. Instead, use the commands key as in the preceding example.


Did this article help you?

Anything we could improve?


Need more help?