Can I install tools using yum inside AWS Lambda? - amazon-web-services

do you know if there exists a way to use yum from inside a Lambda function. For example, I need to install mdbtools, but if in my lambda I write (in Python)
subprocess.run(['yum', 'install', 'mdbtools'])
then it says
[ERROR] FileNotFoundError: [Errno 2] No such file or directory: 'yum'
I also tried with
os.system('yum install mdbtools')
but it says
sh: yum: command not found
Finally, I read from here to enable also the EPEL repository, so I tried with
os.system('sudo amazon-linux-extras install epel -y; sudo yum-config-manager --enable epel; yum install mdbtools')
os.system('sudo amazon-linux-extras install epel -y; sudo yum-config-manager --enable epel; yum install mdbtools')
os.system('sudo amazon-linux-extras install epel -y; sudo yum-config-manager --enable epel; yum install mdbtools')
but again I get
sh: sudo: command not found
sh: sudo: command not found
sh: yum: command not found
Can you help? Thanks in advance.

If yum existed in the Lambda environment, it should be in /bin/yum. I've looked there, and don't see it, so I'm going to assume that you won't be able to run it.
If you need a library that can't be packaged in a deployment bundle, you'll need to use a Lambda Container Image. Start with one of the pre-built base images, and run yum in your Dockerfile.
However, I see that you've tagged this question with ms-access. If you're trying to install a Microsoft product in a the Linix-based Lambda environment, you'll need to do a lot more than just run yum.

This is not how it is intended to work with dependencies in Lambdas.
It can be achieved in another way though.
You should include all the libs and dependencies in your .zip file which you upload. More information on that here.

Related

I can't install PHP on AWS EC2

I'm pretty new in AWS, I've tried to install PHP on my virtual machine, but it doesn't works, I get the error:
[root#ip-xxx-xxx-xxx-xxx user]# yum install apache2 libapache2-mod-php5 php5 mysql-
server php5-mysql
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
No package apache2 available.
No package libapache2-mod-php5 available.
No package php5 available.
No package mysql-server available.
No package php5-mysql available.
Error: Nothing to do
I don't know the reason of this, I already tried the comamnd yum update, but it doesn't help, please help me
PHP5 is quite old and is probably not available anymore in the YUM package manager.
Also I think the tutorial you are using is Debian/Ubuntu based.
Apache2 is called httpd24 in yum for instance.
That would look something like this:
sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
Or if you are using the Amazon Linux 2 image, then use this command:
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
To find out which specific image you are running:
cat /etc/system-release
Please check out the AWS documentation for an up-to-date tutorial on howto deploy your own LAMP-server:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html

How to fix this gRPC installation problem?

Im following these steps to install gRPC on my freshly launched AWS EC2 Instance:
https://jitpaul.blog/2018/04/18/grpc-on-aws/
When I try to execute this line:
sudo yum install libgflags-dev libgtest-dev
I get this error:
I don't want to mess up anything, please help.
Try instead:
sudo yum install gflags-dev
sudo yum install gtest-dev
That should install libgflags-dev and libgtest-dev.

Unable to install pip

I tried installing pip in the following different ways and didn't have any success, any guidance how can I install pip ?
username#machine ~]$ sudo /usr/local/bin/easy_install pip
[sudo] password for username:
Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')
[username#machine ~]$ sudo /usr/local/bin/easy_install-2.7 pip
Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')
[username#machine ~]$ python -m pip
/usr/local/bin/python: No module named pip
[username#machine ~]$ sudo apt-get install python-pip
sudo: apt-get: command not found
[username#machine ~]$ sudo yum install python-pip
Loaded plugins: security
Setting up Install Process
No package python-pip available.
Error: Nothing to do
Machine configuration:
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: OracleServer
Description: Oracle Linux Server release 6.6
Release: 6.6
Codename: n/a
You can try to use the following for python2.7:
sudo apt install python-pip
And if you alternatively want to install on python3:
sudo apt install python3-pip
None of the above worked, I had to do the following for OL7, as per the official docs:
yum install -y oracle-epel-release-el7 oracle-release-el7

need help to install php 7.2 yum packages on aws ec2

I haven't seen any yum packages for php 7.2 on AWS EC2 and the release has been out over a month.
I have tried yum list | grep php7 and only able see php70 and php71 packages.
Has anyone installed php72 on AWS EC2?
Is there another yum repo to connect to?
Does AWS have a delivery scheduled?
Although the #amzn-main repo doesn't have PHP 7.2 yet (as far as I know), you can use remi-php72. According to his release blog you can install the EPEL and Remi repositories via:
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm
rpm -Uvh epel-release-latest-6.noarch.rpm
And then enable remi-php72 using yum-config-manager:
yum install yum-utils
yum-config-manager --enable remi-php72
After that, you can simply search and install php and all the needed extensions like normal:
sudo yum install --disablerepo="*" --enablerepo="remi,remi-php72" php php-fpm php-cli ...
As #Typel says in a comment on the other answer - if you're using Amazon Linux 2 AMI then
sudo amazon-linux-extras install -y php7.2
Beats installing multiple external repos and has most of th basics, including mariadb and vim (everything I need to feel happy!).
See the list: sudo amazon-linux-extras list

ebextensions: yum does not install package

I am trying to make an ebextensions file which will install wkhtmltopdf.
Currently it looks like this:
packages:
yum:
xorg-x11-fonts-75dpi: []
libpng: []
xz: []
urw-fonts: []
libXext: []
openssl-devel: []
libXrender: []
rpm:
wkhtmltopdf: https://s3-eu-west-1.amazonaws.com/myS3Account/wkhtmltox-0.12.2.1_linux-centos5-amd64.rpm
In this case, wkthmltopdf fails to install. I get the following error:
Failed dependencies:
xorg-x11-fonts-75dpi is needed by wkhtmltox-1:0.12.2.1-1.x86_64
If I use SSH to connect to my EC2 instance, I can sucessfully install wkhtml by manually running "yum install xorg-x11-fonts-75dpi", followed by "wget wkthmltopdf-..." and "rpm --install wkhtmltopdf-..". If I skip the yum step, rpm complains that wkhtmltopdf needs the xorg package.
It seems like xorg-x11-fonts-75dpi is not installed by ebextensions on deploy. Am I doing something wrong?
According to the docs:
Packages are processed in the following order: rpm, yum, and then rubygems and python.
Elastic beanstalk first processes your rpm package, causing the error and never gets to the yum packages.
There are a few ways to solve this.
1) Run the rpm install through a command like
commands:
install_wkhtmltox:
command: yum -y install https://s3-eu-west-1.amazonaws.com/myS3Account/wkhtmltox-0.12.2.1_linux-centos5-amd64.rpm
This should automatically solve dependencies through yum.
2) Split the .ebextensions files to two: 01_install_dependencies.config and 02_install_wkhtmltox.config. In the 01-file install yum packages, in the 02 file install the rpm. This way you can "override" the package installation order
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages