Skip to content
v2.273.0

InitCommandOptions Struct ​

Options for InitCommand.

Example ​

ts
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 ​

cwdstringcwdstrcwdStringCwdstringCwd*string= Use default working directory#
The working directory.
env{ [key: string]: string }envtyping.Mapping[str, str]envMap<String, String>EnvIDictionary<string, string>Env*map[string]*string= Use current environment#
Sets environment variables for the command.

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

ignoreErrorsbooleanignore_errorsboolignoreErrorsBooleanIgnoreErrorsboolIgnoreErrors*bool= false#
Continue running if this command fails.
keystringkeystrkeyStringKeystringKey*string= Automatically generated based on…#
Identifier key for this command.

Commands are executed in lexicographical order of their key names.

default

Default: Automatically generated based on index

serviceRestartHandlesInitServiceRestartHandle[]service_restart_handlestyping.List[InitServiceRestartHandle]serviceRestartHandlesList<InitServiceRestartHandle>ServiceRestartHandlesInitServiceRestartHandle[]ServiceRestartHandles*[]InitServiceRestartHandle= Do not restart any service#
Restart the given service(s) after this command has run.
testCmdstringtest_cmdstrtestCmdStringTestCmdstringTestCmd*string= 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.

waitAfterCompletionInitCommandWaitDurationwait_after_completionInitCommandWaitDurationwaitAfterCompletionInitCommandWaitDurationWaitAfterCompletionInitCommandWaitDurationWaitAfterCompletionInitCommandWaitDuration= 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.