aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.81k stars 820 forks source link

Error 'Existing schema attributes cannot be modified or deleted' in 'amplify push' following 'amplify update auth' #13160

Closed rayshi67 closed 1 year ago

rayshi67 commented 1 year ago

Before opening, please confirm:

Language and Async Model

Java

Amplify Categories

Authentication

Gradle script dependencies

```groovy // Put output below this line ```

Environment information

``` # Put output below this line ```

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

I couldn't push with AWS amplify as the Auth version was too old that needs to be updated. I did 'amplify update auth' and selected 'Apply default configuration without Social Provider (Federation)'.

However after i did 'amplify push' I got the following error:

Existing schema attributes cannot be modified or deleted. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: null; Proxy: null)

Reproduction steps (if applicable)

amplify update Auth amplify push

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line Deployment failed. Deploying root stack tamappdriverandroid [ =================----------------------- ] 3/7 amplify-tamappdriverandroid-t… AWS::CloudFormation::Stack UPDATE_ROLLBACK_COMPLETE Wed Aug 23 2023 16:00:33… functiontamdriverAmplifyAuthP… AWS::CloudFormation::Stack UPDATE_COMPLETE Wed Aug 23 2023 15:59:57… storages3tamdrivers3firmwareb… AWS::CloudFormation::Stack UPDATE_COMPLETE Wed Aug 23 2023 15:59:47… authtamdriverAmplifyAuth AWS::CloudFormation::Stack UPDATE_FAILED Wed Aug 23 2023 15:59:43… Deploying api amplifyDatasource [ ---------------------------------------- ] 0/26 Deploying auth userPoolGroups [ ---------------------------------------- ] 0/2 Deploying auth tamdriverAmplifyAuth [ ---------------------------------------- ] 0/7 UserPoolClientRole AWS::IAM::Role UPDATE_FAILED Wed Aug 23 2023 15:59:38… UserPool AWS::Cognito::UserPool UPDATE_FAILED Wed Aug 23 2023 15:59:38… Deployed function tamdriverAmplifyAuthPostConfirmation [ ======================================== ] 3/3 Deploying function tamdriverAmplifyTripReceiptEmail [ ---------------------------------------- ] 0/5 Deployed storage s3tamdrivers3firmwarebucket [ ======================================== ] 7/7 🛑 The following resources failed to deploy: Resource Name: UserPool (AWS::Cognito::UserPool) Event Type: update Reason: Existing schema attributes cannot be modified or deleted. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: null; Proxy: null) URL: https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/arn%3Aaws%3Acloudformation%3Aap-southeast-2%3A334851156215%3Astack%2Famplify-tamappdriverandroid-test-234322-authtamdriverAmplifyAuth-15Q51FO8UWH94%2F0f302b80-7f02-11ec-9b16-02a200717f74/events 🛑 Resource is not in the state stackUpdateComplete Name: UserPool (AWS::Cognito::UserPool), Event Type: update, Reason: Existing schema attributes cannot be modified or deleted. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: null; Proxy: null), IsCustomResource: false ```

amplifyconfiguration.json

No response

GraphQL Schema

```graphql // Put your schema below this line ```

Additional information and screenshots

amplify --version 12.3.0

ankpshah commented 1 year ago

Amplify CLI might be right repo for this issue. Transferring this issue to Amplify CLI repo

ykethan commented 1 year ago

Hey @ankpshah, thank you for reaching out. The issue appears to be similar to https://github.com/aws-amplify/amplify-cli/issues/13095 and https://github.com/aws-amplify/amplify-cli/issues/12827.

Was the Amplify CLI upgraded from version before 7.x? If yes, could you try adding the attributes using the override functionality by running amplify override auth. similar to https://github.com/aws-amplify/amplify-cli/issues/13095 and https://github.com/aws-amplify/amplify-cli/issues/12827. Do let us know if this does not mitigate the issue.

rayshi67 commented 1 year ago

Hi @ykethan

Thank you for the prompt reply. I managed to get it working by following #12827. And the command 'amplify push' has now got through.

However when I tried to clone the existing environment, it gives the following error, image

ykethan commented 1 year ago

@rayshi67 could you check the environment stack in Cloudformation console for any error in the events? Does this also occur when utilizing Amplify CLI, to add the env using amplify add env and amplify push?

rayshi67 commented 1 year ago

I deleted a couple of old environments yesterday before doing a clone, and I can see all deletes are completed successfully on Cloudformation console. I cannot see any relevant error there.

There was no error occurred using 'amplify add env' and 'amplify push' earlier. But we need the clone to work otherwise we would have to write migration scripts now

I tried again to clone the existing env today, and got back the same error, 'Cloning env:test to env: tamdev in app:d24pb2d1td9ltj failed'

ykethan commented 1 year ago

Hey @rayshi67, wanted to get some additional information in using the clone mechanism in the AWS console? As using amplify add env and amplify push should create a new environment similar to your existing resources. Additionally, could you also provide us additional information on the migration scripts and its usage?

rayshi67 commented 1 year ago

So what is the root cause of the error when doing the clone in Amplify console?

Without using the clone in Amplify console, how could we back up the Amplify environment including its data?

And if we use ‘amplify env add’ to spin a new env, how would the data in cognito, dynamodb, and s3 etc in existing amplify env get populated into the newly created env? At the moment we haven’t got any mechanism in place for achieving that. So it would be great if you could point us to the right direction.

ykethan commented 1 year ago

@rayshi67 thank you for the information. The clone functionality in the AWS Amplify console is similar to amplify add env, it does not clone the data for the underlying resources being created. As you have pointed, we may have to utilize custom scripts or AWS services that may assist in cloning the data. additionally, the clone error appears to be similar to https://github.com/aws-amplify/amplify-hosting/issues/3022. I have reached out to our folks in hosting team and will provide an update as soon as I receive any additional information.

ykethan commented 1 year ago

wanted to provide an update on this issue, I was able to reproduce the issue by diving into the logs. The clone error was occurring due to resource overrides being present in the project. I have reached out to the appropriate Amplify team regarding this behaviour. But we should be able to utilize amplify add env to create a environment with similar resources as a workaround. Thank you for your patience.

rayshi67 commented 1 year ago

Thank you for the update.

ykethan commented 1 year ago

Closing the issue, please feel free in reaching out to us again.

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

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. If you wish to keep having a conversation with other community members under this issue feel free to do so.