aws-cdk-lib.aws_ec2.MultipartBody

class MultipartBody

LanguageType name
.NETAmazon.CDK.AWS.EC2.MultipartBody
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#MultipartBody
Javasoftware.amazon.awscdk.services.ec2.MultipartBody
Pythonaws_cdk.aws_ec2.MultipartBody
TypeScript (source)aws-cdk-lib » aws_ec2 » MultipartBody

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

Example

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

new MultipartBody()

Properties

NameTypeDescription
static CLOUD_BOOTHOOKstringContent type for boot hooks.
static SHELL_SCRIPTstringContent type for shell scripts.

static CLOUD_BOOTHOOK

Type: string

Content type for boot hooks.


static SHELL_SCRIPT

Type: string

Content type for shell scripts.

Methods

NameDescription
renderBodyPart()Render body part as the string.
static fromRawBody(opts)Constructs the raw MultipartBody using specified body, content type and transfer encoding.
static fromUserData(userData, contentType?)Constructs the new MultipartBody wrapping existing UserData. Modification to UserData are reflected in subsequent renders of the part.

renderBodyPart()

public renderBodyPart(): string[]

Returns

  • string[]

Render body part as the string.

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


static fromRawBody(opts)

public static fromRawBody(opts: MultipartBodyOptions): MultipartBody

Parameters

  • opts MultipartBodyOptions

Returns

  • MultipartBody

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.


static fromUserData(userData, contentType?)

public static fromUserData(userData: UserData, contentType?: string): MultipartBody

Parameters

  • userData UserData — user data to wrap into body part.
  • contentType string — optional content type, if default one should not be used.

Returns

  • MultipartBody

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.