keyurbhole / htmltopdf

Converting HTML To PDF using AWS Lambda Functions and Layers with Serverless Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Layer binary execute permission error

likeconan opened this issue · comments

Hi,

I followed your steps but when request for the url get this error:

image

This is because of permission of execution I think. Could you help to tell me how to fix?

Thanks a lot

process.env.PATH = ${process.env.PATH}:/opt
process.env.FONTCONFIG_PATH = '/opt'
process.env.LD_LIBRARY_PATH = '/opt'

Did you try adding this lines to top of the function

Thanks for your responding. I tried and worked now. This can be closed~

Hi,

Thanks for this function and manual. I couldn't have figured this out on my own. However, I still cannot get it to work. The lines mentioned above are in my code, but still I get this message when invoking the API:

{
    "errno": "EPIPE",
    "code": "EPIPE",
    "syscall": "write"
}

When running in local mode I get:

{
    "message": "Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1",
    "errno": "ENETUNREACH",
    "code": "CredentialsError",
    "syscall": "connect",
    "address": "169.254.169.254",
    "port": 80,
    "time": "2020-11-19T11:02:12.677Z",
    "originalError": {
        "message": "Could not load credentials from any providers",
        "errno": "ENETUNREACH",
        "code": "CredentialsError",
        "syscall": "connect",
        "address": "169.254.169.254",
        "port": 80,
        "time": "2020-11-19T11:02:12.677Z",
        "originalError": {
            "message": "EC2 Metadata roleName request returned error",
            "errno": "ENETUNREACH",
            "code": "ENETUNREACH",
            "syscall": "connect",
            "address": "169.254.169.254",
            "port": 80,
            "time": "2020-11-19T11:02:12.677Z",
            "originalError": {
                "errno": "ENETUNREACH",
                "code": "ENETUNREACH",
                "syscall": "connect",
                "address": "169.254.169.254",
                "port": 80,
                "message": "connect ENETUNREACH 169.254.169.254:80"
            }
        }
    }
}

Do you have any pointers where to look?

Thanks

Hi @joeplaa

You need to use unix system and try with command like chmod -R 777 ./your_directoy and then zip to upload.

Hi @likeconan,

Thanks for the quick reply. Having two local AWS profile (joeplaa and jodibooks) was the issue locally. After adding the correct aws profile in the provider sections of both serverless.yml it worked in development.

provider:
  name: aws
  profile: jodibooks
  ...

Invoking the actual Lambda on AWS through the API Gateway was even stupider. I selected the wrong S3 policy; in effect I added putObject credentials for the wrong bucket, ouch.