Atlantis for Terraform with support for automated building of python AWS Lambda Functions [Dockerfile]
If you look for a way to use Atlantis both to deploy your infrastructure as a code and package and build AWS Lambda Functions with Python I provide you a Dockerfile for that purpose. Some use cases require, that the Terraform repository holds the infra as code and also the actual source code that this infra should execute. In the case of the Lambda functions, that is both the description for a function (how much memory, timeout, IAM role) as well as the actual code that has to be executed. On the other hand python lambda functions has to be built and zipped locally, especially if they contain external libraries, before uploading them to the cloud. That means, the machine, or cluster that runs Atlantis needs Python to perform the task, and that is what the following image gives you: it pulls the original Atlantis image from Docker Hub and on top of that installs Python.
Important: You probably want to include this (or similar) terraform module to build the python packages: https://github.com/claranet/terraform-aws-lambda
Dockerfile:
FROM runatlantis/atlantis:latest
ENV USER atlantis_deploy
RUN adduser -D $USER
ENV HOME /home/$USER
ENV PY_VERSION='3.7.2'
RUN apk add --no-cache --update \
curl git bash bash-doc bash-completion \
openssh libffi-dev \
openssl-dev \
bzip2-dev zlib-dev zip \
readline-dev sqlite-dev \
build-base \
linux-headers \
util-linux \
docker
WORKDIR /home/$USER
# Install Python 3.7 via pyenv
ARG PYENV_HOME=$HOME/.pyenv
RUN git clone --depth 1 https://github.com/pyenv/pyenv.git $PYENV_HOME && \
rm -rfv $PYENV_HOME/.git
ENV PATH $PYENV_HOME/shims:$PYENV_HOME/bin:$PATH
RUN pyenv install $PY_VERSION
RUN pyenv global $PY_VERSION
RUN pip install --upgrade pip && pyenv rehash
RUN rm -rf ~/.cache/pip
# Install additional software
RUN pip3 install --upgrade awscli pipenv boto3 click ssm-cache
3
Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your blog? My website is in the exact same niche as yours and my users would truly benefit from some of the information you present here. Please let me know if this ok with you. Regards!