aws-amplify / amplify-cli

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

Invalid request provided: Existing schema attributes cannot be modified or deleted. doing amplify push after adding a custom CDK stack #13989

Closed charith-eLovu closed 3 weeks ago

charith-eLovu commented 1 month ago

Before opening, please confirm:

JavaScript Framework

React, React Native

Amplify APIs

Authentication, Analytics, Push Notifications

Amplify Version

v5

Amplify Categories

auth, function, notifications

Backend

Amplify CLI

Environment information

``` # Put output below this line System: OS: macOS 14.2.1 CPU: (8) arm64 Apple M1 Memory: 109.44 MB / 16.00 GB Shell: 3.6.0 - /opt/homebrew/bin/fish Binaries: Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node Yarn: 1.22.22 - ~/.nvm/versions/node/v16.14.2/bin/yarn npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm Watchman: 2024.06.24.00 - /opt/homebrew/bin/watchman Browsers: Brave Browser: 126.1.67.123 Chrome: 117.0.5938.92 Safari: 17.2.1 npmPackages: <%= name %>: <%= version %> @aws-amplify/rtn-push-notification: ^1.2.12 => 1.2.12 (1.1.11) @aws-amplify/rtn-web-browser: ^1.0.3 => 1.0.5 @babel/core: ^7.14.5 => 7.23.3 @babel/preset-react: ^7.14.5 => 7.23.3 @chakra-ui/react: ^2.8.2 => 2.8.2 @config-plugins/detox: ~6.0.0 => 6.0.0 @cypress/angular: 0.0.0-development @cypress/mount-utils: 0.0.0-development @cypress/react: 0.0.0-development @cypress/react18: 0.0.0-development @cypress/svelte: 0.0.0-development @cypress/vue: 0.0.0-development @cypress/vue2: 0.0.0-development @emotion/react: ^11.11.1 => 11.11.1 @emotion/styled: ^11.11.0 => 11.11.0 @expo/cli: ~0.10.12 => 0.10.16 (0.10.12) @expo/metro-config: ~0.10.7 => 0.10.7 @medplum/core: ^3.0.10 => 3.0.10 @medplum/fhirtypes: ^3.0.10 => 3.0.10 @nestjs-cognito/auth: ^1.0.11 => 1.0.11 @nestjs/common: ^10.0.2 => 10.2.10 @nestjs/core: ^10.0.2 => 10.2.10 @nestjs/platform-express: ^10.0.2 => 10.2.10 @nestjs/schematics: ^10.0.1 => 10.0.3 (9.2.0) @nestjs/swagger: ^7.1.14 => 7.1.16 @nestjs/testing: ^10.0.2 => 10.2.10 @nx/cypress: 17.0.1 => 17.0.1 @nx/detox: 17.2.8 => 17.2.8 (17.1.3) @nx/eslint: 17.0.1 => 17.0.1 (17.2.8, 17.1.3) @nx/eslint-plugin: 17.0.1 => 17.0.1 @nx/expo: ^17.0.2 => 17.1.3 @nx/jest: 17.2.8 => 17.2.8 (17.1.3, 17.0.1) @nx/js: 17.2.8 => 17.2.8 (17.0.1, 17.1.3) @nx/nest: ^17.0.1 => 17.1.3 @nx/node: 17.0.1 => 17.0.1 (17.1.3) @nx/react: 17.0.1 => 17.0.1 (17.2.8, 17.1.3) @nx/react-native: ^17.2.8 => 17.2.8 @nx/vite: 17.0.1 => 17.0.1 @nx/webpack: 17.0.1 => 17.0.1 (17.1.3) @nx/workspace: 17.0.1 => 17.0.1 (17.1.3, 17.2.8) @prisma/client: ^5.5.2 => 5.6.0 @react-native-async-storage/async-storage: ^1.21.0 => 1.21.0 @react-native-community/cli: 11.3.7 => 11.3.7 @react-native-community/cli-platform-android: 11.3.7 => 11.3.7 @react-native-community/cli-platform-ios: 11.3.7 => 11.3.7 @react-native-community/datetimepicker: 7.2.0 => 7.2.0 @react-native-community/netinfo: ^9.5.0 => 9.5.0 @react-native-masked-view/masked-view: ^0.3.0 => 0.3.0 @react-native/metro-config: ^0.72.11 => 0.72.11 @react-navigation/bottom-tabs: ^6.5.11 => 6.5.11 @react-navigation/native: ^6.1.9 => 6.1.9 @react-navigation/stack: ^6.3.20 => 6.3.20 @reduxjs/toolkit: ^1.9.7 => 1.9.7 @reduxjs/toolkit-query: 1.0.0 @reduxjs/toolkit-query-react: 1.0.0 @swc-node/register: ~1.6.7 => 1.6.8 @swc/cli: ~0.1.62 => 0.1.63 @swc/core: ~1.3.85 => 1.3.99 @swc/helpers: ~0.5.2 => 0.5.3 @tanstack/query-codemods: 4.24.3 @tanstack/react-query: ^5.4.3 => 5.8.7 @tanstack/react-query-devtools: ^5.4.3 => 5.8.7 @testing-library/jest-dom: 5.16.5 => 5.16.5 @testing-library/jest-native: ~5.4.3 => 5.4.3 @testing-library/react: 14.0.0 => 14.0.0 @testing-library/react-native: ~12.3.0 => 12.3.3 @types/jest: ^29.4.0 => 29.5.10 @types/lodash: ^4.17.6 => 4.17.6 @types/mssql: ^9.1.5 => 9.1.5 @types/node: 18.16.9 => 18.16.9 (18.18.13) @types/react: 18.2.24 => 18.2.24 @types/react-dom: 18.2.9 => 18.2.9 @types/react-is: 18.2.2 => 18.2.2 @types/react-native-vector-icons: ^6.4.17 => 6.4.18 @types/styled-components: 5.1.26 => 5.1.26 @types/styled-components-react-native: ^5.2.4 => 5.2.5 @typescript-eslint/eslint-plugin: ^5.60.1 => 5.62.0 @typescript-eslint/parser: ^5.60.1 => 5.62.0 @vitejs/plugin-react: ~4.0.0 => 4.0.4 @vitest/coverage-c8: ~0.32.0 => 0.32.4 @vitest/ui: ~0.32.0 => 0.32.4 HelloWorld: 0.0.1 amazon-cognito-identity-js: ^6.3.10 => 6.3.10 amazon-cognito-identity-js/internals: undefined () aws-amplify: ^5.3.15 => 5.3.15 aws-amplify-react-native: ^7.0.8 => 7.0.8 axios: ^1.0.0 => 1.6.5 babel-jest: ^29.4.1 => 29.7.0 babel-plugin-styled-components: 1.10.7 => 1.10.7 (2.1.4) babel-preset-expo: ~9.5.2 => 9.5.2 cypress: ^13.0.0 => 13.6.0 detox: ^20.11.1 => 20.13.5 eas-cli: ~5.2.0 => 5.2.0 emoji-picker-react: ^4.11.1 => 4.11.1 eslint: ~8.46.0 => 8.46.0 eslint-config-prettier: ^9.0.0 => 9.0.0 eslint-plugin-cypress: ^2.13.4 => 2.15.1 eslint-plugin-import: 2.27.5 => 2.27.5 eslint-plugin-jsx-a11y: 6.7.1 => 6.7.1 eslint-plugin-react: 7.32.2 => 7.32.2 eslint-plugin-react-hooks: 4.6.0 => 4.6.0 expo: 49.0.10 => 49.0.10 expo-splash-screen: ~0.20.5 => 0.20.5 expo-status-bar: ~1.6.0 => 1.6.0 framer-motion: ^10.16.16 => 10.16.16 jest: ^29.4.1 => 29.7.0 jest-circus: ^29.4.1 => 29.7.0 jest-environment-jsdom: ^29.4.1 => 29.7.0 jest-environment-node: ^29.4.1 => 29.7.0 jest-expo: ~49.0.0 => 49.0.0 jest-react-native: 18.0.0 => 18.0.0 jsdom: ~22.1.0 => 22.1.0 (20.0.3) metro: 0.76.8 => 0.76.8 metro-babel-register: 0.76.8 => 0.76.8 metro-config: 0.76.8 => 0.76.8 metro-react-native-babel-preset: 0.76.8 => 0.76.8 metro-react-native-babel-transformer: 0.76.8 => 0.76.8 metro-resolver: 0.76.8 => 0.76.8 moment: ^2.29.4 => 2.29.4 moment-timezone: ^0.5.45 => 0.5.45 mssql: ^11.0.1 => 11.0.1 nestjs-zod: ^3.0.0 => 3.0.0 nx: 17.0.1 => 17.0.1 (17.1.3, 17.2.8) prettier: ^2.6.2 => 2.8.8 prisma: ^5.5.2 => 5.6.0 prisma-erd-generator: ^1.11.1 => 1.11.1 react: 18.2.0 => 18.2.0 react-data-table-component: ^7.6.2 => 7.6.2 react-dom: 18.2.0 => 18.2.0 react-is: 18.2.0 => 18.2.0 (17.0.2, 16.13.1) react-markdown: ^9.0.1 => 9.0.1 react-native: 0.72.6 => 0.72.6 react-native-ble-plx: ^3.1.2 => 3.1.2 react-native-dropdown-picker: ^5.4.6 => 5.4.6 react-native-flash-message: ^0.4.2 => 0.4.2 react-native-gesture-handler: ^2.14.0 => 2.14.0 react-native-get-random-values: ^1.10.0 => 1.10.0 react-native-gifted-chat: ^2.4.0 => 2.4.0 react-native-health: ^1.18.0 => 1.18.0 react-native-image-picker: ^7.1.2 => 7.1.2 react-native-inappbrowser-reborn: ^3.7.0 => 3.7.0 react-native-markdown-display: ^7.0.2 => 7.0.2 react-native-modalize: ^2.1.1 => 2.1.1 react-native-paper: ^5.12.3 => 5.12.3 react-native-popup-menu: ^0.16.1 => 0.16.1 react-native-reanimated: ^3.5.4 => 3.5.4 react-native-safe-area-context: ^4.7.4 => 4.7.4 react-native-screens: ^3.27.0 => 3.27.0 react-native-svg: ^13.14.1 => 13.14.1 react-native-svg-transformer: 1.0.0 => 1.0.0 react-native-switch: ^1.5.1 => 1.5.1 react-native-url-polyfill: ^2.0.0 => 2.0.0 (1.3.0) react-native-vector-icons: ^10.0.2 => 10.0.2 react-native-video: ^5.2.1 => 5.2.1 react-native-web: ~0.19.8 => 0.19.9 react-navigation: ^5.0.0 => 5.0.0 react-redux: ^8.1.3 => 8.1.3 react-router-dom: ^6.18.0 => 6.20.0 react-router-native: ^6.19.0 => 6.20.0 react-test-renderer: 18.2.0 => 18.2.0 redux-saga: ^1.2.3 => 1.2.3 redux-saga/effects: undefined () reflect-metadata: ^0.1.13 => 0.1.13 rn-emoji-keyboard: ^1.7.0 => 1.7.0 rxjs: ^7.8.0 => 7.8.1 rxjs/ajax: undefined () rxjs/fetch: undefined () rxjs/operators: undefined () rxjs/testing: undefined () rxjs/webSocket: undefined () styled-components: 5.3.6 => 5.3.6 styled-components/macro: undefined () styled-components/native: undefined () styled-components/primitives: undefined () ts-jest: ^29.1.0 => 29.1.1 ts-node: 10.9.1 => 10.9.1 tslib: ^2.3.0 => 2.6.2 (1.14.1, 2.4.1, 2.4.0) typescript: ~5.1.3 => 5.1.6 (5.2.2) unfetch: ^5.0.0 => 5.0.0 (4.2.0) unfetch-polyfill: undefined () victory-native: ^36.9.2 => 36.9.2 vite: ~4.3.9 => 4.3.9 vitest: ~0.32.0 => 0.32.4 zod: ^3.22.4 => 3.22.4 npmGlobalPackages: @aws-amplify/cli: 12.10.1 @medplum/cli: 3.1.11 aws-cdk: 2.159.1 corepack: 0.10.0 npm: 8.5.0 nx: 19.0.1 yarn: 1.22.22 ```

