aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
449 stars 113 forks source link

Build Error after Import an existing DynamoDB table: storage headless is missing the following inputParams tables, region #1544

Open ddotx opened 3 years ago

ddotx commented 3 years ago

From Originally posted by @hsspain in https://github.com/aws-amplify/amplify-console/issues/1359#issuecomment-745626000

To resolve this error add the following variables to your environment variables in your build:

AMPLIFY_STORAGE_BUCKET_NAME AMPLIFY_STORAGE_REGION

These values should correlate to the bucket name and region for your imported storage.

This documentation will guide you to the right page to add these settings:

https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html


@hsspain But not work for me when import dynamo and build Error: storage headless is missing the following inputParams tables, region

and after i add ENV like this

AMPLIFY_STORAGE_REGION AMPLIFY_STORAGE_TABLES

Not Work, Same Error


To Reproduce Steps to reproduce the behavior: On any amplify project with deployed frontend and backend

  1. amplify import storage
  2. Select any dynamodb resource
  3. amplify push
  4. git add .
  5. git commit -m 'message'
  6. git push
  7. Go to Amplify Console amplify console
  8. See error
2021-02-06T12:15:53.731Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.
2021-02-06T12:15:54.353Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.
2021-02-06T12:15:54.578Z [WARNING]: ✖ There was an error initializing your environment.
2021-02-06T12:15:54.591Z [INFO]: Failed to pull the backend.
2021-02-06T12:15:54.592Z [INFO]: storage headless is missing the following inputParams tables, region
2021-02-06T12:15:54.596Z [INFO]: Error: storage headless is missing the following inputParams tables, region
                                     at ensureHeadlessParameters (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/import/import-dynamodb.ts:439:11)
                                     at headlessImport (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/import/import-dynamodb.ts:387:40)
                                     at exports.importedDynamoDBEnvInit (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/import/import-dynamodb.ts:277:18)
                                     at runMicrotasks (<anonymous>)
                                     at processTicksAndRejections (internal/process/task_queues.js:97:5)
                                     at updateConfigOnEnvInit (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/index.js:84:72)
                                     at /root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/index.js:147:22
2021-02-06T12:15:54.614Z [ERROR]: !!! Build failed
2021-02-06T12:15:54.615Z [ERROR]: !!! Non-Zero Exit Code detected
davinanaya commented 3 years ago

Same here

Kriz1618 commented 3 years ago

I got the same error, but adding those variants don't solve it, any thoughts?

zeheeba commented 3 years ago

I'm receiving the same error after importing my own DynamoDB into my Amplify setup. Any assistance would be appreciated! `2021-02-21T21:04:08.412Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.

2021-02-21T21:04:08.797Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.

2021-02-21T21:04:08.861Z [WARNING]: ✖ There was an error initializing your environment.

2021-02-21T21:04:08.864Z [INFO]: Failed to pull the backend.

2021-02-21T21:04:08.866Z [INFO]: storage headless is missing the following inputParams tables, region

