# Migrating AWS Lambda Functions to E2E Consider an example where the AWS Lambda function is already available on a GitHub repository. ## Steps to Migrate 1. **Clone the Repository** First, the user needs to clone the repository using the Git Clone command. ![Migration Function 1](images/Migration_Function1.png) ![Migration Function 2](images/Migration_Function2.png) 2. **Accessing the Function Locally** After cloning, the Function and its supporting files can be accessed locally. Their listing would look like this. ![Migration Function 3](images/Migration_Function3.png) 3. **Create the Workflows Directory** Inside the same directory, create the `.github/workflows` directory using the command: ```bash mkdir -p .github/workflows ```python mkdir -p .github/workflows ``` 4. **Create the `deploy.yml` File** Create a file with the name `deploy.yml` under the `workflows` folder using the command: ```bash touch .github/workflows/deploy.yml ``` 5. **Download the YAML File** Download this YAML file from [here](https://github.com/tarune2e/e2e-function-py-f1/blob/master/.github/workflows/deploy.yml). Copy its content and paste it inside the `deploy.yml` file. ![Migration Function 5](images/Migration_Function5.png) ![Migration Function 6](images/Migration_Function6.png) 6. **Rename the Function File** Change your function file name from `lambda_function.py` to `code.txt`. ![Migration Function 7](images/Migration_Function7.png) ![Migration Function 8](images/Migration_Function8.png) 7. **Change the Entry-Level Function Name** Change the entry-level function name from `def lambda_handler` to `def handler`. ![Migration Function 9](images/Migration_Function9.png) ![Migration Function 10](images/Migration_Function10.png) 8. **Modify the `deploy.yml` File** Make changes in the `deploy.yml` file: - Change the branch name to the one 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, and the runtime must correspond to the supported language choices. ![Migration Function 11](images/Migration_Function11.png) 9. **Commit the Changes** ![Migration Function 12](images/Migration_Function12.png) 10. **Create the Function Using E2E CLI** Use the E2E CLI command line tool to create the function. If the E2E CLI tool is not installed, please refer to the [documentation](/docs/myaccount/e2e_cli/faas_cli_intro/#deploy) for installation instructions. ![Migration Function 13](images/Migration_Function13.png) 11. **Generate API Key and Auth Token** On GitHub, go to the repository’s settings tab. Navigate to **Security > Secrets and variables > Actions**. 12. In case you need to generate a new API key and Auth Token, please refer to the Documentation. ![Migration Function 14](images/Migration_Function14.png) ![Migration Function 15](images/Migration_Function15.png) 13. **Create Repository Secrets** 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 the API key generated from MyAccount as the value for this secret. - **E2E_AUTH_TOKEN:** Use the Auth Token generated from MyAccount as the value for this secret. ![Migration Function 16](images/Migration_Function16.png) ![Migration Function 17](images/Migration_Function17.png) 14. **Push the Code** Now push the code using the `git push` command. 15. **Check Workflow Execution** On GitHub, navigate to **Actions > All workflows**. You will see a workflow under execution. Once it is executed successfully, the Function will be redeployed. You can verify this on the MyAccount cloud console. ![Migration Function 18](images/Migration_Function18.png) ![Migration Function 19](images/Migration_Function19.png) ---