ServiceManager

class aws_cdk.aws_ec2.ServiceManager(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

The service manager that will be used by InitServices.

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

ExampleMetadata:

infused

Example:

# vpc: ec2.Vpc
# instance_type: ec2.InstanceType


ec2.Instance(self, "Instance",
    vpc=vpc,
    instance_type=instance_type,
    machine_image=ec2.MachineImage.latest_amazon_linux2023(),

    init=ec2.CloudFormationInit.from_elements(
        # Create a simple config file that runs a Python web server
        ec2.InitService.systemd_config_file("simpleserver",
            command="/usr/bin/python3 -m http.server 8080",
            cwd="/var/www/html"
        ),
        # Start the server using SystemD
        ec2.InitService.enable("simpleserver",
            service_manager=ec2.ServiceManager.SYSTEMD
        ),
        # Drop an example file to show the web server working
        ec2.InitFile.from_string("/var/www/html/index.html", "Hello! It's working!"))
)

Attributes

SYSTEMD

Use systemd.

SYSVINIT

Use SysVinit.

This is the default for Linux systems.

WINDOWS

Use Windows.

This is the default for Windows systems.