Class InitService
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.InitElement
software.amazon.awscdk.services.ec2.InitService
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)",
date="2025-11-20T23:37:19.311Z")
@Stability(Stable)
public class InitService
extends InitElement
A services that be enabled, disabled or restarted when the instance is launched.
Example:
Bucket myBucket;
InitServiceRestartHandle handle = new InitServiceRestartHandle();
CloudFormationInit.fromElements(InitFile.fromString("/etc/nginx/nginx.conf", "...", InitFileOptions.builder().serviceRestartHandles(List.of(handle)).build()), InitSource.fromS3Object("/var/www/html", myBucket, "html.zip", InitSourceOptions.builder().serviceRestartHandles(List.of(handle)).build()), InitService.enable("nginx", InitServiceOptions.builder()
.serviceRestartHandle(handle)
.build()));
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedInitService(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic InitServiceDisable and stop the given service.static InitServiceEnable and start the given service, optionally restarting it.static InitServiceenable(String serviceName, InitServiceOptions options) Enable and start the given service, optionally restarting it.Returns the init element type for this element.static InitFilesystemdConfigFile(String serviceName, SystemdConfigFileOptions options) Install a systemd-compatible config file for the given service.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
InitService
protected InitService(software.amazon.jsii.JsiiObjectRef objRef) -
InitService
protected InitService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
disable
Disable and stop the given service.- Parameters:
serviceName- This parameter is required.
-
enable
@Stability(Stable) @NotNull public static InitService enable(@NotNull String serviceName, @Nullable InitServiceOptions options) Enable and start the given service, optionally restarting it.- Parameters:
serviceName- This parameter is required.options-
-
enable
Enable and start the given service, optionally restarting it.- Parameters:
serviceName- This parameter is required.
-
systemdConfigFile
@Stability(Stable) @NotNull public static InitFile systemdConfigFile(@NotNull String serviceName, @NotNull SystemdConfigFileOptions options) Install a systemd-compatible config file for the given service.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
InitFileto create exactly the configuration file you need at/etc/systemd/system/${serviceName}.service.- Parameters:
serviceName- This parameter is required.options- This parameter is required.
-
getElementType
Returns the init element type for this element.- Specified by:
getElementTypein classInitElement
-