Class UserData
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.UserData
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
- Direct Known Subclasses:
MultipartUserData
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-12-11T23:26:32.504Z")
@Stability(Stable)
public abstract class UserData
extends software.amazon.jsii.JsiiObject
Instance User Data.
Example:
Cluster cluster; UserData userData = UserData.forLinux(); userData.addCommands("set -o xtrace", String.format("/etc/eks/bootstrap.sh %s", cluster.getClusterName())); CfnLaunchTemplate lt = CfnLaunchTemplate.Builder.create(this, "LaunchTemplate") .launchTemplateData(LaunchTemplateDataProperty.builder() .imageId("some-ami-id") // custom AMI .instanceType("t3.small") .userData(Fn.base64(userData.render())) .build()) .build(); cluster.addNodegroupCapacity("extra-ng", NodegroupOptions.builder() .launchTemplateSpec(LaunchTemplateSpec.builder() .id(lt.getRef()) .version(lt.getAttrLatestVersionNumber()) .build()) .build());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
addCommands
(@NotNull String... commands) Add one or more commands to the user data.abstract void
Adds commands to execute a file.abstract void
addOnExitCommands
(@NotNull String... commands) Add one or more commands to the user data that will run when the script exits.abstract String
Adds commands to download a file from S3.abstract void
addSignalOnExitCommand
(Resource resource) Adds a command which will send a cfn-signal when the user data script ends.static UserData
Create a userdata object with custom content.static UserData
forLinux()
Create a userdata object for Linux hosts.static UserData
forLinux
(LinuxUserDataOptions options) Create a userdata object for Linux hosts.static UserData
static UserData
Create a userdata object for Windows hosts.static UserData
forWindows
(WindowsUserDataOptions options) Create a userdata object for Windows hosts.abstract String
render()
Render the UserData for use in a construct.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
-
UserData
protected UserData(software.amazon.jsii.JsiiObjectRef objRef) -
UserData
protected UserData(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
UserData
@Stability(Stable) protected UserData()
-
-
Method Details
-
custom
Create a userdata object with custom content.- Parameters:
content
- This parameter is required.
-
forLinux
Create a userdata object for Linux hosts.- Parameters:
options
-
-
forLinux
Create a userdata object for Linux hosts. -
forOperatingSystem
@Stability(Stable) @NotNull public static UserData forOperatingSystem(@NotNull OperatingSystemType os) - Parameters:
os
- This parameter is required.
-
forWindows
@Stability(Stable) @NotNull public static UserData forWindows(@Nullable WindowsUserDataOptions options) Create a userdata object for Windows hosts.- Parameters:
options
-
-
forWindows
Create a userdata object for Windows hosts. -
addCommands
Add one or more commands to the user data.- Parameters:
commands
- This parameter is required.
-
addExecuteFileCommand
Adds commands to execute a file.- Parameters:
params
- This parameter is required.
-
addOnExitCommands
Add one or more commands to the user data that will run when the script exits.- Parameters:
commands
- This parameter is required.
-
addS3DownloadCommand
@Stability(Stable) @NotNull public abstract String addS3DownloadCommand(@NotNull S3DownloadOptions params) Adds commands to download a file from S3.- Parameters:
params
- This parameter is required.- Returns:
- : The local path that the file will be downloaded to
-
addSignalOnExitCommand
Adds a command which will send a cfn-signal when the user data script ends.- Parameters:
resource
- This parameter is required.
-
render
Render the UserData for use in a construct.
-