Running TagUI RPA as a Lambda Function

0

I am trying to run a simple TagUI flow as a Lambda function using container images. I have made a Dockerfile using the bootstrap and function.sh from this tutorial:

FROM amazon/aws-lambda-provided:al2

RUN yum install -y wget nano php java-1.8.0-openjdk unzip procps

RUN curl https://intoli.com/install-google-chrome.sh | bash

RUN wget https://github.com/kelaberetiv/TagUI/releases/download/v6.46.0/TagUI_Linux.zip \
    && unzip TagUI_Linux.zip \
    && rm TagUI_Linux.zip \
    && ln -sf /var/task/tagui/src/tagui /usr/local/bin/tagui \
    && tagui update 

RUN sed -i 's/no_sandbox_switch=""/no_sandbox_switch="--no-sandbox"/' /var/task/tagui/src/tagui

ADD tr.tag /var/task/tagui/src/tr.tag

WORKDIR /var/runtime/
COPY bootstrap bootstrap
RUN chmod 755 bootstrap

WORKDIR /var/task/
COPY function.sh function.sh
RUN chmod 755 function.sh

CMD [ "function.sh.handler" ]

My function.sh:

function handler () {
   cp -r /var/task/tagui/src/* /tmp;
   chmod 755 /tmp/tagui;
   OUTPUT=$(/tmp/tagui /tmp/tr.tag -h);
   echo "${OUTPUT}";
}

Notes:

  • the sed line is required to get TagUI running in docker images.
  • tr.tag is just a simple flow to do a password reset on a webapp so I can confirm the container has run.
  • everything has to be run in /tmp as that is the only folder Lambda can write to in the container and TagUI creates a load of temporary files during execution.

When I run as a Lambda I get the error:

./tmp/tagui/src/tagui: line 398: 56 Trace/breakpoint trap (core dumped) $chrome_command --user-data-dir="$TAGUI_DIR/chrome/tagui_user_profile" $chrome_switches $window_size $headless_switch $no_sandbox_switch > /dev/null 2>&1

When I run the container from Docker it runs perfectly. I have tried increasing both the memory and timeout of the function.

The end goal I am trying to achieve is to have a Lambda function triggered by an API gateway that can receive a TagUI RPA flow and run it.

已提問 2 年前檢視次數 354 次
1 個回答
0

When you create a Lambda function as a container image you must include in there the Runtime Interface Client. This is the component which is responsible for interfacing between the Lambda runtime and your function handler. You can either install it yourself in the image or you can use a support base image which includes the RIC.

Your Lambda handler should do whatever it needs with TagUI and the RPA flow (I am not familiar with those so not sure what is needed).

profile pictureAWS
專家
Uri
已回答 2 年前
profile picture
專家
已審閱 1 個月前
  • Thank you for your assistance. Please see update above based on your answer.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南