aws-cdk-lib.aws_ec2.InitServiceOptions

interface InitServiceOptions

LanguageType name
.NETAmazon.CDK.AWS.EC2.InitServiceOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#InitServiceOptions
Javasoftware.amazon.awscdk.services.ec2.InitServiceOptions
Pythonaws_cdk.aws_ec2.InitServiceOptions
TypeScript (source)aws-cdk-lib » aws_ec2 » InitServiceOptions

Options for an InitService.

Example

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

NameTypeDescription
enabled?booleanEnable or disable this service.
ensureRunning?booleanMake sure this service is running or not running after cfn-init finishes.
serviceManager?ServiceManagerWhat service manager to use.
serviceRestartHandle?InitServiceRestartHandleRestart service when the actions registered into the restartHandle have been performed.

enabled?

Type: boolean (optional, default: true if used in InitService.enable(), no change to service state if used in InitService.fromOptions().)

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.


ensureRunning?

Type: boolean (optional, default: same value as enabled.)

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.


serviceManager?

Type: ServiceManager (optional, default: ServiceManager.SYSVINIT for Linux images, ServiceManager.WINDOWS for Windows images)

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.


serviceRestartHandle?

Type: InitServiceRestartHandle (optional, default: No files trigger restart)

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.