aws-cdk-lib.aws_ec2.InitCommandOptions

interface InitCommandOptions

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

Options for InitCommand.

Example

const handle = new ec2.InitServiceRestartHandle();
ec2.CloudFormationInit.fromElements(
  ec2.InitCommand.shellCommand('/usr/bin/custom-nginx-install.sh', { serviceRestartHandles: [handle] }),
  ec2.InitService.enable('nginx', { serviceRestartHandle: handle }),
);

Properties

NameTypeDescription
cwd?stringThe working directory.
env?{ [string]: string }Sets environment variables for the command.
ignoreErrors?booleanContinue running if this command fails.
key?stringIdentifier key for this command.
serviceRestartHandles?InitServiceRestartHandle[]Restart the given service(s) after this command has run.
testCmd?stringCommand to determine whether this command should be run.
waitAfterCompletion?InitCommandWaitDurationThe duration to wait after a command has finished in case the command causes a reboot.

cwd?

Type: string (optional, default: Use default working directory)

The working directory.


env?

Type: { [string]: string } (optional, default: Use current environment)

Sets environment variables for the command.

This property overwrites, rather than appends, the existing environment.


ignoreErrors?

Type: boolean (optional, default: false)

Continue running if this command fails.


key?

Type: string (optional, default: Automatically generated based on index)

Identifier key for this command.

Commands are executed in lexicographical order of their key names.


serviceRestartHandles?

Type: InitServiceRestartHandle[] (optional, default: Do not restart any service)

Restart the given service(s) after this command has run.


testCmd?

Type: string (optional, default: Always run the command)

Command to determine whether this command should be run.

If the test passes (exits with error code of 0), the command is run.


waitAfterCompletion?

Type: InitCommandWaitDuration (optional, default: 60 seconds)

The duration to wait after a command has finished in case the command causes a reboot.

Set this value to InitCommandWaitDuration.none() if you do not want to wait for every command; InitCommandWaitDuration.forever() directs cfn-init to exit and resume only after the reboot is complete.

For Windows systems only.