class MultipartBody
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EC2.MultipartBody |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#MultipartBody |
Java | software.amazon.awscdk.services.ec2.MultipartBody |
Python | aws_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
Name | Type | Description |
---|---|---|
static CLOUD_BOOTHOOK | string | Content type for boot hooks. |
static SHELL_SCRIPT | string | Content 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
Name | Description |
---|---|
render | Render body part as the string. |
static from | Constructs the raw MultipartBody using specified body, content type and transfer encoding. |
static from | Constructs the new MultipartBody wrapping existing UserData . Modification to UserData are reflected in subsequent renders of the part. |
BodyPart()
renderpublic renderBodyPart(): string[]
Returns
string[]
Render body part as the string.
Subclasses should not add leading nor trailing new line characters (\r \n)
RawBody(opts)
static frompublic static fromRawBody(opts: MultipartBodyOptions): MultipartBody
Parameters
- opts
Multipart
Body Options
Returns
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.
UserData(userData, contentType?)
static frompublic static fromUserData(userData: UserData, contentType?: string): MultipartBody
Parameters
- userData
User
— user data to wrap into body part.Data - contentType
string
— optional content type, if default one should not be used.
Returns
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
.