aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
87 stars 75 forks source link

DeploymentAwaiter fails to update in a project with serverless containers enabled #2730

Closed ashphy closed 1 month ago

ashphy commented 1 month ago

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v20.13.1

Amplify CLI Version

12.12.4

What operating system are you using?

macOS Sonoma 14.5

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

In a project with Serverless containers enabled, updating a backend deployed with Amplify CLI v12.12.3 or earlier to Amplify CLI v12.12.4 and then running amplify push results in a failure to update DeploymentAwaiter.

Context:

Issue:

INIT_START Runtime Version: nodejs:18.v31   Runtime Version ARN: arn:aws:lambda:us-west-2::runtime:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2024-07-30T12:16:16.780Z    undefined   ERROR   Uncaught Exception  {
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/outbound.js\n- /var/task/cfn-response.js\n- /var/task/framework.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'",
        "Require stack:",
        "- /var/task/outbound.js",
        "- /var/task/cfn-response.js",
        "- /var/task/framework.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:1087:17)",
        "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
        "    at async start (file:///var/runtime/index.mjs:1282:23)",
        "    at async file:///var/runtime/index.mjs:1288:1"
    ]
}

Reviewing the CloudFormation Template reveals the following entry:

The S3Key is fixed, which likely causes the source code not to be updated.

Changes to a deployment package in Amazon S3 or a container image in ECR are not detected automatically during stack updates. To update the function code, change the object key or version in the template.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html

The source code custom-resource-pipeline-awaiter.zip uploaded to the deployment bucket has been confirmed to be updated. However, the code on the lambda was confirmed to be NOT updated.

Expected behavior

The DeploymentAwaiter source code should be updated to the latest version, and CloudFormation should complete successfully.

Reproduction steps

  1. Create an Amplify app with Amplify CLI v12.12.3 and enable Serverless containers.
  2. Run amplify push to update the backend.
  3. Update Amplify CLI to v12.12.4.
  4. Run amplify push to update the backend.
  5. An error occurs.

Project Identifier

Project Identifier: 52a166481f025be404045fcd549de961

Log output

No response

Additional information

No response

Before submitting, please confirm:

AnilMaktala commented 1 month ago

Hey @ashphy, Thank you for raising this issue. I am working on reproducing it and will keep you updated on the outcome.

AnilMaktala commented 1 month ago

Hey @ashphy, We can reproduce the issue by following the steps mentioned in the description. Hence, marking this as bug for the team to evaluate further. To unblock, could you please downgrade to the previous CLI version until we resolve this issue?

image
ashphy commented 1 month ago

Thank you for your prompt response. As suggested, I will downgrade to the previous version. Please feel free to close the issue once the fix is merged.

Jupdi commented 1 month ago

We are also affected by the error and would appreciate a fast fix.

dpilch commented 1 month ago

CLI v12.12.6 has been released with the fix.

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.