Migrating AWS Lambda Functions to E2E
Consider an example where the AWS lambda function is already available on a GitHub repository.
First of all the user needs to clone the repository using the Git Clone command.
After cloning, the Function and its supporting files can be accessed locally. Their listing would look like this.
Inside the same directory, create .github/workflows directory using the command
mkdir -p .github/workflows
Create a file with the name deploy.yml under the workflows folder using the command
touch .github/workflows/deploy.yml
Download this yaml file using link. Copy its content and paste it inside the deploy.yml file.
Change your function file name from lambda_function.py to code.txt.
Change the entry-level function name from def lambda_handler to def handler.
Make changes in the deploy.yml file.
Change the branch name. The branch from which you want to trigger the automatic deployment.
Change the function name and runtime. The function name should be the same as the repository name. The runtime must be the one according to the supported language choices.
Commit the changes.
Create the function using the e2e-cli command line tool. If e2e-cli tool is not installed, please refer to the documentation and install it.
On GitHub, go to the repository’s settings tab. Navigate to Security > Secrets and variables > Actions
In case of generating a new API key and Auth-Token please refer to the Documentation.
Navigate to the Repository Secrets section and create new secrets by clicking the New Repository Secret button. Create the following two secrets:
E2E_API_KEY: Use apikey generated from MyAccount as the value for this secret.
E2E_AUTH_TOKEN: Use the authtoken generated from MyAccount as the value for this secret.
Now push the code using the git push command.
On GitHub navigate to the Actions > All workflows. You will see a workflow under execution. Once it is executed successfully, the Function will be redeployed. Same you can check on the MyAccount cloud console.