Class: AWSCDK::EC2::InitFile
- Inherits:
-
InitElement
- Object
- InitElement
- AWSCDK::EC2::InitFile
- Defined in:
- ec2/init_file.rb
Overview
Create files on the EC2 instance.
Class Method Summary collapse
-
.from_asset(target_file_name, path, options = nil) ⇒ AWSCDK::EC2::InitFile
Create an asset from the given file.
-
.from_existing_asset(target_file_name, asset, options = nil) ⇒ AWSCDK::EC2::InitFile
Use a file from an asset at instance startup time.
-
.from_file_inline(target_file_name, source_file_name, options = nil) ⇒ AWSCDK::EC2::InitFile
Read a file from disk and use its contents.
-
.from_object(file_name, obj, options = nil) ⇒ AWSCDK::EC2::InitFile
Use a JSON-compatible object as the file content, write it to a JSON file.
-
.from_s3_object(file_name, bucket, key, options = nil) ⇒ AWSCDK::EC2::InitFile
Download a file from an S3 bucket at instance startup time.
-
.from_string(file_name, content, options = nil) ⇒ AWSCDK::EC2::InitFile
Use a literal string as the file content.
-
.from_url(file_name, url, options = nil) ⇒ AWSCDK::EC2::InitFile
Download from a URL at instance startup time.
- .jsii_overridable_methods ⇒ Object
-
.symlink(file_name, target, options = nil) ⇒ AWSCDK::EC2::InitFile
Write a symlink with the given symlink target.
Instance Method Summary collapse
-
#element_type ⇒ String
Returns the init element type for this element.
-
#initialize(file_name, options) ⇒ InitFile
constructor
A new instance of InitFile.
Constructor Details
#initialize(file_name, options) ⇒ InitFile
Returns a new instance of InitFile.
10 11 12 13 14 15 |
# File 'ec2/init_file.rb', line 10 def initialize(file_name, ) = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName") Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") Jsii::Object.instance_method(:initialize).bind(self).call(file_name, ) end |
Class Method Details
.from_asset(target_file_name, path, options = nil) ⇒ AWSCDK::EC2::InitFile
Create an asset from the given file.
This is appropriate for files that are too large to embed into the template.
31 32 33 34 35 36 37 |
# File 'ec2/init_file.rb', line 31 def self.from_asset(target_file_name, path, = nil) Jsii::Type.check_type(target_file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "targetFileName") Jsii::Type.check_type(path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "path") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileAssetOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlQXNzZXRPcHRpb25zIn0=")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromAsset", [target_file_name, path, ]) end |
.from_existing_asset(target_file_name, asset, options = nil) ⇒ AWSCDK::EC2::InitFile
Use a file from an asset at instance startup time.
45 46 47 48 49 50 51 |
# File 'ec2/init_file.rb', line 45 def self.from_existing_asset(target_file_name, asset, = nil) Jsii::Type.check_type(target_file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "targetFileName") Jsii::Type.check_type(asset, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfczNfYXNzZXRzLkFzc2V0In0=")), "asset") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromExistingAsset", [target_file_name, asset, ]) end |
.from_file_inline(target_file_name, source_file_name, options = nil) ⇒ AWSCDK::EC2::InitFile
Read a file from disk and use its contents.
The file will be embedded in the template, so care should be taken to not exceed the template size.
If options.base64encoded is set to true, this will base64-encode the file's contents.
64 65 66 67 68 69 70 |
# File 'ec2/init_file.rb', line 64 def self.from_file_inline(target_file_name, source_file_name, = nil) Jsii::Type.check_type(target_file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "targetFileName") Jsii::Type.check_type(source_file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "sourceFileName") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromFileInline", [target_file_name, source_file_name, ]) end |
.from_object(file_name, obj, options = nil) ⇒ AWSCDK::EC2::InitFile
Use a JSON-compatible object as the file content, write it to a JSON file.
May contain tokens.
80 81 82 83 84 85 86 |
# File 'ec2/init_file.rb', line 80 def self.from_object(file_name, obj, = nil) Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName") Jsii::Type.check_type(obj, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6ImFueSJ9LCJraW5kIjoibWFwIn19")), "obj") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromObject", [file_name, obj, ]) end |
.from_s3_object(file_name, bucket, key, options = nil) ⇒ AWSCDK::EC2::InitFile
Download a file from an S3 bucket at instance startup time.
95 96 97 98 99 100 101 102 |
# File 'ec2/init_file.rb', line 95 def self.from_s3_object(file_name, bucket, key, = nil) Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName") Jsii::Type.check_type(bucket, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfczMuSUJ1Y2tldCJ9")), "bucket") Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromS3Object", [file_name, bucket, key, ]) end |
.from_string(file_name, content, options = nil) ⇒ AWSCDK::EC2::InitFile
Use a literal string as the file content.
110 111 112 113 114 115 116 |
# File 'ec2/init_file.rb', line 110 def self.from_string(file_name, content, = nil) Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName") Jsii::Type.check_type(content, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "content") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromString", [file_name, content, ]) end |
.from_url(file_name, url, options = nil) ⇒ AWSCDK::EC2::InitFile
Download from a URL at instance startup time.
124 125 126 127 128 129 130 |
# File 'ec2/init_file.rb', line 124 def self.from_url(file_name, url, = nil) Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName") Jsii::Type.check_type(url, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "url") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "fromUrl", [file_name, url, ]) end |
.jsii_overridable_methods ⇒ Object
17 18 19 20 21 |
# File 'ec2/init_file.rb', line 17 def self.jsii_overridable_methods { :element_type => { kind: :property, name: "elementType", is_optional: false }, } end |
.symlink(file_name, target, options = nil) ⇒ AWSCDK::EC2::InitFile
Write a symlink with the given symlink target.
138 139 140 141 142 143 144 |
# File 'ec2/init_file.rb', line 138 def self.symlink(file_name, target, = nil) Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName") Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "target") = .is_a?(Hash) ? ::AWSCDK::EC2::InitFileOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRGaWxlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.InitFile", "symlink", [file_name, target, ]) end |
Instance Method Details
#element_type ⇒ String
Returns the init element type for this element.
149 150 151 |
# File 'ec2/init_file.rb', line 149 def element_type() jsii_get_property("elementType") end |