Skip to content

An AWS Lambda function that executes a shell command and returns the output. Additional executable binaries can be deployed with and used by the function.

Notifications You must be signed in to change notification settings

ken107/aws-lambda-shell-execute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-lambda-shell-execute

An AWS Lambda function that executes a shell command and returns the output. Additional executable binaries can be deployed with and used by the function.

1. Prepare

Create a 'bin' subdirectory in the project directory and add any executable binaries your function needs. These binaries must be compatible with the AWS Lambda execution environment, which is Amazon Linux. Make sure they have the execute permission set.

2. Build

Open a shell in the project directory and run npm run dist. If you're on Windows, make sure you use a Linux shell so that file permissions are properly copied into the package. Then deploy the dist/package.zip file to your AWS Lambda function.

3. Invoke

You can quickly test your function from the Lambda console with this simple test event:

{
  "command": "ls",
  "args": ["-l"]
}

Request

The request event can have the following properties:

  1. command: the shell command to execute
  2. args: array of arguments
  3. stdin: a string that is passed as stdin
  4. stdinEncoding: encoding of stdin (default 'utf8', use 'base64' for binary)
  5. stdoutEncoding: encoding to use to encode stdout into a string

Response

The response can have the following properties:

  1. exitCode: either the exit code or the signal that ended the command
  2. stdout: the command's stdout as a string
  3. stderr: the command's stderr as a string

About

An AWS Lambda function that executes a shell command and returns the output. Additional executable binaries can be deployed with and used by the function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published