Class MultipartUserData
Mime multipart user data.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class MultipartUserData : UserData
Syntax (vb)
Public Class MultipartUserData
Inherits UserData
Remarks
This class represents MIME multipart user data, as described in. Specifying Multiple User Data Blocks Using a MIME Multi Part Archive
ExampleMetadata: infused
Examples
var bootHookConf = UserData.ForLinux();
bootHookConf.AddCommands("cloud-init-per once docker_options echo 'OPTIONS=\"${OPTIONS} --storage-opt dm.basesize=40G\"' >> /etc/sysconfig/docker");
var setupCommands = UserData.ForLinux();
setupCommands.AddCommands("sudo yum install awscli && echo Packages installed らと > /var/tmp/setup");
var 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));
new LaunchTemplate(this, "", new LaunchTemplateProps {
UserData = multipartUserData,
BlockDevices = new [] { }
});
Synopsis
Constructors
MultipartUserData(IMultipartUserDataOptions) | |
MultipartUserData(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
MultipartUserData(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
AddCommands(String[]) | Add one or more commands to the user data. |
AddExecuteFileCommand(IExecuteFileOptions) | Adds commands to execute a file. |
AddOnExitCommands(String[]) | Add one or more commands to the user data that will run when the script exits. |
AddPart(MultipartBody) | Adds a part to the list of parts. |
AddS3DownloadCommand(IS3DownloadOptions) | Adds commands to download a file from S3. |
AddSignalOnExitCommand(Resource) | Adds a command which will send a cfn-signal when the user data script ends. |
AddUserDataPart(UserData, String, Nullable<Boolean>) | Adds a multipart part based on a UserData object. |
Render() | Render the UserData for use in a construct. |
Constructors
MultipartUserData(IMultipartUserDataOptions)
public MultipartUserData(IMultipartUserDataOptions opts = null)
Parameters
MultipartUserData(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected MultipartUserData(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
MultipartUserData(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected MultipartUserData(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
AddCommands(String[])
Add one or more commands to the user data.
public override void AddCommands(params string[] commands)
Parameters
- commands System.String[]
Overrides
AddExecuteFileCommand(IExecuteFileOptions)
Adds commands to execute a file.
public override void AddExecuteFileCommand(IExecuteFileOptions params)
Parameters
- params IExecuteFileOptions
Overrides
AddOnExitCommands(String[])
Add one or more commands to the user data that will run when the script exits.
public override void AddOnExitCommands(params string[] commands)
Parameters
- commands System.String[]
Overrides
AddPart(MultipartBody)
Adds a part to the list of parts.
public virtual void AddPart(MultipartBody part)
Parameters
- part MultipartBody
AddS3DownloadCommand(IS3DownloadOptions)
Adds commands to download a file from S3.
public override string AddS3DownloadCommand(IS3DownloadOptions params)
Parameters
- params IS3DownloadOptions
Returns
System.String
Overrides
AddSignalOnExitCommand(Resource)
Adds a command which will send a cfn-signal when the user data script ends.
public override void AddSignalOnExitCommand(Resource resource)
Parameters
- resource Resource
Overrides
AddUserDataPart(UserData, String, Nullable<Boolean>)
Adds a multipart part based on a UserData object.
public virtual void AddUserDataPart(UserData userData, string contentType = null, Nullable<bool> makeDefault = null)
Parameters
- userData UserData
- contentType System.String
- makeDefault System.Nullable<System.Boolean>
Remarks
If makeDefault
is true, then the UserData added by this method
will also be the target of calls to the add*Command
methods on
this MultipartUserData object.
If makeDefault
is false, then this is the same as calling:
MultipartUserData multiPart;
UserData userData;
string contentType;
multiPart.AddPart(MultipartBody.FromUserData(userData, contentType));
An undefined makeDefault
defaults to either:
Render()
Render the UserData for use in a construct.
public override string Render()
Returns
System.String