Class InitFile
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.InitElement
software.amazon.awscdk.services.ec2.InitFile
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:39.372Z")
@Stability(Stable)
public abstract class InitFile
extends InitElement
Create files on the EC2 instance.
Example:
Vpc vpc; InstanceType instanceType; IMachineImage machineImage; AutoScalingGroup.Builder.create(this, "ASG") .vpc(vpc) .instanceType(instanceType) .machineImage(machineImage) // ... .init(CloudFormationInit.fromElements(InitFile.fromString("/etc/my_instance", "This got written during instance startup"))) .signals(Signals.waitForAll(SignalsOptions.builder() .timeout(Duration.minutes(10)) .build())) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
ModifierConstructorDescriptionprotected
InitFile
(String fileName, InitFileOptions options) protected
InitFile
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
InitFile
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic InitFile
Create an asset from the given file.static InitFile
fromAsset
(String targetFileName, String path, InitFileAssetOptions options) Create an asset from the given file.static InitFile
fromExistingAsset
(String targetFileName, Asset asset) Use a file from an asset at instance startup time.static InitFile
fromExistingAsset
(String targetFileName, Asset asset, InitFileOptions options) Use a file from an asset at instance startup time.static InitFile
fromFileInline
(String targetFileName, String sourceFileName) Read a file from disk and use its contents.static InitFile
fromFileInline
(String targetFileName, String sourceFileName, InitFileOptions options) Read a file from disk and use its contents.static InitFile
fromObject
(String fileName, Map<String, ? extends Object> obj) Use a JSON-compatible object as the file content, write it to a JSON file.static InitFile
fromObject
(String fileName, Map<String, ? extends Object> obj, InitFileOptions options) Use a JSON-compatible object as the file content, write it to a JSON file.static InitFile
fromS3Object
(String fileName, IBucket bucket, String key) Download a file from an S3 bucket at instance startup time.static InitFile
fromS3Object
(String fileName, IBucket bucket, String key, InitFileOptions options) Download a file from an S3 bucket at instance startup time.static InitFile
fromString
(String fileName, String content) Use a literal string as the file content.static InitFile
fromString
(String fileName, String content, InitFileOptions options) Use a literal string as the file content.static InitFile
Download from a URL at instance startup time.static InitFile
fromUrl
(String fileName, String url, InitFileOptions options) Download from a URL at instance startup time.Returns the init element type for this element.static InitFile
Write a symlink with the given symlink target.static InitFile
symlink
(String fileName, String target, InitFileOptions options) Write a symlink with the given symlink target.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
InitFile
protected InitFile(software.amazon.jsii.JsiiObjectRef objRef) -
InitFile
protected InitFile(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
InitFile
- Parameters:
fileName
- This parameter is required.options
- This parameter is required.
-
-
Method Details
-
fromAsset
@Stability(Stable) @NotNull public static InitFile fromAsset(@NotNull String targetFileName, @NotNull String path, @Nullable InitFileAssetOptions options) Create an asset from the given file.This is appropriate for files that are too large to embed into the template.
- Parameters:
targetFileName
- This parameter is required.path
- This parameter is required.options
-
-
fromAsset
@Stability(Stable) @NotNull public static InitFile fromAsset(@NotNull String targetFileName, @NotNull String path) Create an asset from the given file.This is appropriate for files that are too large to embed into the template.
- Parameters:
targetFileName
- This parameter is required.path
- This parameter is required.
-
fromExistingAsset
@Stability(Stable) @NotNull public static InitFile fromExistingAsset(@NotNull String targetFileName, @NotNull Asset asset, @Nullable InitFileOptions options) Use a file from an asset at instance startup time.- Parameters:
targetFileName
- This parameter is required.asset
- This parameter is required.options
-
-
fromExistingAsset
@Stability(Stable) @NotNull public static InitFile fromExistingAsset(@NotNull String targetFileName, @NotNull Asset asset) Use a file from an asset at instance startup time.- Parameters:
targetFileName
- This parameter is required.asset
- This parameter is required.
-
fromFileInline
@Stability(Stable) @NotNull public static InitFile fromFileInline(@NotNull String targetFileName, @NotNull String sourceFileName, @Nullable InitFileOptions options) 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.
- Parameters:
targetFileName
- This parameter is required.sourceFileName
- This parameter is required.options
-
-
fromFileInline
@Stability(Stable) @NotNull public static InitFile fromFileInline(@NotNull String targetFileName, @NotNull String sourceFileName) 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.
- Parameters:
targetFileName
- This parameter is required.sourceFileName
- This parameter is required.
-
fromObject
@Stability(Stable) @NotNull public static InitFile fromObject(@NotNull String fileName, @NotNull Map<String, ? extends Object> obj, @Nullable InitFileOptions options) Use a JSON-compatible object as the file content, write it to a JSON file.May contain tokens.
- Parameters:
fileName
- This parameter is required.obj
- This parameter is required.options
-
-
fromObject
@Stability(Stable) @NotNull public static InitFile fromObject(@NotNull String fileName, @NotNull Map<String, ? extends Object> obj) Use a JSON-compatible object as the file content, write it to a JSON file.May contain tokens.
- Parameters:
fileName
- This parameter is required.obj
- This parameter is required.
-
fromS3Object
@Stability(Stable) @NotNull public static InitFile fromS3Object(@NotNull String fileName, @NotNull IBucket bucket, @NotNull String key, @Nullable InitFileOptions options) Download a file from an S3 bucket at instance startup time.- Parameters:
fileName
- This parameter is required.bucket
- This parameter is required.key
- This parameter is required.options
-
-
fromS3Object
@Stability(Stable) @NotNull public static InitFile fromS3Object(@NotNull String fileName, @NotNull IBucket bucket, @NotNull String key) Download a file from an S3 bucket at instance startup time.- Parameters:
fileName
- This parameter is required.bucket
- This parameter is required.key
- This parameter is required.
-
fromString
@Stability(Stable) @NotNull public static InitFile fromString(@NotNull String fileName, @NotNull String content, @Nullable InitFileOptions options) Use a literal string as the file content.- Parameters:
fileName
- This parameter is required.content
- This parameter is required.options
-
-
fromString
@Stability(Stable) @NotNull public static InitFile fromString(@NotNull String fileName, @NotNull String content) Use a literal string as the file content.- Parameters:
fileName
- This parameter is required.content
- This parameter is required.
-
fromUrl
@Stability(Stable) @NotNull public static InitFile fromUrl(@NotNull String fileName, @NotNull String url, @Nullable InitFileOptions options) Download from a URL at instance startup time.- Parameters:
fileName
- This parameter is required.url
- This parameter is required.options
-
-
fromUrl
@Stability(Stable) @NotNull public static InitFile fromUrl(@NotNull String fileName, @NotNull String url) Download from a URL at instance startup time.- Parameters:
fileName
- This parameter is required.url
- This parameter is required.
-
symlink
@Stability(Stable) @NotNull public static InitFile symlink(@NotNull String fileName, @NotNull String target, @Nullable InitFileOptions options) Write a symlink with the given symlink target.- Parameters:
fileName
- This parameter is required.target
- This parameter is required.options
-
-
symlink
@Stability(Stable) @NotNull public static InitFile symlink(@NotNull String fileName, @NotNull String target) Write a symlink with the given symlink target.- Parameters:
fileName
- This parameter is required.target
- This parameter is required.
-
getElementType
Returns the init element type for this element.- Specified by:
getElementType
in classInitElement
-