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.94.0 (build b380f01)", date="2024-03-01T20:58:23.351Z") @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");
 
  • 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(@Nullable WindowsUserDataOptions options)
      Create a userdata object for Windows hosts.

      Parameters:
      options -
    • 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.