Show / Hide Table of Contents

Class InitService

A services that be enabled, disabled or restarted when the instance is launched.

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

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

Properties

ElementType

Returns the init element type for this element.

Methods

Disable(string)

Disable and stop the given service.

Enable(string, IInitServiceOptions?)

Enable and start the given service, optionally restarting it.

SystemdConfigFile(string, ISystemdConfigFileOptions)

Install a systemd-compatible config file for the given service.

Properties

ElementType

Returns the init element type for this element.

public override string ElementType { get; }
Property Value

string

Overrides
InitElement.ElementType
Remarks

ExampleMetadata: infused

Methods

Disable(string)

Disable and stop the given service.

public static InitService Disable(string serviceName)
Parameters
serviceName string
Returns

InitService

Remarks

ExampleMetadata: infused

Enable(string, IInitServiceOptions?)

Enable and start the given service, optionally restarting it.

public static InitService Enable(string serviceName, IInitServiceOptions? options = null)
Parameters
serviceName string
options IInitServiceOptions
Returns

InitService

Remarks

ExampleMetadata: infused

SystemdConfigFile(string, ISystemdConfigFileOptions)

Install a systemd-compatible config file for the given service.

public static InitFile SystemdConfigFile(string serviceName, ISystemdConfigFileOptions options)
Parameters
serviceName string
options ISystemdConfigFileOptions
Returns

InitFile

Remarks

This is a helper function to create a simple systemd configuration file that will allow running a service on the machine using InitService.enable().

Systemd allows many configuration options; this function does not pretend to expose all of them. If you need advanced configuration options, you can use InitFile to create exactly the configuration file you need at /etc/systemd/system/${serviceName}.service.

Back to top Generated by DocFX