UserData

class aws_cdk.aws_ec2.UserData

Bases: object

Instance User Data.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Return type

None

Methods

add_commands(*commands)

Add one or more commands to the user data.

Parameters

commands (str) –

Return type

None

add_execute_file_command(*, file_path, arguments=None)

Adds commands to execute a file.

Parameters
  • file_path (str) – The path to the file.

  • arguments (Optional[str]) – The arguments to be passed to the file. Default: No arguments are passed to the file.

Return type

None

add_on_exit_commands(*commands)

Add one or more commands to the user data that will run when the script exits.

Parameters

commands (str) –

Return type

None

add_s3_download_command(*, bucket, bucket_key, local_file=None)

Adds commands to download a file from S3.

Parameters
  • bucket (IBucket) – Name of the S3 bucket to download from.

  • bucket_key (str) – The key of the file to download.

  • local_file (Optional[str]) – The name of the local file. Default: Linux - /tmp/bucketKey Windows - %TEMP%/bucketKey

return :rtype: str :return: : The local path that the file will be downloaded to

add_signal_on_exit_command(resource)

Adds a command which will send a cfn-signal when the user data script ends.

Parameters

resource (Resource) –

Return type

None

render()

Render the UserData for use in a construct.

Return type

str

Static Methods

classmethod custom(content)

Create a userdata object with custom content.

Parameters

content (str) –

Return type

UserData

classmethod for_linux(*, shebang=None)

Create a userdata object for Linux hosts.

Parameters

shebang (Optional[str]) – Shebang for the UserData script. Default: “#!/bin/bash”

Return type

UserData

classmethod for_operating_system(os)
Parameters

os (OperatingSystemType) –

Return type

UserData

classmethod for_windows()

Create a userdata object for Windows hosts.

Return type

UserData