# InitServiceRestartHandle

An object that represents reasons to restart an InitService.

Pass an instance of this object to the `InitFile`, `InitCommand`,
`InitSource` and `InitPackage` objects, and finally to an `InitService`
itself to cause the actions (files, commands, sources, and packages)
to trigger a restart of the service.

For example, the following will run a custom command to install Nginx,
and trigger the nginx service to be restarted after the command has run.

```ts
const handle = new ec2.InitServiceRestartHandle();
ec2.CloudFormationInit.fromElements(
  ec2.InitCommand.shellCommand('/usr/bin/custom-nginx-install.sh', { serviceRestartHandles: [handle] }),
  ec2.InitService.enable('nginx', { serviceRestartHandle: handle }),
);
```

- Source: [`aws-ec2/lib/cfn-init-elements.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts#L30)

## 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,
  })
);
```

## Initializer

```ts
new InitServiceRestartHandle()
```
