InitServiceOptions

class aws_cdk.aws_ec2.InitServiceOptions(*, enabled=None, ensure_running=None, service_manager=None, service_restart_handle=None)

Bases: object

Options for an InitService.

Parameters:
  • enabled (Optional[bool]) – Enable or disable this service. 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. Default: - true if used in InitService.enable(), no change to service state if used in InitService.fromOptions().

  • ensure_running (Optional[bool]) – Make sure this service is running or not running after cfn-init finishes. 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. Default: - same value as enabled.

  • service_manager (Optional[ServiceManager]) – What service manager to use. This needs to match the actual service manager on your Operating System. For example, Amazon Linux 1 uses SysVinit, but Amazon Linux 2 uses Systemd. Default: ServiceManager.SYSVINIT for Linux images, ServiceManager.WINDOWS for Windows images

  • service_restart_handle (Optional[InitServiceRestartHandle]) – Restart service when the actions registered into the restartHandle have been performed. Register actions into the restartHandle by passing it to InitFile, InitCommand, InitPackage and InitSource objects. Default: - No files trigger restart

ExampleMetadata:

infused

Example:

# my_bucket: s3.Bucket


handle = ec2.InitServiceRestartHandle()

ec2.CloudFormationInit.from_elements(
    ec2.InitFile.from_string("/etc/nginx/nginx.conf", "...", service_restart_handles=[handle]),
    ec2.InitSource.from_s3_object("/var/www/html", my_bucket, "html.zip", service_restart_handles=[handle]),
    ec2.InitService.enable("nginx",
        service_restart_handle=handle
    ))

Attributes

enabled

Enable or disable this service.

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.

Default:

  • true if used in InitService.enable(), no change to service

state if used in InitService.fromOptions().

ensure_running

Make sure this service is running or not running after cfn-init finishes.

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.

Default:
  • same value as enabled.

service_manager

What service manager to use.

This needs to match the actual service manager on your Operating System. For example, Amazon Linux 1 uses SysVinit, but Amazon Linux 2 uses Systemd.

Default:

ServiceManager.SYSVINIT for Linux images, ServiceManager.WINDOWS for Windows images

service_restart_handle

Restart service when the actions registered into the restartHandle have been performed.

Register actions into the restartHandle by passing it to InitFile, InitCommand, InitPackage and InitSource objects.

Default:
  • No files trigger restart