Class: AWSCDK::EC2::InitService
- Inherits:
-
InitElement
- Object
- InitElement
- AWSCDK::EC2::InitService
- Defined in:
- ec2/init_service.rb
Overview
A services that be enabled, disabled or restarted when the instance is launched.
Class Method Summary collapse
-
.disable(service_name) ⇒ AWSCDK::EC2::InitService
Disable and stop the given service.
-
.enable(service_name, options = nil) ⇒ AWSCDK::EC2::InitService
Enable and start the given service, optionally restarting it.
- .jsii_overridable_methods ⇒ Object
-
.systemd_config_file(service_name, options) ⇒ AWSCDK::EC2::InitFile
Install a systemd-compatible config file for the given service.
Instance Method Summary collapse
-
#element_type ⇒ String
Returns the init element type for this element.
-
#initialize(*args) ⇒ InitService
constructor
A new instance of InitService.
Constructor Details
#initialize(*args) ⇒ InitService
Returns a new instance of InitService.
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.
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.
32 33 34 35 36 37 |
# File 'ec2/init_service.rb', line 32 def self.enable(service_name, = nil) Jsii::Type.check_type(service_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "serviceName") = .is_a?(Hash) ? ::AWSCDK::EC2::InitServiceOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRTZXJ2aWNlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitService", "enable", [service_name, ]) end |
.jsii_overridable_methods ⇒ Object
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.
52 53 54 55 56 57 |
# File 'ec2/init_service.rb', line 52 def self.systemd_config_file(service_name, ) Jsii::Type.check_type(service_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "serviceName") = .is_a?(Hash) ? ::AWSCDK::EC2::SystemdConfigFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN5c3RlbWRDb25maWdGaWxlT3B0aW9ucyJ9")), "options") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitService", "systemdConfigFile", [service_name, ]) end |
Instance Method Details
#element_type ⇒ String
Returns the init element type for this element.
62 63 64 |
# File 'ec2/init_service.rb', line 62 def element_type() jsii_get_property("elementType") end |