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
82 stars 71 forks source link

Deployment failed: MissingRequiredParameter: Missing required key 'functionId' in params #2307

Open cabcookie opened 4 months ago

cabcookie commented 4 months ago

Environment information

System:
  OS: macOS 14.3.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 112.33 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn: undefined - undefined
  npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 0.12.1
  @aws-amplify/backend-cli: 0.11.1
  aws-amplify: 6.0.16
  aws-cdk: 2.126.0
  aws-cdk-lib: 2.126.0
  typescript: 5.3.3
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

Hello, I run into an issue with my sandbox environment. It happened twice to me in the last 2 weeks and I had to delete and recreate my sandbox which has been quite cumbersome (including recreation of demo data). I login to my account using SSO and the profile org-data-amplify. My session is valid for a couple of hours and then I need to sign in again. Yesterday, I launched my sandbox environment with npx amplify sandbox --profile org-data-amplify and forgot to stop it. So, today I got back to VS Code (I didn't restart it) and stopped the sandbox and ran the command again. Now, I tried to make a change to my data model. I changed my Activity schema from

const schema = a.schema({
  Context: a.enum(["family", "hobby", "work"]),
  Activity: a
    .model({
      owner: a.string().authorization([a.allow.owner().to(["read", "delete"])]),
      notes: a.string(),
      finishedOn: a.datetime(),
    })
    .authorization([a.allow.owner()]),
});

to

const schema = a.schema({
  Context: a.enum(["family", "hobby", "work"]),
  Activity: a
    .model({
      owner: a.string().authorization([a.allow.owner().to(["read", "delete"])]),
      notes: a.string(),
      slateNotes: a.string(),
      finishedOn: a.datetime(),
    })
    .authorization([a.allow.owner()]),
});

Amplify identified correctly a file update, synthesized the template and tried to deploy the update but then failed with the mentioned error message. Here is the output in my console: [Sandbox] Triggered due to a file update event: /Users/carskoch/Development/personal-crm/amplify/data/resource.ts

✨ Synthesis time: 3.86s

⚠️ The --hotswap and --hotswap-fallback flags deliberately introduce CloudFormation drift to speed up deployments ⚠️ They should only be used for development - never use them for your production Stacks!

amplify-personalcrm-carskoch-sandbox-63e4bb09d0: deploying... [1/1]

✨ hotswapping resources: ✨ AWS::AppSync::FunctionConfiguration 'MutationcreateActivityauth0Function' ✨ AWS::AppSync::FunctionConfiguration 'MutationupdateActivityauth0Function' ✨ AWS::AppSync::GraphQLSchema 'uevvie4lgje2pegsontu5uvbwaGraphQLSchema' ✨ Contents of S3 Bucket 'amplify-personalcrm-carsk-amplifydataamplifycodege-8slq063fvosf'

✨ Contents of S3 Bucket 'amplify-personalcrm-carsk-amplifydataamplifycodege-8slq063fvosf' hotswapped! ✨ AWS::AppSync::GraphQLSchema 'uevvie4lgje2pegsontu5uvbwaGraphQLSchema' hotswapped! The CloudFormation deployment has failed. Find more information in the CloudFormation AWS Console for this stack. Caused By: ❌ Deployment failed: MissingRequiredParameter: Missing required key 'functionId' in params

It mentions I should verify CloudFormation. However, CloudFormation is not showing any events. How can I fix this issue?

cabcookie commented 4 months ago

I ran npx amplify sandbox with the --debug option and received more details:

[DEBUG] 2024-02-27T13:05:14.681Z: 
 ❌  amplify-personalcrm-carskoch-sandbox-63e4bb09d0 failed: MissingRequiredParameter: Missing required key 'functionId' in params
    at ParamValidator.fail (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:224807)
    at ParamValidator.validateStructure (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:225157)
    at ParamValidator.validateMember (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:225789)
    at ParamValidator.validate2 [as validate] (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:224402)
    at Request.VALIDATE_PARAMETERS (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:143072)
    at Request.callListeners (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:91385)
    at callNextListener (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:91177)
    at /Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:141847
    at finish (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:125042)
    at /Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:125392 {
  code: 'MissingRequiredParameter',
  time: 2024-02-27T13:05:14.680Z
}

[DEBUG] 2024-02-27T13:05:14.681Z: 
 ❌ Deployment failed: MissingRequiredParameter: Missing required key 'functionId' in params
    at ParamValidator.fail (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:224807)
    at ParamValidator.validateStructure (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:225157)
    at ParamValidator.validateMember (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:225789)
    at ParamValidator.validate2 [as validate] (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:224402)
    at Request.VALIDATE_PARAMETERS (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:143072)
    at Request.callListeners (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:91385)
    at callNextListener (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:91177)
    at /Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:141847
    at finish (/Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:125042)
    at /Users/carskoch/Development/personal-crm/node_modules/aws-cdk/lib/index.js:373:125392 {
  code: 'MissingRequiredParameter',
  time: 2024-02-27T13:05:14.680Z
}
ykethan commented 4 months ago

Hey @cabcookie, could you try bumping the package version to beta which should contain the latest changes and re-run the sandbox.

"@aws-amplify/backend": "0.13.0-beta.3",
"@aws-amplify/backend-cli": "0.12.0-beta.3",
cabcookie commented 4 months ago

I created a separate sandbox to ensure I can reproduce the error if you come up with a recommendation. I just shifted back to the sandbox with the issue and tried to reproduce the error and yes I succeeded.

My simplified schema looks like this:

import { type ClientSchema, a, defineData } from "@aws-amplify/backend";

const schema = a.schema({
  Activity: a
    .model({
      owner: a.string().authorization([a.allow.owner().to(["read", "delete"])]),
      notionId: a.integer(),
      notes: a.string(),
      forProjects: a.manyToMany("Projects", {
        relationName: "ProjectActivity",
      }),
      forMeeting: a.belongsTo("Meeting"),
      finishedOn: a.datetime(),
    })
    .authorization([a.allow.owner()]),
});

export type Schema = ClientSchema<typeof schema>;

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: "userPool",
  },
});