Describe the bug

i have created a custom CDK to create a step function . initially it had some problems so i did amplify remove custom and re-created the stack with same name . now when i try to push my i can only see 'Update' operation for my custom stack and all other's as No change . but i get the following error


🛑 The following resources failed to deploy:
Resource Name: UserPool (AWS::Cognito::UserPool)
Event Type: update
Reason: Resource handler returned message: "Invalid request provided: Existing schema attributes cannot be modified or deleted." (RequestToken: a4493fb2-9fd1-105d-6991-03b1dc964866, HandlerErrorCode: InvalidRequest)
URL: https://console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stacks/arn%3Aaws%3Acloudformation%3Aap-south-1%3A730335501858%3Astack%2Famplify-elovumomsapp-dev-155951-authMOMsAuth-SPVYAQ5VMGKE%2F5cb1b630-1370-11ef-a8c5-0a61b79874b9/events

🛑 Resource is not in the state stackUpdateComplete
Name: UserPool (AWS::Cognito::UserPool), Event Type: update, Reason: Resource handler returned message: "Invalid request provided: Existing schema attributes cannot be modified or deleted." (RequestToken: a4493fb2-9fd1-105d-6991-03b1dc964866, HandlerErrorCode: InvalidRequest), IsCustomResource: false

what i also observe is in my backend-config.json i see parameters property with all its details being removed.

