Show / Hide Table of Contents

Class InitServiceRestartHandle

An object that represents reasons to restart an InitService.

Inheritance
object
InitServiceRestartHandle
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class InitServiceRestartHandle : DeputyBase
Syntax (vb)
Public Class InitServiceRestartHandle Inherits DeputyBase
Remarks

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.

var handle = new InitServiceRestartHandle();
CloudFormationInit.FromElements(InitCommand.ShellCommand("/usr/bin/custom-nginx-install.sh", new InitCommandOptions { ServiceRestartHandles = new [] { handle } }), InitService.Enable("nginx", new InitServiceOptions { ServiceRestartHandle = handle }));

ExampleMetadata: infused

Examples
Bucket myBucket;


             var handle = new InitServiceRestartHandle();

             CloudFormationInit.FromElements(InitFile.FromString("/etc/nginx/nginx.conf", "...", new InitFileOptions { ServiceRestartHandles = new [] { handle } }), InitSource.FromS3Object("/var/www/html", myBucket, "html.zip", new InitSourceOptions { ServiceRestartHandles = new [] { handle } }), InitService.Enable("nginx", new InitServiceOptions {
                 ServiceRestartHandle = handle
             }));

Synopsis

Constructors

InitServiceRestartHandle()

An object that represents reasons to restart an InitService.

Constructors

InitServiceRestartHandle()

An object that represents reasons to restart an InitService.

public InitServiceRestartHandle()
Remarks

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.

var handle = new InitServiceRestartHandle();
CloudFormationInit.FromElements(InitCommand.ShellCommand("/usr/bin/custom-nginx-install.sh", new InitCommandOptions { ServiceRestartHandles = new [] { handle } }), InitService.Enable("nginx", new InitServiceOptions { ServiceRestartHandle = handle }));

ExampleMetadata: infused

Examples
Bucket myBucket;


             var handle = new InitServiceRestartHandle();

             CloudFormationInit.FromElements(InitFile.FromString("/etc/nginx/nginx.conf", "...", new InitFileOptions { ServiceRestartHandles = new [] { handle } }), InitSource.FromS3Object("/var/www/html", myBucket, "html.zip", new InitSourceOptions { ServiceRestartHandles = new [] { handle } }), InitService.Enable("nginx", new InitServiceOptions {
                 ServiceRestartHandle = handle
             }));
Back to top Generated by DocFX