I wish to create issues in JIRA from an AWS Lambda function. I am getting stuck on the first couple of steps for OAuth where I need to use JIRA's AppLinks to pair with an application. Do I need to build a custom client? If so, how? If not, what do I need to do?
Any help is appreciated, thanks!
I found this question via Google looking for an answer to the same problem. I'm adding an answer in case someone else stumbles upon this question looking for an answer.
The jira python package does not include cryptography which you'll need to add as a pip requirement.
pycrypto - This is required for the RSA-SHA1 used by OAuth. Please note that it’s not installed automatically, since it’s a fairly cumbersome process in Windows. On Linux and OS X, a pip install pycrypto should do it.
https://jira.readthedocs.io/en/master/installation.html#dependencies
Depending on your platform it may not be as simple as adding the above and deploying due to native code requirements
cryptography contains native code and that code is compiled for the architecture (and OS) of the current machine. The AWS lambda documentation currently appears to claim that zipping up your local directory will work, but that's patently untrue.
https://github.com/pyca/cryptography/issues/3051#issuecomment-234093766
To resolve you can compile your function's requirements on an EC2 AMI or docker container.
If you are using serverless you can use the serverless-python-requirements plugin which is what I used to resolved these issue for me.
In your serverless.yml file you can specify compiling packages via docker.
custom:
pythonRequirements:
dockerizePip: true
found via https://www.npmjs.com/package/serverless-python-requirements#cross-compiling
Related
I am getting the below error in the Azure Function for Python
Please see the below screenshot
Whenever I am trying to open the azure function python on the portal then I got the above error.
Let me know if anyone has any idea regarding this error.
This error can be very difficult to debug, because it seems to be caused by multiple root causes. In my case, I suspect the root cause to be a failure in pip package installation. But this is difficult to verify, because I was not able to drill in to the pip logs. The deployment log does not contain information about pip installation, and some of the logs were unavailable because the host runtime was down.
I followed these best practices to finally make the Python function deployment succeed:
Use remote build (app setting: SCM_DO_BUILD_DURING_DEPLOYMENT: 1)
Make sure that the AzureWebJobsStorage application setting is configured to point to the correct Function Storage
Do not include local .venv/ directory in deployment (add it to .funcignore)
Make sure the dependencies can be installed on the local Virtual Environment without conflicts
Test that the function runs locally without errors
In requirements.txt, I had the following lines. Note that there is no need to specify azure-functions version, since it is determined by the platform. It is only for local linting etc.
pip==21.2.*
azure-functions
As a side note, it is not necessary to specify "Build from package" (app setting: WEBSITE_RUN_FROM_PACKAGE: 1); this seems to be enabled by default.
My deployment configuration:
OS: Ubuntu 21.04
Functions Python version: 3.9
Functions Runtime Extension version: 4
Deployed with VS Code Azure extension
My Python App Engine Flex application needs to connect to an external Oracle database. Currently I'm using the cx_Oracle Python package which requires me to install the Oracle Instant Client.
I have successfully run this locally (on macOS) by following the Instant Client installation steps. The steps required me to do the following:
Make a directory called /opt/oracle
Create a symlink from /opt/oracle/instantclient_12_2/libclntsh.dylib.12.1 to ~/lib/
However, I am confused about how to do the same thing in App Engine Flex (instructions). Specifically, here's what I'm confused about:
The instructions say I should run sudo yum install libaio to install the libaio package. How do I do this on GAE Flex? Or is this package already available?
I think I can add the Instant Client files to GAE (a whopping ~100MB!), then set the LD_LIBRARY_PATH environment variable in app.yaml to export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH. Will this work?
Is this even feasible without using custom Docker containers on App Engine Flex?
Overall I'm not sure if I'm on the right track. Would love to hear from someone who has managed this before :)
If any of your dependencies is not available in the base GAE flex images provided by Google and cannot be installed via pip (because it's not a python package or it's not available in PyPI or whatever other reason) then you can't use the requirements.txt file to get it installed in your GAE flex app.
The proper way to satisfy such dependencies would be to build your own custom runtime. From About Custom Runtimes:
Custom runtimes allow you to define new runtime environments, which
might include additional components like language interpreters or
application servers.
Yes, that means providing a custom Docker file. In your particular case you'd be installing the Instant Client and libaio inside this Dockerfile. See also Building Custom Runtimes.
Answering your first question, I think that the instructions in the oracle website just show that you have to install said library for your application to work.
In the case of App engine flex, they way to ensure that the libraries are present in the deployment is with the requirements.txt textfile. There is a documentation page which does explain how to do so.
On the other hand, I will assume that "Instant Client Files" are not libraries, but necessary data for your App to run. You should use Google Cloud Storage to serve them, or any other alternative of Storage within Google Cloud.
I believe that, if this is all what you need for your App to work, pushing your own custom container should not be necessary.
I'm new to AWS Lambda and pretty new to Python.
I wanted to write a python lambda that uses the AWS API.
boto is the most popular python module to do this so I wanted to include it.
Looking at examples online I put import boto3 at the top of my Lambda and it just worked- I was able to use boto in my Lambda.
How does AWS know about boto? It's a community module. Are there a list of supported modules for Lambdas? Does AWS cache its own copy of community modules?
AWS Lambda's Python environment comes pre-installed with boto3. Any other libraries you want need to be part of the zip you upload. You can install them locally with pip install whatever -t mysrcfolder.
The documentation seems to suggest boto3 is provided by default on AWS Lambda:
AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package. However, if you want to use a version of Boto3 other than the one included by default, you can include it in your deployment package.
As far as I know, you will need to manually install any other dependencies in your deployment package, as shown in the linked documentation, using:
pip install foobar -t <project path>
AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package.
This link will give you a little more in-depth info on Lambda environment
https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/
And this too
https://alestic.com/2014/12/aws-lambda-persistence/
I am super new to python and AWS as well. I want to install and uninstall web browsers like Chrome/ Firefox/ IE etc as per the requirement on EC2 instances using Python. I am yet not sure whether "BOTO" can be useful here and I am using Python 2.7.9. Any suggestions / guidelines / overview / tutorial are appreciated.
Thanks a lot :)
Boto allows you to make API calls to AWS services like EC2 and S3. It's not relevant to installing web browsers on EC2 instances.
You mentioned IE so I'm assuming that your EC2 instances are Windows, not Linux. Python is not likely to be the best way to install and uninstall Windows applications. You might want to host the installation binaries somewhere and then use a CMD script to do silent installs/uninstalls (Firefox example here) or even look at a Windows package manager like chocolatey.
Can somebody explain me how to use the setuptools inside python in google app engine to implement WSGIProxy for a webapp.
How do i utilize it, if i dont have access to the filesystem? Specifically,easy steps on how install package from python egg on GAE.
This should be relatively easy for someone who has used setuptools or installed 3rd party packages on GAE python.
I just answered almost the same question, but about a different library. The concept behind installing thirdparty libraries is exactly the same though, you need to either put a copy of the actual code in your app folder, or use a softlink to in.
GAE - Including external python modules without adding them to the repository?