Skip to content
v2.274.0

ServiceManager Enum ​

The service manager that will be used by InitServices.

The value needs to match the service manager used by your operating system.

Example ​

ts
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;

new ec2.Instance(this, 'Instance', {
  vpc,
  instanceType,
  machineImage: ec2.MachineImage.latestAmazonLinux2023(),

  init: ec2.CloudFormationInit.fromElements(
    // Create a simple config file that runs a Python web server
    ec2.InitService.systemdConfigFile('simpleserver', {
      command: '/usr/bin/python3 -m http.server 8080',
      cwd: '/var/www/html',
    }),
    // Start the server using SystemD
    ec2.InitService.enable('simpleserver', {
      serviceManager: ec2.ServiceManager.SYSTEMD,
    }),
    // Drop an example file to show the web server working
    ec2.InitFile.fromString('/var/www/html/index.html', 'Hello! It\'s working!'),
  ),
});

Members ​

MemberDescription
SYSVINITUse SysVinit.
WINDOWSUse Windows.
SYSTEMDUse systemd.

Referenced by ​

  • InitServiceOptions.serviceManagerservice_managerserviceManagerServiceManagerServiceManager