class UserData
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EC2.UserData |
Java | software.amazon.awscdk.services.ec2.UserData |
Python | aws_cdk.aws_ec2.UserData |
TypeScript (source) | @aws-cdk/aws-ec2 » UserData |
Implemented by
Multipart
Instance User Data.
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 UserData()
Methods
Name | Description |
---|---|
add | Add one or more commands to the user data. |
add | Adds commands to execute a file. |
add | Add one or more commands to the user data that will run when the script exits. |
add | Adds commands to download a file from S3. |
add | Adds a command which will send a cfn-signal when the user data script ends. |
render() | Render the UserData for use in a construct. |
static custom(content) | Create a userdata object with custom content. |
static for | Create a userdata object for Linux hosts. |
static for | |
static for | Create a userdata object for Windows hosts. |
Commands(...commands)
addpublic addCommands(...commands: string[]): void
Parameters
- commands
string
Add one or more commands to the user data.
ExecuteFileCommand(params)
addpublic addExecuteFileCommand(params: ExecuteFileOptions): void
Parameters
- params
Execute
File Options
Adds commands to execute a file.
OnExitCommands(...commands)
addpublic addOnExitCommands(...commands: string[]): void
Parameters
- commands
string
Add one or more commands to the user data that will run when the script exits.
S3DownloadCommand(params)
addpublic addS3DownloadCommand(params: S3DownloadOptions): string
Parameters
- params
S3
Download Options
Returns
string
Adds commands to download a file from S3.
SignalOnExitCommand(resource)
addpublic addSignalOnExitCommand(resource: Resource): void
Parameters
- resource
Resource
Adds a command which will send a cfn-signal when the user data script ends.
render()
public render(): string
Returns
string
Render the UserData for use in a construct.
static custom(content)
public static custom(content: string): UserData
Parameters
- content
string
Returns
Create a userdata object with custom content.
Linux(options?)
static forpublic static forLinux(options?: LinuxUserDataOptions): UserData
Parameters
- options
Linux
User Data Options
Returns
Create a userdata object for Linux hosts.
OperatingSystem(os)
static forpublic static forOperatingSystem(os: OperatingSystemType): UserData
Parameters
Returns
Windows()
static forpublic static forWindows(): UserData
Returns
Create a userdata object for Windows hosts.