To use binaries from within AWS lambda functions, you need to have the compiled binaries available within the lambda package used and for that you sometimes need to compile those yourself. To do that, you can either compile on an Amazon Linux docker image (more information on how to do this here and from the aws docs) or compile the binary on an EC2 instance that uses the same environment as the underlying AWS Lambda execution environment. This latter is what’s described here.
You can launch this EC2 by the AMI mentioned here:
Note that the EC2 instance that will be launched is an Amazon Linux EC2 (Not Debian/Ubuntu) which means that to login you’ll need to use
ssh -i my-private-key.pem ec2-user@the.ipa.ddr.ess
The following table summarizes various user names for different EC2 platforms (taken from here):
AMI type | ssh username to use |
---|---|
Amazon Linux AMI | ec2-user |
Centos AMI | centos |
Debian AMI | admin or root |
Fedora AMI | ec2-user or fedora |
RHEL AMI | ec2-user or root |
SUSE AMI | ec2-user or root |
Ubuntu AMI | ubuntu or root |
Of course, don’t forget to chmod 600 your private key or you’ll get a complaint from ssh…
Once logged in to the Amazon Linux EC2, you’ll want to install the relevant development tools to be able to compile whatever it is you’re compiling. Unlike Debian family of Linux distributions (Debian, Ubuntu, Mint etc.) which use apt/apt-get/dpkg to install packages, Amazon Linux uses the yum package manager (RedHat, Fedora etc.), and while on a Debian system you’d use sudo apt-get install build-essential
to install your gcc compiler and other necessary development tools, to achieve more or less the same with yum, enter:
sudo yum groupinstall "Development Tools"
Now you’re ready to start compiling. Hopefully, the next post will explain how to package and launch the compiled binaries and their dependencies. I expect a lot of environment/path definitions, dependency tracking, and other gotchas along the way, but one step at a time…