Expected behavior

should create the custom stack on aws

Reproduction steps

  1. create a new custom cdk stack
  2. pushed it and it failed initially
  3. tried deleting it and pushed
  4. recreated the same custom stack and trying to push it

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "ap-south-1",
    "aws_mobile_analytics_app_id": "XXX",
    "aws_mobile_analytics_app_region": "ap-south-1",
    "Analytics": {
        "AWSPinpoint": {
            "appId": "XXX",
            "region": "ap-south-1"
        }
    },
    "Notifications": {
        "Push": {
            "AWSPinpoint": {
                "appId": "XXX",
                "region": "ap-south-1"
            }
        }
    },
    "aws_cognito_identity_pool_id": "ap-south-1:XXX-a244-438d-ac4e-329e4b410461",
    "aws_cognito_region": "ap-south-1",
    "aws_user_pools_id": "ap-south-XXX",
    "aws_user_pools_web_client_id": "XXX",
    "oauth": {
        "domain": "XXX.auth.ap-south-1.amazoncognito.com",
        "scope": [
            "phone",
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "app://oauth/",
        "redirectSignOut": "app://oauth/sign-out/",
        "responseType": "code"
    },
    "federationTarget": "COGNITO_USER_POOLS",
    "aws_cognito_username_attributes": [
        "EMAIL"
    ],
    "aws_cognito_social_providers": [],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": "8",
        "passwordPolicyCharacters": [
            "REQUIRES_LOWERCASE",
            "REQUIRES_UPPERCASE",
            "REQUIRES_SYMBOLS"
        ]
    },
    "aws_cognito_verification_mechanisms": [
        "EMAIL"
    ]
};