2021-02-21T21:04:08.870Z [INFO]: Error: storage headless is missing the following inputParams tables, region  at ensureHeadlessParameters (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/import/import-dynamodb.ts:439:11)  at headlessImport (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/import/import-dynamodb.ts:387:40)  at importedDynamoDBEnvInit (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/import/import-dynamodb.ts:277:18)  at processTicksAndRejections (internal/process/task_queues.js:97:5)  at updateConfigOnEnvInit (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/provider-utils/awscloudformation/index.js:84:72)  at /root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-storage/src/index.js:150:22 2021-02-21T21:04:08.887Z [ERROR]: !!! Build failed 2021-02-21T21:04:08.887Z [ERROR]: !!! Non-Zero Exit Code detected`

skilenton commented 3 years ago

hello has anyone found a fix for this yet?

angelo-giuffredi commented 3 years ago

same here. Does anyone has found a solution?

samueuh commented 3 years ago

I have the same problem. Are there any updates?

burntsugar commented 3 years ago

Also following this issue.

zeheeba commented 3 years ago

I bumped this issue through Twitter today and received a positive reply. So I'm hopeful something will shake loose with this. https://twitter.com/Z55_Studios/status/1374838470150131714

victorccccc commented 3 years ago

Hello folks, thanks for reporting this issue. We are currently investigating this.

Update: The issue has been identified, we will prioritize this fix. Will update here as the roll out completes.

tom-hewitt commented 3 years ago

Any idea when we can expect a fix for this? Thanks

samgates3 commented 3 years ago

I have tried everything I can think of to work around this with no luck. Commenting to stay updated

victorccccc commented 3 years ago

Hello folks, We apologize for the delay. Fix is rolling out and should be in Live in a few days. I'll update the status here when deployment completed

victorccccc commented 3 years ago

Update: You can now set AMPLIFY_STORAGE_REGION, and AMPLIFY_STORAGE_TABLES environment variable to address this issue.

Format of AMPLIFY_STORAGE_TABLES is {"Resources Name":"Table Name"}, you can find resource name and table name in your /amplify/team-provider-info.json file

Example:

AMPLIFY_STORAGE_REGION : us-west-2
AMPLIFY_STORAGE_TABLES: {"testResourceName1":"test-table1","testResourceName2":"test-table2"}

team-provider-info.json File:

{
...
"categories": {
      "storage": {
        "testResourceName1": {
          "tableName": "test-table1",
          "region": "us-west-2",
          "arn": "*****",
          "streamArn": "****",
          "partitionKeyName": "***"
          "partitionKeyType": "*",
          "sortKeyName": "****",
          "sortKeyType": "*"
          },
        "testResourceName2": {
          "tableName": "test-table2",
          "region": "us-west-2",
          "arn": "*****",
          "streamArn": "****",
          "partitionKeyName": "***"
          "partitionKeyType": "*",
          "sortKeyName": "****",
          "sortKeyType": "*"
          }
      }
  }
...
}
zeheeba commented 3 years ago

@victorccccc Thanks for the fix and the update! I can confirm that this fix works and deployment completes successfully.

stefanmcshane commented 3 years ago

Issue still exists with amplify version 4.52.0

jianupetrut commented 3 years ago

Issue still exists

reedshea commented 2 years ago

I am also still seeing a related issue, even after including environment variables as described above. In the Amplify Console (not Admin UI), the build succeeds and deploys fine. On the home page of the Amplify Admin UI, however, in the "Deployment activity" table, I see one failed job:

Category: jobCategory.GenerateBackendAPIModels
Status: FAILED
Reason: storage headless is missing the following inputParams tables, region

As a result of this, I believe, I am unable to modify my schema via the Amplify Admin UI. Making changes and clicking "Save and deploy" results in an message:

Command failed with exit code 1: /root/.amplify/bin/amplify pull --amplify  {"envName":"dev","defaultEditor":"code",...
Deployment status: Failed
- Fetching updates to backend environment: dev from the cloud.
✔ Successfully pulled backend environment dev from the cloud.
✖ There was an error initializing your environment.
...
[32mGraphQL schema compiled successfully.
...
[0mSuccessfully generated models. Generated models can be found in /tmp/amplify...
[31mFailed to pull the backend.
[31mstorage headless is missing the following inputParams tables, region
[0mError: storage headless is missing the following inputParams tables, region
[0m    at ensureHeadlessParameters (/snapshot/node_modules/amplify-category-storage/lib/provider-utils/awscloudformation/import/import-dynamodb.js:367:11)
[0m    at ensureHeadlessParameters (/snapshot/node_modules/amplify-category-storage/lib/provider-utils/awscloudformation/import/import-dynamodb.js:367:11)
[0m    at headlessImport (/snapshot/node_modules/amplify-category-storage/lib/provider-utils/awscloudformation/import/import-dynamodb.js:327:40)
[0m    at importedDynamoDBEnvInit (/snapshot/node_modules/amplify-category-storage/lib/provider-utils/awscloudformation/import/import-dynamodb.js:227:18)
[0m    at runMicrotasks (<anonymous>)
[0m    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[0m    at Object.updateConfigOnEnvInit (/snapshot/node_modules/amplify-category-storage/lib/provider-utils/awscloudformation/index.js:157:9)
[0m    at /snapshot/node_modules/amplify-category-storage/lib/index.js:216:22

@victorccccc , thank you for the guidance above. That helped substantially, as I was able to get the build working. This seems like it's related. I would like to be able to use the Amplify Admin UI to build out a GraphQL schema, so I'd be grateful for any suggestions or assistance.

JGillam commented 2 years ago

@victorccccc (or anyone else) Any idea when this is supposed to get rolled into the latest build? I'm experiencing the issue exactly as described by the OP, so I assume this has not been pushed to the latest production Amplify code. For a little more context:

I started with an existing Amplify project with auth, apis, and functions on the backend. This was deploying perfectly out of a github branch using the default amplify.yml.

Then I imported a dynamo table (i.e. amplify import storage), which deploys fine in dev using amplify push.

But when I merged the changes to my deploying branch, I got the error message regarding storage headless is missing the following inputParams tables, region. Then I found this thread and added AMPLIFY_STORAGE_REGION and AMPLIFY_STORAGE_TABLES environment variables in the Amplify console, as you described above. But I am still getting the error.

Is it possible I am missing some other configuration steps?

JGillam commented 2 years ago

An alternative solution that worked for me was to set a CATAGORIES environment variable with a value such as:

{"storage":{"region": "us-east-1", "tables": {"mytableresource":"mytablename"}}}

The values are:

It seems a side effect of this approach broke auth configuration on the frontend, which I fixed with a Auth.configure(awsconfig) as described in this issue comment.