My lambda function is a NodeJS application that runs in public.ecr.aws/lambda/nodejs:18.
Here’s the gist of the app:
import { createGunzip } from 'node:zlib';
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
const execAsync = promisify(exec);
export default async function handler() {
const readStream = fs.createReadStream('test.tar.gz');
const writeStream = fs.createWriteStream('test.tar');
const gunzip = createGunzip();
// Decompress .gzip file to a .tar file
await stream.pipeline(readStream, gunzip, writeStream);
// Now extract the .tar file contents
await execAsync(`tar -xf 'test.tar' -C 'test'`);
}
When the application runs, it throws this error:
Error: Command failed: tar -xf /test.tar -C test
/bin/sh: tar: command not found
What are my alternatives? I couldn’t find a tar
alternative in the Lambda’s image. Using an NPM dependency, like node-tar wouldn’t be ideal.