Search code examples
react-nativeaws-lambdaaws-amplifyaws-amplify-cli

Error adding Lambda function with AWS Amplify CLI


I am encountering an issue when trying to add a Lambda function using AWS Amplify CLI. The process fails with different errors depending on the version of the CLI that I use. Below are the details of the CLI versions and the respective errors:

  1. Using AWS Amplify CLI version 12.12.0 After running npm i @aws-amplify/cli@latest -g, I attempted to add a Lambda function using the following command:
amplify add function

The process prompts me to select the capability (Lambda function), but then it abruptly stops with the following error:

🛑 There was an error adding the function resource
  1. Using AWS Amplify CLI version 9.2.1 After updating the CLI to version 9.2.1 with npm i @aws-amplify/[email protected] -g, I received a different error when attempting the same operation:
amplify add function

The error displayed is:

TypeError: Cannot read property 'toLowerCase' of undefined
at autogeneratedParameters (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/autogeneratedParameters.js:7:35)

In both cases, I am unable to proceed with adding a Lambda function. The Amplify library version in my project is "aws-amplify": "4.3.46".

Has anyone else encountered this issue or can provide any insights on how to resolve these errors? Any help would be greatly appreciated.


Solution

  • < .config/project-config.json への projectName の追加例 >

    {
      "frontend": "javascript",
      "javascript": {
        "framework": "none",
        "config": {
          "SourceDir": "amplify-codegen-temp"
        }
      },
      "providers": [
        "awscloudformation"
      ],
      "projectName": "case171557251600363" # 追加
    }
    

    ※ 実際の projectName の値はお客様のプロジェクト名を記載してください。