AWS Cargo Lambda Runtime.Error SQS Example

161 views Asked by At

I'm fairly new to Rust and AWS Lambda. I am developing our first function that will be triggered by an SQS subscription with batch processing. The SQS will then be triggered from an SNS Topic. We use the CloudFormation template to set up our stacks and use our in-house CI/CD pipeline triggered from a GitHub repo.

We use the cargo lambda package to develop the function. https://github.com/cargo-lambda/cargo-lambda

I'm trying out the example code from the AWS Labs repo. When I test the lambda, I got this error:

{
  "errorType": "Runtime.ExitError",
  "errorMessage": "RequestId: fa19660a-b221-4c0a-a61b-6f0239bdd0a6 Error: Runtime exited with error: signal: illegal instruction"
}

I tested it from the Test tab in the AWS console, with the SQS template test.

Not sure why. I didn't do any modifications to the example code. The error doesn't give me any clue about what's wrong with my setup.

I have increased the memory to 1024 MB, based on some threads in SO [1][2][3]. No luck so far. I can see the binary bootstrap file inside the lambda directory.

enter image description here

Anyone can help?

1

There are 1 answers

0
Seto On BEST ANSWER

This is due to the compilation error. We use it in our CI/CD pipeline. This is the workflow file that works:

name: Build
# This build image is compatable with AWS Linux 2
runs-on: ubuntu-latest
strategy:
  matrix:
    target:
      - x86_64-unknown-linux-gnu
steps:
  - name: Checkout source Git repo
    uses: actions/checkout@v3

  // More workflow steps

  - name: Run Rust Cargo Build
    uses: actions-rs/cargo@v1
    with:
      use-cross: true
      command: build
      args: --release --all-features --target=${{ matrix.target }}