class InitCommand
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.InitCommand |
![]() | software.amazon.awscdk.services.ec2.InitCommand |
![]() | aws_cdk.aws_ec2.InitCommand |
![]() | @aws-cdk/aws-ec2 » InitCommand |
Extends
Init
Command to execute on the instance.
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
Name | Type | Description |
---|---|---|
element | string | Returns the init element type for this element. |
elementType
Type:
string
Returns the init element type for this element.
Methods
Name | Description |
---|---|
static argv | Run a command from an argv array. |
static shell | Run a shell command. |
static argvCommand(argv, options?)
public static argvCommand(argv: string[], options?: InitCommandOptions): InitCommand
Parameters
- argv
string[]
- options
Init
Command Options
Returns
Run a command from an argv array.
You do not need to escape space characters or enclose command parameters in quotes.
static shellCommand(shellCommand, options?)
public static shellCommand(shellCommand: string, options?: InitCommandOptions): InitCommand
Parameters
- shellCommand
string
- options
Init
Command Options
Returns
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.