Class InitCommand
Command to execute on the instance.
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class InitCommand : InitElement
Syntax (vb)
Public Class InitCommand Inherits InitElement
Remarks
ExampleMetadata: infused
Examples
var handle = new InitServiceRestartHandle();
CloudFormationInit.FromElements(InitCommand.ShellCommand("/usr/bin/custom-nginx-install.sh", new InitCommandOptions { ServiceRestartHandles = new [] { handle } }), InitService.Enable("nginx", new InitServiceOptions { ServiceRestartHandle = handle }));
Synopsis
Properties
| ElementType | Returns the init element type for this element. |
Methods
| ArgvCommand(string[], IInitCommandOptions?) | Run a command from an argv array. |
| ShellCommand(string, IInitCommandOptions?) | Run a shell command. |
Properties
ElementType
Returns the init element type for this element.
public override string ElementType { get; }
Property Value
Overrides
Remarks
ExampleMetadata: infused
Methods
ArgvCommand(string[], IInitCommandOptions?)
Run a command from an argv array.
public static InitCommand ArgvCommand(string[] argv, IInitCommandOptions? options = null)
Parameters
- argv string[]
- options IInitCommandOptions
Returns
Remarks
You do not need to escape space characters or enclose command parameters in quotes.
ShellCommand(string, IInitCommandOptions?)
Run a shell command.
public static InitCommand ShellCommand(string shellCommand, IInitCommandOptions? options = null)
Parameters
- shellCommand string
- options IInitCommandOptions
Returns
Remarks
Remember that some characters like &, |, ;, > etc. have special meaning in a shell and
need to be preceded by a </code> if you want to treat them as part of a filename.