class UserData
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.UserData |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#UserData |
![]() | software.amazon.awscdk.services.ec2.UserData |
![]() | aws_cdk.aws_ec2.UserData |
![]() | aws-cdk-lib » aws_ec2 » UserData |
Implemented by
Multipart
Instance User Data.
Example
declare const cluster: eks.Cluster;
const userData = ec2.UserData.forLinux();
userData.addCommands(
'set -o xtrace',
`/etc/eks/bootstrap.sh ${cluster.clusterName}`,
);
const lt = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
launchTemplateData: {
imageId: 'some-ami-id', // custom AMI
instanceType: 't3.small',
userData: Fn.base64(userData.render()),
},
});
cluster.addNodegroupCapacity('extra-ng', {
launchTemplateSpec: {
id: lt.ref,
version: lt.attrLatestVersionNumber,
},
});
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. |
addCommands(...commands)
public addCommands(...commands: string[]): void
Parameters
- commands
string
Add one or more commands to the user data.
addExecuteFileCommand(params)
public addExecuteFileCommand(params: ExecuteFileOptions): void
Parameters
- params
Execute
File Options
Adds commands to execute a file.
addOnExitCommands(...commands)
public addOnExitCommands(...commands: string[]): void
Parameters
- commands
string
Add one or more commands to the user data that will run when the script exits.
addS3DownloadCommand(params)
public addS3DownloadCommand(params: S3DownloadOptions): string
Parameters
- params
S3
Download Options
Returns
string
Adds commands to download a file from S3.
addSignalOnExitCommand(resource)
public 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.
static forLinux(options?)
public static forLinux(options?: LinuxUserDataOptions): UserData
Parameters
- options
Linux
User Data Options
Returns
Create a userdata object for Linux hosts.
static forOperatingSystem(os)
public static forOperatingSystem(os: OperatingSystemType): UserData
Parameters
Returns
static forWindows(options?)
public static forWindows(options?: WindowsUserDataOptions): UserData
Parameters
- options
Windows
User Data Options
Returns
Create a userdata object for Windows hosts.