Skip to content
v2.273.0

MultipartBody Class ​

The base class for all classes which can be used as MultipartUserData.

Example ​

ts
const multipartUserData = new ec2.MultipartUserData();
const commandsUserData = ec2.UserData.forLinux();
multipartUserData.addUserDataPart(commandsUserData, ec2.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');

Initializer ​

ts
new MultipartBody()
python
MultipartBody()
java
new MultipartBody()
csharp
new MultipartBody()
go
NewMultipartBody()

Properties ​

CLOUD_BOOTHOOKstringcloud_boothookstrCLOUD_BOOTHOOKStringCLOUD_BOOTHOOKstringCLOUD_BOOTHOOK*stringrequiredstatic#
Content type for boot hooks.
SHELL_SCRIPTstringshell_scriptstrSHELL_SCRIPTStringSHELL_SCRIPTstringSHELL_SCRIPT*stringrequiredstatic#
Content type for shell scripts.

Methods ​

fromRawBody(opts: MultipartBodyOptions): MultipartBody // chainable@staticmethod def from_raw_body(opts: MultipartBodyOptions) -> MultipartBodypublic static MultipartBody fromRawBody(MultipartBodyOptions opts)public static MultipartBody FromRawBody(MultipartBodyOptions opts)func FromRawBody(Opts MultipartBodyOptions) MultipartBodystatic#
Constructs the raw `MultipartBody` using specified body, content type and transfer encoding.

When transfer encoding is specified (typically as Base64), it's caller responsibility to convert body to Base64 either by wrapping with Fn.base64 or by converting it by other converters.

fromUserData(userData: UserData, contentType?: string): MultipartBody // chainable@staticmethod def from_user_data(user_data: UserData, content_type: typing.Optional[str] = None) -> MultipartBodypublic static MultipartBody fromUserData(UserData userData, String contentType)public static MultipartBody FromUserData(UserData userData, string? contentType = null)func FromUserData(UserData UserData, ContentType *string) MultipartBodystatic#
Constructs the new `MultipartBody` wrapping existing `UserData`. Modification to `UserData` are reflected in subsequent renders of the part.

For more information about content types see MultipartBodyOptions.contentType.

2 parameters

Parameters

  • userDatauser_datauserDatauserDataUserData — user data to wrap into body part.
  • contentTypecontent_typecontentTypecontentTypeContentType — optional content type, if default one should not be used.
renderBodyPart(): string[]def render_body_part(self, ) -> typing.List[str]public List<String> renderBodyPart()public string[] RenderBodyPart()func RenderBodyPart() *[]*string#
Render body part as the string.

Subclasses should not add leading nor trailing new line characters (\r \n)