How to use pdfkit in AWS Lambda? - amazon-web-services

I'm using AWS Lambda to generate pdf file using a ninja2 template. I am trying to use pdfkit to convert my HTML into pdf. I realize pdfkit has an internal dependency - wkhtmltopdf which needs to be used as a binary or installed via a package manager. I am not sure how to make this work on AWS Lambda?
With my current template and python code using pdfkit, I am getting the following error -
{
"errorMessage": "No wkhtmltopdf executable found: \"b''\"\nIf this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf",
"errorType": "OSError",
.....
.....
}
Any ideas on how can I make pdfkit work on lambda?
Any suggestions for wkhtmltopdf replacements?
Thanks

I've made a simple demo on using PDFKit using Serverless framework using layer. Checkout https://medium.com/#crespo.wang/create-pdf-using-pdfkit-on-serverless-aws-lambda-with-layer-721ca86724b2

AWS Lambda has concept of Layers which allows you to upload your custom dependencies as a zip and then it will be available as it is installed on the box. For more information see here :
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
In your case you could upload the binaries for wkhtmltopdf as layer and while creating lambda function, you could provide the layer to use.

There are multiple projects on GitHub used to run wkhtmltopdf on Lambda for example:
https://github.com/lubos/aws-lambda-wkhtmltopdf
https://github.com/dimiro1/lambda-wkhtmltopdf
https://github.com/jpaolin/aws-lambda-s3-wkhtmltopdf

Download the wkhtmltopdf binaries required for aws lambda from :https://wkhtmltopdf.org/downloads.html.
Add the zip file as layer to lambda and set the pdf kit config pointing to executable path in the zip file.(/opt/bin/wkhtmltopdf)

Related

Deploy only lambdas without changing api gateway

everytime I deploy with AWS-SAM my Settings in API-Gateway get reset.
I have an Open Api 3.0 Spec.yml I imported into API-Gateway and it loaded just fine. After deploying using SAM it only shows the hello world function (only one i currently have).
What I want is that the settings imported via the Open API spec stay and i develop the lambdas locally and push them via SAM. I then want to connect the function manually via AWS-Cloud-Console to the specific lambda, not using the SAM's yaml format. How can i deploy only the function, without destroing the API-Gateway Config everytime?
FYI:
I dont want to use the browser IDE to deploy / test my function.
I am using Node.js / Typescript
I've read the useless Documentation # AWS
https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/scheduled-events-invoking-lambda-deploy-function.html
https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/lambda-create-table-deploy-function.html
I know this question is similar, but doesnt solve the problem:
how to develop a lambda on SAM but deploy without api gateway
I tried uploading via ZIP File, but upon testing the function it always fails at finding the Entrypoint, even after ajusting the Entrypoint in the Cloud Console
Thank you in advance!

Is it possible to download an artifact from Artifactory through Django?

I have a question regarding the possibility of downloading an artifact from Artifactory through Django.
Is it possible to use a get request using requests like :
import requests
r = requests.get(http://localhost:8081/artifactory/libs-release-local/ch/qos/logback/logback-classic/0.9.9/logback-classic-0.9.9.jar?skipUpdateStats=true)
or is there another way to download the artifact in python?
If curl works to download the artifact with the URL then the requests library does have sufficient functions that support the curl request. I would recommend referring to this StackOverflow for more info.

I want to add “aws-iot-device-sdk” to my project

I want to add “aws-iot-device-sdk” to my project, but I couldn’t find such a plugin for vue js. Have you used it before.
https://github.com/aws/aws-iot-device-sdk-js
You can install aws iot sdk for javascript.

How to create a Module for AWS SDK

I am trying to develop a custom module for AWS-IOT, Here i got module to access AWS services but the existing module is not supported for AWS-IOT which is the new service launched by Amazon.
I have downloaded the AWS-SDK but here i am unable to find .m files.
Please let me know if you need more info.
Thanks, Rakesh Kalwa.
If AWS marketplace modules is not working then you maybe try another open source module ti.aws. please check that.
And if still not working then you can also create your new module based on AWS SDK. for modules development help Please visit Extending Titanium Mobile.

How do I download the artifacts from a jenkins build through python

How do I download the artifacts from a Jenkins build to my local machine using Python?
I will assume that you want to download via http.
You might want to use GNU wget for example, but if you really want to use Python - check out How do I download a file over HTTP using Python?. Urllib2 provides an easy way to handle http requests.
This is providing that you will not need to perform any additional actions to get to the file (authentication etc.).