class aws_cdk.aws_ec2.MultipartBody

Bases: object

The base class for all classes which can be used as {@link MultipartUserData}.


abstract render_body_part()

Render body part as the string.

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

Return type



CLOUD_BOOTHOOK = 'text/cloud-boothook; charset="utf-8"'
SHELL_SCRIPT = 'text/x-shellscript; charset="utf-8"'

Static Methods

classmethod from_raw_body(*, content_type, body=None, transfer_encoding=None)

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.

  • content_type (str) – Content-Type header of this part. Some examples of content types: - text/x-shellscript; charset="utf-8" (shell script) - text/cloud-boothook; charset="utf-8" (shell script executed during boot phase) For Linux shell scripts use text/x-shellscript.

  • body (Optional[str]) – The body of message. Default: undefined - body will not be added to part

  • transfer_encoding (Optional[str]) – Content-Transfer-Encoding header specifying part encoding. Default: undefined - body is not encoded

Return type


classmethod from_user_data(user_data, content_type=None)

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 {@link MultipartBodyOptions.contentType}.

  • user_data (UserData) – user data to wrap into body part.

  • content_type (Optional[str]) – optional content type, if default one should not be used.

Return type