Class MultipartUserData
- All Implemented Interfaces:
- software.amazon.jsii.JsiiSerializable
This class represents MIME multipart user data, as described in. Specifying Multiple User Data Blocks Using a MIME Multi Part Archive
Example:
 UserData bootHookConf = UserData.forLinux();
 bootHookConf.addCommands("cloud-init-per once docker_options echo 'OPTIONS=\"${OPTIONS} --storage-opt dm.basesize=40G\"' >> /etc/sysconfig/docker");
 UserData setupCommands = UserData.forLinux();
 setupCommands.addCommands("sudo yum install awscli && echo Packages installed らと > /var/tmp/setup");
 MultipartUserData multipartUserData = new MultipartUserData();
 // The docker has to be configured at early stage, so content type is overridden to boothook
 multipartUserData.addPart(MultipartBody.fromUserData(bootHookConf, "text/cloud-boothook; charset=\"us-ascii\""));
 // Execute the rest of setup
 multipartUserData.addPart(MultipartBody.fromUserData(setupCommands));
 LaunchTemplate.Builder.create(this, "")
         .userData(multipartUserData)
         .blockDevices(List.of())
         .build();
 - 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObjectsoftware.amazon.jsii.JsiiObject.InitializationMode
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedMultipartUserData(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedMultipartUserData(software.amazon.jsii.JsiiObjectRef objRef) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddCommands(@NotNull String... commands) Add one or more commands to the user data.voidAdds commands to execute a file.voidaddOnExitCommands(@NotNull String... commands) Add one or more commands to the user data that will run when the script exits.voidaddPart(MultipartBody part) Adds a part to the list of parts.Adds commands to download a file from S3.voidaddSignalOnExitCommand(Resource resource) Adds a command which will send a cfn-signal when the user data script ends.voidaddUserDataPart(UserData userData) Adds a multipart part based on a UserData object.voidaddUserDataPart(UserData userData, String contentType) Adds a multipart part based on a UserData object.voidaddUserDataPart(UserData userData, String contentType, Boolean makeDefault) Adds a multipart part based on a UserData object.render()Render the UserData for use in a construct.Methods inherited from class software.amazon.awscdk.services.ec2.UserDatacustom, forLinux, forLinux, forOperatingSystem, forWindowsMethods inherited from class software.amazon.jsii.JsiiObjectjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable$jsii$toJson
- 
Constructor Details- 
MultipartUserDataprotected MultipartUserData(software.amazon.jsii.JsiiObjectRef objRef) 
- 
MultipartUserDataprotected MultipartUserData(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) 
- 
MultipartUserData- Parameters:
- opts-
 
- 
MultipartUserData@Stability(Stable) public MultipartUserData()
 
- 
- 
Method Details- 
addCommandsAdd one or more commands to the user data.- Specified by:
- addCommandsin class- UserData
- Parameters:
- commands- This parameter is required.
 
- 
addExecuteFileCommandAdds commands to execute a file.- Specified by:
- addExecuteFileCommandin class- UserData
- Parameters:
- params- This parameter is required.
 
- 
addOnExitCommandsAdd one or more commands to the user data that will run when the script exits.- Specified by:
- addOnExitCommandsin class- UserData
- Parameters:
- commands- This parameter is required.
 
- 
addPartAdds a part to the list of parts.- Parameters:
- part- This parameter is required.
 
- 
addS3DownloadCommandAdds commands to download a file from S3.- Specified by:
- addS3DownloadCommandin class- UserData
- Parameters:
- params- This parameter is required.
- Returns:
- : The local path that the file will be downloaded to
 
- 
addSignalOnExitCommandAdds a command which will send a cfn-signal when the user data script ends.- Specified by:
- addSignalOnExitCommandin class- UserData
- Parameters:
- resource- This parameter is required.
 
- 
addUserDataPart@Stability(Stable) public void addUserDataPart(@NotNull UserData userData, @Nullable String contentType, @Nullable Boolean makeDefault) Adds a multipart part based on a UserData object.If makeDefaultis true, then the UserData added by this method will also be the target of calls to theadd*Commandmethods on this MultipartUserData object.If makeDefaultis false, then this is the same as calling:MultipartUserData multiPart; UserData userData; String contentType; multiPart.addPart(MultipartBody.fromUserData(userData, contentType)); An undefined makeDefaultdefaults to either:- trueif no default UserData has been set yet; or
- falseif there is no default UserData set.
 - Parameters:
- userData- This parameter is required.
- contentType-
- makeDefault-
 
- 
addUserDataPart@Stability(Stable) public void addUserDataPart(@NotNull UserData userData, @Nullable String contentType) Adds a multipart part based on a UserData object.If makeDefaultis true, then the UserData added by this method will also be the target of calls to theadd*Commandmethods on this MultipartUserData object.If makeDefaultis false, then this is the same as calling:MultipartUserData multiPart; UserData userData; String contentType; multiPart.addPart(MultipartBody.fromUserData(userData, contentType)); An undefined makeDefaultdefaults to either:- trueif no default UserData has been set yet; or
- falseif there is no default UserData set.
 - Parameters:
- userData- This parameter is required.
- contentType-
 
- 
addUserDataPartAdds a multipart part based on a UserData object.If makeDefaultis true, then the UserData added by this method will also be the target of calls to theadd*Commandmethods on this MultipartUserData object.If makeDefaultis false, then this is the same as calling:MultipartUserData multiPart; UserData userData; String contentType; multiPart.addPart(MultipartBody.fromUserData(userData, contentType)); An undefined makeDefaultdefaults to either:- trueif no default UserData has been set yet; or
- falseif there is no default UserData set.
 - Parameters:
- userData- This parameter is required.
 
- 
renderRender the UserData for use in a construct.
 
-