Getting Event Bridge Atlas working in a lambda function: Error: EROFS: read-only file system

Viewed 32

eventbridge-atlas project: https://github.com/boyney123/eventbridge-atlas their website: https://eventbridge-atlas.netlify.app/

So I'm trying to have eventbridge-atlas generate the async-api docs and then upload them to an s3 bucket from a lambda function. Currently I have everything working locally, and I'm storing the files in the /tmp directory (which should be the same tmp directory in the lambda function) and then added a few function in the event-bridge-atlas code to then upload those files to the /tmp directory.

At some point in the lambda function we are executing:

npx @asyncapi/generator /tmp/events.yml @asyncapi/html-template -o /tmp --force-write

which should just be writing the docs into the tmp folder of the lambda function (this is how it is working locally). When this command is run I'm getting the following error though:

2022-06-28T17:46:49.457Z    90c863cb-b7de-4906-a71c-6aad84fd8bd4    INFO    e Error: Command failed: npx @asyncapi/generator /tmp/events.yml @asyncapi/html-template -o /tmp --force-write
Error: EROFS: read-only file system, mkdir '/home/sbx_user1051'
command not found: generator

    at ChildProcess.exithandler (child_process.js:383:12)
    at ChildProcess.emit (events.js:400:28)
    at ChildProcess.emit (domain.js:475:12)
    at maybeClose (internal/child_process.js:1088:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'npx @asyncapi/generator /tmp/events.yml @asyncapi/html-template -o /tmp --force-write',
  stdout: '',
  stderr: "Error: EROFS: read-only file system, mkdir '/home/sbx_user1051'\n" +
    'command not found: generator\n'
}

It seems as though this function isn't just trying to write to tmp, but also attempting to make a directory in /home/sbx_user1051.

Has anyone found a work around or successfully deployed eventbridge-atlas in a lambda function to auto generate docs?


I have altered the eventbride atlas code to actually use the node module instead of executing a bash command, am an running into the same issue, now i get a bit more traceback info

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "Error: EROFS: read-only file system, mkdir '/home/sbx_user1051'",
    "reason": {
        "errorType": "Error",
        "errorMessage": "EROFS: read-only file system, mkdir '/home/sbx_user1051'",
        "code": "EROFS",
        "errno": -30,
        "syscall": "mkdir",
        "path": "/home/sbx_user1051",
        "stack": [
            "Error: EROFS: read-only file system, mkdir '/home/sbx_user1051'"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: Error: EROFS: read-only file system, mkdir '/home/sbx_user1051'",
        "    at process.<anonymous> (/var/runtime/index.js:35:15)",
        "    at process.emit (events.js:400:28)",
        "    at process.emit (domain.js:475:12)",
        "    at process.emit (/var/task/node_modules/@asyncapi/generator/node_modules/source-map-support/source-map-support.js:516:21)",
        "    at processPromiseRejections (internal/process/promises.js:245:33)",
        "    at processTicksAndRejections (internal/process/task_queues.js:96:32)"
    ]
}

1 Answers

Alright, so at this current iteration you are unable to use asyncapi generator in a lambda function and this is because it will try to create dirs in places other than /tmp which is not allowed. If you want to set up eventbridge-atlas to work you will need to use a docker image on an ec2 like instance, as you will need the extra file structure control.

I hope this helps someone who is stuck trying to throw it in a lambda function!

Related