Class: AWSCDK::EC2::InitService

Inherits:
InitElement
  • Object
show all
Defined in:
ec2/init_service.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ InitService

Returns a new instance of InitService.

Raises:

  • (NoMethodError)


8
9
10
# File 'ec2/init_service.rb', line 8

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.aws_ec2.InitService does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.disable(service_name) ⇒ AWSCDK::EC2::InitService

Disable and stop the given service.

Parameters:

  • service_name (String)

Returns:

  • (AWSCDK::EC2::InitService)


22
23
24
25
# File 'ec2/init_service.rb', line 22

def self.disable(service_name)
  Jsii::Type.check_type(service_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "serviceName")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitService", "disable", [service_name])
end

.enable(service_name, options = nil) ⇒ AWSCDK::EC2::InitService

Enable and start the given service, optionally restarting it.

Parameters:

Returns:

  • (AWSCDK::EC2::InitService)


32
33
34
35
36
37
# File 'ec2/init_service.rb', line 32

def self.enable(service_name, options = nil)
  Jsii::Type.check_type(service_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "serviceName")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::InitServiceOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRTZXJ2aWNlT3B0aW9ucyJ9")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitService", "enable", [service_name, options])
end

.jsii_overridable_methodsObject



12
13
14
15
16
# File 'ec2/init_service.rb', line 12

def self.jsii_overridable_methods
  {
    :element_type => { kind: :property, name: "elementType", is_optional: false },
  }
end

.systemd_config_file(service_name, options) ⇒ AWSCDK::EC2::InitFile

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 InitFile to create exactly the configuration file you need at /etc/systemd/system/${serviceName}.service.

Parameters:

Returns:



52
53
54
55
56
57
# File 'ec2/init_service.rb', line 52

def self.systemd_config_file(service_name, options)
  Jsii::Type.check_type(service_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "serviceName")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::SystemdConfigFileOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN5c3RlbWRDb25maWdGaWxlT3B0aW9ucyJ9")), "options")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitService", "systemdConfigFile", [service_name, options])
end

Instance Method Details

#element_typeString

Returns the init element type for this element.

Returns:

  • (String)


62
63
64
# File 'ec2/init_service.rb', line 62

def element_type()
  jsii_get_property("elementType")
end