Class: AWSCDK::EC2::InitCommandOptions

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ec2/init_command_options.rb

Overview

Options for InitCommand.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cwd: nil, env: nil, ignore_errors: nil, key: nil, service_restart_handles: nil, test_cmd: nil, wait_after_completion: nil) ⇒ InitCommandOptions

Returns a new instance of InitCommandOptions.

Parameters:

  • cwd (String, nil) (defaults to: nil)

    The working directory.

  • env (Hash{String => String}, nil) (defaults to: nil)

    Sets environment variables for the command.

  • ignore_errors (Boolean, nil) (defaults to: nil)

    Continue running if this command fails.

  • key (String, nil) (defaults to: nil)

    Identifier key for this command.

  • service_restart_handles (Array<AWSCDK::EC2::InitServiceRestartHandle>, nil) (defaults to: nil)

    Restart the given service(s) after this command has run.

  • test_cmd (String, nil) (defaults to: nil)

    Command to determine whether this command should be run.

  • wait_after_completion (AWSCDK::EC2::InitCommandWaitDuration, nil) (defaults to: nil)

    The duration to wait after a command has finished in case the command causes a reboot.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'ec2/init_command_options.rb', line 14

def initialize(cwd: nil, env: nil, ignore_errors: nil, key: nil, service_restart_handles: nil, test_cmd: nil, wait_after_completion: nil)
  @cwd = cwd
  Jsii::Type.check_type(@cwd, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "cwd") unless @cwd.nil?
  @env = env
  Jsii::Type.check_type(@env, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "env") unless @env.nil?
  @ignore_errors = ignore_errors
  Jsii::Type.check_type(@ignore_errors, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "ignoreErrors") unless @ignore_errors.nil?
  @key = key
  Jsii::Type.check_type(@key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") unless @key.nil?
  @service_restart_handles = service_restart_handles
  Jsii::Type.check_type(@service_restart_handles, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lYzIuSW5pdFNlcnZpY2VSZXN0YXJ0SGFuZGxlIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "serviceRestartHandles") unless @service_restart_handles.nil?
  @test_cmd = test_cmd
  Jsii::Type.check_type(@test_cmd, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "testCmd") unless @test_cmd.nil?
  @wait_after_completion = wait_after_completion
  Jsii::Type.check_type(@wait_after_completion, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRDb21tYW5kV2FpdER1cmF0aW9uIn0=")), "waitAfterCompletion") unless @wait_after_completion.nil?
end

Instance Attribute Details

#cwdString? (readonly)

Note:

Default: - Use default working directory

The working directory.

Returns:

  • (String, nil)


35
36
37
# File 'ec2/init_command_options.rb', line 35

def cwd
  @cwd
end

#envHash{String => String}? (readonly)

Note:

Default: - Use current environment

Sets environment variables for the command.

This property overwrites, rather than appends, the existing environment.

Returns:

  • (Hash{String => String}, nil)


42
43
44
# File 'ec2/init_command_options.rb', line 42

def env
  @env
end

#ignore_errorsBoolean? (readonly)

Note:

Default: false

Continue running if this command fails.

Returns:

  • (Boolean, nil)


47
48
49
# File 'ec2/init_command_options.rb', line 47

def ignore_errors
  @ignore_errors
end

#keyString? (readonly)

Note:

Default: - Automatically generated based on index

Identifier key for this command.

Commands are executed in lexicographical order of their key names.

Returns:

  • (String, nil)


54
55
56
# File 'ec2/init_command_options.rb', line 54

def key
  @key
end

#service_restart_handlesArray<AWSCDK::EC2::InitServiceRestartHandle>? (readonly)

Note:

Default: - Do not restart any service

Restart the given service(s) after this command has run.

Returns:



59
60
61
# File 'ec2/init_command_options.rb', line 59

def service_restart_handles
  @service_restart_handles
end

#test_cmdString? (readonly)

Note:

Default: - Always run the command

Command to determine whether this command should be run.

If the test passes (exits with error code of 0), the command is run.

Returns:

  • (String, nil)


66
67
68
# File 'ec2/init_command_options.rb', line 66

def test_cmd
  @test_cmd
end

#wait_after_completionAWSCDK::EC2::InitCommandWaitDuration? (readonly)

Note:

Default: - 60 seconds

The duration to wait after a command has finished in case the command causes a reboot.

Set this value to InitCommandWaitDuration.none() if you do not want to wait for every command; InitCommandWaitDuration.forever() directs cfn-init to exit and resume only after the reboot is complete.

For Windows systems only.



76
77
78
# File 'ec2/init_command_options.rb', line 76

def wait_after_completion
  @wait_after_completion
end

Class Method Details

.jsii_propertiesObject



78
79
80
81
82
83
84
85
86
87
88
# File 'ec2/init_command_options.rb', line 78

def self.jsii_properties
  {
    :cwd => "cwd",
    :env => "env",
    :ignore_errors => "ignoreErrors",
    :key => "key",
    :service_restart_handles => "serviceRestartHandles",
    :test_cmd => "testCmd",
    :wait_after_completion => "waitAfterCompletion",
  }
end

Instance Method Details

#to_jsiiObject



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'ec2/init_command_options.rb', line 90

def to_jsii
  result = {}
  result.merge!({
    "cwd" => @cwd,
    "env" => @env,
    "ignoreErrors" => @ignore_errors,
    "key" => @key,
    "serviceRestartHandles" => @service_restart_handles,
    "testCmd" => @test_cmd,
    "waitAfterCompletion" => @wait_after_completion,
  })
  result.compact
end