Now, when I add a property to my model (e.g., noteVersion: a.integer()), I run into this issue. I update my package.json with the following lines:

"@aws-amplify/backend": "0.13.0-beta.3",
"@aws-amplify/backend-cli": "0.12.0-beta.3",

and ran npm i in my terminal. When I do the same schema change again it starts running the CloudFormation changes and succeeds.

I tried to understand what changed between the versions and can't spot what change could impact the sandbox to successfully making the changes now.

cabcookie commented 4 months ago

I removed the new property. The sandbox recognized the change on the schema and tried to implement the changes again and failed with the same error message:

The CloudFormation deployment has failed. Find more information in the CloudFormation AWS Console for this stack.
Caused By: ❌ Deployment failed: MissingRequiredParameter: Missing required key 'functionId' in params
cabcookie commented 4 months ago

As I seem to have a working sandbox I compared the 2 amplifyconfiguration.json files and the main differences between the 2 were how the enums were treated.

When comparing the 2 configuration files, these are the differences (comparing the failing configuration to the working configuration):

Deleted:

Updated:

Added:

I guess this is because of the "failing" configuration has been created with a previous version, and the new sandbox has been created using these versions:

@aws-amplify/backend: 0.12.1
@aws-amplify/backend-cli: 0.11.1

I have no idea if this impacts the behaviour and causing the problem though

ykethan commented 4 months ago

Hey @cabcookie, thank you for providing this detailed information. I'm going to transfer this over to our API repository for better assistance 🙂.

AnilMaktala commented 4 months ago

Hey @cabcookie, We aim to explore this issue further. Could you possibly join a call with us to delve deeper into the issue?

AnilMaktala commented 2 months ago

Hey @cabcookie, Are you still facing this issue in the latest version?

pkubat commented 1 month ago

@AnilMaktala See this issue with
"@aws-amplify/backend": "^1.0.2", "@aws-amplify/backend-cli": "^1.0.3",

cabcookie commented 1 month ago

I saw this issue again today in my sandbox environment. Had to delete and recreate it. I am using the versions mentioned by @pkubat

asanobm commented 1 month ago
image

... this?

cabcookie commented 1 month ago

Yes exactly @asanobm

asanobm commented 1 month ago

@cabcookie

Yes, I've had that same experience multiple times. In the end, the only solutions were either to recreate the sandbox or reset the data structure to its original state and try again.

I apologize for not being of much help. It seems like there might be a bug. It would be a good idea to create a bug report.

npx ampx info
System:
  OS: macOS 14.4.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 22.71 GB / 64.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.20.2 - ~/.nodebrew/current/bin/node
  Yarn: undefined - undefined
  npm: 10.8.0 - ~/workspace/fleeklounge/amplify-next-template/node_modules/.bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.2
  @aws-amplify/backend-cli: 1.0.3
  aws-amplify: 6.3.2
  aws-cdk: 2.142.0
  aws-cdk-lib: 2.142.0
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
asanobm commented 1 month ago

@cabcookie

Hello. The same error occurred today as well. After trying various methods, I updated the amplify CLI and it seems to have resolved the issue.

image
LukaASoban commented 1 month ago

@asanobm I seem to have gotten the same error today as well. Updating didn't seem to help.

JDMathew commented 1 month ago

I'm also bumping into this issue on: "@aws-amplify/backend": "^1.0.2", "@aws-amplify/backend-cli": "^1.0.3",

kekami commented 1 month ago

Also running into this issue

jewells07 commented 3 weeks ago

image I got the same error. I reverted back to where there was no error, ran the sandbox command, and then I changed again. It worked for me. It was a weird behavior, but just give it a try.

suekou commented 1 week ago

The same error occurred as well. I commented out the model defined in resource.ts that I recently changed. After the error disappeared, I uncommented it, and it worked.

treewhopper commented 1 week ago

also seeing this issue with: "@aws-amplify/backend": "1.0.4", "@aws-amplify/backend-cli": "1.1.0",

wavegate commented 1 week ago

Encountering this after schema modifications occasionally. I have to delete and re-seed my sandbox

cabcookie commented 1 week ago

Over the past 2 weeks. I ran into the issue multiple times. I couldn't find another solution than destroying my sandbox environment and creating a new one. I am running these versions right now:

System:
  OS: macOS 14.5
  CPU: (10) arm64 Apple M1 Pro
  Memory: 148.27 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn: undefined - undefined
  npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.3
  @aws-amplify/backend-cli: 1.0.4
  aws-amplify: 6.3.4
  aws-cdk: 2.144.0
  aws-cdk-lib: 2.144.0
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Will update packages and try again.