Class: AWSCDK::EC2::UserData
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::EC2::UserData
- Defined in:
- ec2/user_data.rb
Overview
Instance User Data.
Direct Known Subclasses
Class Method Summary collapse
-
.custom(content) ⇒ AWSCDK::EC2::UserData
Create a userdata object with custom content.
-
.for_linux(options = nil) ⇒ AWSCDK::EC2::UserData
Create a userdata object for Linux hosts.
- .for_operating_system(os) ⇒ AWSCDK::EC2::UserData
-
.for_windows(options = nil) ⇒ AWSCDK::EC2::UserData
Create a userdata object for Windows hosts.
- .jsii_overridable_methods ⇒ Object
Instance Method Summary collapse
-
#add_commands(*commands) ⇒ void
Add one or more commands to the user data.
-
#add_execute_file_command(params) ⇒ void
Adds commands to execute a file.
-
#add_on_exit_commands(*commands) ⇒ void
Add one or more commands to the user data that will run when the script exits.
-
#add_s3_download_command(params) ⇒ String
Adds commands to download a file from S3.
-
#add_signal_on_exit_command(resource) ⇒ void
Adds a command which will send a cfn-signal when the user data script ends.
-
#initialize ⇒ UserData
constructor
A new instance of UserData.
-
#render ⇒ String
Render the UserData for use in a construct.
Constructor Details
#initialize ⇒ UserData
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.
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.
36 37 38 39 40 |
# File 'ec2/user_data.rb', line 36 def self.for_linux( = nil) = .is_a?(Hash) ? ::AWSCDK::EC2::LinuxUserDataOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkxpbnV4VXNlckRhdGFPcHRpb25zIn0=")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.UserData", "forLinux", []) end |
.for_operating_system(os) ⇒ AWSCDK::EC2::UserData
44 45 46 47 |
# File 'ec2/user_data.rb', line 44 def self.(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.
53 54 55 56 57 |
# File 'ec2/user_data.rb', line 53 def self.for_windows( = nil) = .is_a?(Hash) ? ::AWSCDK::EC2::WindowsUserDataOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLldpbmRvd3NVc2VyRGF0YU9wdGlvbnMifQ==")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.UserData", "forWindows", []) end |
.jsii_overridable_methods ⇒ Object
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.
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.
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.
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.
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.
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 |
#render ⇒ String
Render the UserData for use in a construct.
113 114 115 |
# File 'ec2/user_data.rb', line 113 def render() jsii_call_method("render", []) end |