service

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 service method maps to the AWS::CloudFormation::Init services seciton.

service("sysvinit",
  nginx: {
    enabled: true,
    ensureRunning: true,
    files: ["/etc/nginx/nginx.conf"],
    sources: ["/var/www/html"]
  },
  "php-fastcgi": {
    enabled: true,
    ensureRunning: true,
    packages: { yum: ["php", "spawn-fcgi"] }
  },
  sendmail: {
    enabled: false,
    ensureRunning: false
  }
)

Generates:

AWS::CloudFormation::Init:
  configSets:
    default:
    - main
  main:
    services:
      sysvinit:
        nginx:
          enabled: true
          ensureRunning: true
          files:
          - "/etc/nginx/nginx.conf"
          sources:
          - "/var/www/html"
        php-fastcgi:
          enabled: true
          ensureRunning: true
          packages:
            yum:
            - php
            - spawn-fcgi
        sendmail:
          enabled: false
          ensureRunning: false

Back to DSL Docs

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!