Skip to content
v2.274.0

InitServiceOptions Struct ​

Options for an InitService.

Example ​

ts
declare const myBucket: s3.Bucket;

const handle = new ec2.InitServiceRestartHandle();

ec2.CloudFormationInit.fromElements(
  ec2.InitFile.fromString('/etc/nginx/nginx.conf', '...', { serviceRestartHandles: [handle] }),
  ec2.InitSource.fromS3Object('/var/www/html', myBucket, 'html.zip', { serviceRestartHandles: [handle] }),
  ec2.InitService.enable('nginx', {
    serviceRestartHandle: handle,
  })
);

Properties ​

enabledoptionalbooleanenabledoptionalboolenabledoptionalBooleanEnabledoptionalboolEnabledoptional*bool#
Enable or disable this service.

Default: true if used in InitService.enable(), no change to service state if used in InitService.fromOptions().

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.

ensureRunningoptionalbooleanensure_runningoptionalboolensureRunningoptionalBooleanEnsureRunningoptionalboolEnsureRunningoptional*bool#
Make sure this service is running or not running after cfn-init finishes.

Default: same value as enabled.

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.

serviceManageroptionalServiceManagerservice_manageroptionalServiceManagerserviceManageroptionalServiceManagerServiceManageroptionalServiceManagerServiceManageroptionalServiceManager#
What service manager to use.

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

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.

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

Default: No files trigger restart

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