Class: AWSCDK::EC2::UserData

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

Overview

Instance User Data.

Direct Known Subclasses

MultipartUserData

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUserData

Returns a new instance of UserData.



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

def initialize
  Jsii::Object.instance_method(:initialize).bind(self).call
end

Class Method Details

.custom(content) ⇒ AWSCDK::EC2::UserData

Create a userdata object with custom content.

Parameters:

  • content (String)

Returns:

  • (AWSCDK::EC2::UserData)


27
28
29
30
# File 'ec2/user_data.rb', line 27

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

.for_linux(options = nil) ⇒ AWSCDK::EC2::UserData

Create a userdata object for Linux hosts.

Parameters:

Returns:

  • (AWSCDK::EC2::UserData)


36
37
38
39
40
# File 'ec2/user_data.rb', line 36

def self.for_linux(options = nil)
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::LinuxUserDataOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkxpbnV4VXNlckRhdGFPcHRpb25zIn0=")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.UserData", "forLinux", [options])
end

.for_operating_system(os) ⇒ AWSCDK::EC2::UserData

Parameters:

Returns:

  • (AWSCDK::EC2::UserData)


44
45
46
47
# File 'ec2/user_data.rb', line 44

def self.for_operating_system(os)
  Jsii::Type.check_type(os, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLk9wZXJhdGluZ1N5c3RlbVR5cGUifQ==")), "os")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.UserData", "forOperatingSystem", [os])
end

.for_windows(options = nil) ⇒ AWSCDK::EC2::UserData

Create a userdata object for Windows hosts.

Parameters:

Returns:

  • (AWSCDK::EC2::UserData)


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

def self.for_windows(options = nil)
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::WindowsUserDataOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLldpbmRvd3NVc2VyRGF0YU9wdGlvbnMifQ==")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.UserData", "forWindows", [options])
end

.jsii_overridable_methodsObject



12
13
14
15
16
17
18
19
20
21
# File 'ec2/user_data.rb', line 12

def self.jsii_overridable_methods
  {
    :add_commands => { kind: :method, name: "addCommands", is_optional: false },
    :add_execute_file_command => { kind: :method, name: "addExecuteFileCommand", is_optional: false },
    :add_on_exit_commands => { kind: :method, name: "addOnExitCommands", is_optional: false },
    :add_s3_download_command => { kind: :method, name: "addS3DownloadCommand", is_optional: false },
    :add_signal_on_exit_command => { kind: :method, name: "addSignalOnExitCommand", is_optional: false },
    :render => { kind: :method, name: "render", is_optional: false },
  }
end

Instance Method Details

#add_commands(*commands) ⇒ void

This method returns an undefined value.

Add one or more commands to the user data.

Parameters:

  • commands (Array<String>)


63
64
65
66
67
68
# File 'ec2/user_data.rb', line 63

def add_commands(*commands)
  commands.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "commands[#{index}]")
  end
  jsii_call_method("addCommands", [*commands])
end

#add_execute_file_command(params) ⇒ void

This method returns an undefined value.

Adds commands to execute a file.

Parameters:



74
75
76
77
78
# File 'ec2/user_data.rb', line 74

def add_execute_file_command(params)
  params = params.is_a?(Hash) ? ::AWSCDK::EC2::ExecuteFileOptions.new(**params.transform_keys(&:to_sym)) : params
  Jsii::Type.check_type(params, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkV4ZWN1dGVGaWxlT3B0aW9ucyJ9")), "params")
  jsii_call_method("addExecuteFileCommand", [params])
end

#add_on_exit_commands(*commands) ⇒ void

This method returns an undefined value.

Add one or more commands to the user data that will run when the script exits.

Parameters:

  • commands (Array<String>)


84
85
86
87
88
89
# File 'ec2/user_data.rb', line 84

def add_on_exit_commands(*commands)
  commands.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "commands[#{index}]")
  end
  jsii_call_method("addOnExitCommands", [*commands])
end

#add_s3_download_command(params) ⇒ String

Adds commands to download a file from S3.

Parameters:

Returns:

  • (String)

    : The local path that the file will be downloaded to



95
96
97
98
99
# File 'ec2/user_data.rb', line 95

def add_s3_download_command(params)
  params = params.is_a?(Hash) ? ::AWSCDK::EC2::S3DownloadOptions.new(**params.transform_keys(&:to_sym)) : params
  Jsii::Type.check_type(params, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlMzRG93bmxvYWRPcHRpb25zIn0=")), "params")
  jsii_call_method("addS3DownloadCommand", [params])
end

#add_signal_on_exit_command(resource) ⇒ void

This method returns an undefined value.

Adds a command which will send a cfn-signal when the user data script ends.

Parameters:



105
106
107
108
# File 'ec2/user_data.rb', line 105

def add_signal_on_exit_command(resource)
  Jsii::Type.check_type(resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZXNvdXJjZSJ9")), "resource")
  jsii_call_method("addSignalOnExitCommand", [resource])
end

#renderString

Render the UserData for use in a construct.

Returns:

  • (String)


113
114
115
# File 'ec2/user_data.rb', line 113

def render()
  jsii_call_method("render", [])
end