Download AWS CloudFormation User Guide

Transcript
AWS CloudFormation User Guide
AWS::CloudFormation::Init
Services
You can use the services key to define which services should be enabled or disabled when the instance
is launched. On Linux systems, this key is supported by using sysvinit. On Windows systems, it is supported
by using the Windows service manager.
The services key also allows you to specify dependencies on sources, packages and files so that if a
restart is needed due to files being installed, cfn-init will take care of the service restart. For example, if
you download the Apache HTTP Server package, the package installation will automatically start the
Apache HTTP Server during the stack creation process. However, if the Apache HTTP Server configuration
is updated later in the stack creation process, the update won't take effect unless the Apache server is
restarted. You can use the services key to ensure that the Apache HTTP service is restarted.
The following table lists the supported keys.
Key
Description
ensureRunning
Set to true to ensure that the service is running after cfn-init finishes.
Set to false to ensure that the service is not running after cfn-init finishes.
Omit this key to make no changes to the service state.
enabled
Set to true to ensure that the service will be started automatically upon boot.
Set to false to ensure that the service will not be started automatically upon
boot.
Omit this key to make no changes to this property.
files
A list of files. If cfn-init changes one directly via the files block, this service
will be restarted
sources
A list of directories. If cfn-init expands an archive into one of these directories,
this service will be restarted.
packages
A map of package manager to list of package names. If cfn-init installs or
updates one of these packages, this service will be restarted.
commands
A list of command names. If cfn-init runs the specified command, this service
will be restarted.
The following Linux snippet configures the services as follows:
• The nginx service will be restarted if either /etc/nginx/nginx.conf or /var/www/html are modified by
cfn-init.
• The php-fastcgi service will be restarted if cfn-init installs or updates php or spawn-fcgi using yum.
• The sendmail service will be stopped and disabled.
"services" : {
"sysvinit" : {
"nginx" : {
"enabled" : "true",
"ensureRunning" : "true",
"files" : ["/etc/nginx/nginx.conf"],
"sources" : ["/var/www/html"]
API Version 2010-05-15
322