InitCommand Class
Command to execute on the instance.
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
Returns the init element type for this element.
Methods
argvCommand(argv: string[], options?: InitCommandOptions): InitCommand // chainable@staticmethod def argv_command(argv: typing.List[str], options: typing.Optional[InitCommandOptions] = None) -> InitCommandpublic static InitCommand argvCommand(List<String> argv, InitCommandOptions options)public static InitCommand ArgvCommand(string[] argv, InitCommandOptions? options = null)func ArgvCommand(Argv *[]*string, Options InitCommandOptions) InitCommandstatic#Run a command from an argv array.
You do not need to escape space characters or enclose command parameters in quotes.
shellCommand(shellCommand: string, options?: InitCommandOptions): InitCommand // chainable@staticmethod def shell_command(shell_command: str, options: typing.Optional[InitCommandOptions] = None) -> InitCommandpublic static InitCommand shellCommand(String shellCommand, InitCommandOptions options)public static InitCommand ShellCommand(string shellCommand, InitCommandOptions? options = null)func ShellCommand(ShellCommand *string, Options InitCommandOptions) InitCommandstatic#Run a shell command.
Remember that some characters like &, |, ;, > etc. have special meaning in a shell and need to be preceded by a \ if you want to treat them as part of a filename.