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.84.0 (build 5404dcf)", date="2023-06-19T16:30:39.546Z") @Stability(Stable) public abstract class UserData extends software.amazon.jsii.JsiiObject
Instance User Data.

Example:

 MultipartUserData multipartUserData = new MultipartUserData();
 UserData commandsUserData = UserData.forLinux();
 multipartUserData.addUserDataPart(commandsUserData, MultipartBody.SHELL_SCRIPT, true);
 // Adding commands to the multipartUserData adds them to commandsUserData, and vice-versa.
 multipartUserData.addCommands("touch /root/multi.txt");
 commandsUserData.addCommands("touch /root/userdata.txt");
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    UserData(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    UserData(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract 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
    Adds a command which will send a cfn-signal when the user data script ends.
    static UserData
    custom(String content)
    Create a userdata object with custom content.
    static UserData
    Create a userdata object for Linux hosts.
    static UserData
    Create a userdata object for Linux hosts.
    static UserData
     
    static UserData
    Create a userdata object for Windows hosts.
    abstract String
    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

      @Stability(Stable) @NotNull public static UserData custom(@NotNull String content)
      Create a userdata object with custom content.

      Parameters:
      content - This parameter is required.
    • forLinux

      @Stability(Stable) @NotNull public static UserData forLinux(@Nullable LinuxUserDataOptions options)
      Create a userdata object for Linux hosts.

      Parameters:
      options -
    • forLinux

      @Stability(Stable) @NotNull public static UserData 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()
      Create a userdata object for Windows hosts.
    • addCommands

      @Stability(Stable) public abstract void addCommands(@NotNull @NotNull String... commands)
      Add one or more commands to the user data.

      Parameters:
      commands - This parameter is required.
    • addExecuteFileCommand

      @Stability(Stable) public abstract void addExecuteFileCommand(@NotNull ExecuteFileOptions params)
      Adds commands to execute a file.

      Parameters:
      params - This parameter is required.
    • addOnExitCommands

      @Stability(Stable) public abstract void addOnExitCommands(@NotNull @NotNull String... commands)
      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

      @Stability(Stable) public abstract void addSignalOnExitCommand(@NotNull Resource resource)
      Adds a command which will send a cfn-signal when the user data script ends.

      Parameters:
      resource - This parameter is required.
    • render

      @Stability(Stable) @NotNull public abstract String render()
      Render the UserData for use in a construct.