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 Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMultipartUserData(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedMultipartUserData(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommands(String... commands) Add one or more commands to the user data.voidAdds commands to execute a file.voidaddOnExitCommands(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.UserData
custom, forLinux, forLinux, forOperatingSystem, forWindows, forWindowsMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
MultipartUserData
protected MultipartUserData(software.amazon.jsii.JsiiObjectRef objRef) -
MultipartUserData
protected MultipartUserData(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
MultipartUserData
- Parameters:
opts-
-
MultipartUserData
@Stability(Stable) public MultipartUserData()
-
-
Method Details
-
addCommands
Add one or more commands to the user data.- Specified by:
addCommandsin classUserData- Parameters:
commands- This parameter is required.
-
addExecuteFileCommand
Adds commands to execute a file.- Specified by:
addExecuteFileCommandin classUserData- Parameters:
params- This parameter is required.
-
addOnExitCommands
Add one or more commands to the user data that will run when the script exits.- Specified by:
addOnExitCommandsin classUserData- Parameters:
commands- This parameter is required.
-
addPart
Adds a part to the list of parts.- Parameters:
part- This parameter is required.
-
addS3DownloadCommand
Adds commands to download a file from S3.- Specified by:
addS3DownloadCommandin classUserData- 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.- Specified by:
addSignalOnExitCommandin classUserData- 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; orfalseif 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; orfalseif there is no default UserData set.
- Parameters:
userData- This parameter is required.contentType-
-
addUserDataPart
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; orfalseif there is no default UserData set.
- Parameters:
userData- This parameter is required.
-
render
Render the UserData for use in a construct.
-