export default awsmobile;

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

ykethan commented 1 month ago

Hey @charith-eLovu, thank you for reaching out. It appears there is an update action on the user pool attribute. As a quick check, does the Auth resource have any override configure? or does the custom resource interact with the Auth resource?

charith-eLovu commented 1 month ago

Hi @ykethan , i did not make any changes on the auth resource , nor does my custom resource utilise the auth resource . it just utilises my functions .

const dependencies: AmplifyDependentResourcesAttributes =
      AmplifyHelpers.addResourceDependency(
        this,
        amplifyResourceProps.category,
        amplifyResourceProps.resourceName,
        [
          {
            category: 'function', // api, auth, storage, function, etc.
            resourceName: 'MyFunction', // find the resource at "amplify/backend/<category>/<resourceName>"
          } /* add more dependencies as needed */,
        ]
      );
ykethan commented 1 month ago

@charith-eLovu interesting. To further dive into this issue, could you run amplify diagnose --send-report and provide us the Project Identifier output from the terminal?

charith-eLovu commented 1 month ago

@ykethan Project Identifier: 98f93e5491855496140f48d44499b6cc

charith-eLovu commented 4 weeks ago

Hi @ykethan , wanted to check if you got a chance to look at this.

ykethan commented 3 weeks ago

Hey @charith-eLovu, tried reproducing the issue similar to the project resources.

  1. amplify add auth with 2 triggers
  2. amplify add analytics
  3. amplify add function, added 2 function with 1 depending on analytics
  4. amplify push
  5. amplify add custom, referenced the 2 created functions and referenced in a sample stepfunction
  6. amplify push but did not observe any error messages on auth attributes being modifies. On the push, do you observe any changes to the requiredAttributes in the cli-inputs.json file? additionally, could you provide us the a minimal reproduction steps on the failure caused on the custom resource. could you also try running amplify update auth, reselecting similar options and running push ?
ykethan commented 3 weeks ago

@charith-eLovu does the auth resource contain any custom attributes? if yes, could you provide us information on how the custom attributes are being added currently.

charith-eLovu commented 3 weeks ago

hi @ykethan , thanks for the quick response . i just tried doing amplify push and did not see any changes on cli-inputs.json but see changes backend-config.json the parameters attribute is fully removed.

also posting a screenshot of the output if that is helpful

Screenshot 2024-10-29 at 9 49 40 PM
ykethan commented 3 weeks ago

@charith-eLovu the error currently suggests this occurring on the Auth attributes/schema changes. does the auth resource contain any custom attributes? if yes, could you provide us information on how the custom attributes are being added currently. could you provide us the a minimal reproduction steps on the failure caused on the custom resource? could you also try running amplify update auth, reselecting similar options and running push?

charith-eLovu commented 3 weeks ago

Hi @ykethan , we found the issue, it was due to an custom attribute that we added . added it now with amplify and everything seems to work fine . Thank you very much for the help that you have provided .

ykethan commented 3 weeks ago

thank you for the confirmation. Closing the issue.

github-actions[bot] commented 3 weeks 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.