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 821 forks source link

Ampilfy push or build gives me "Invalid AttributeDataType input" error after adding analytics to existing project auth that was building fine #9525

Open Shomari opened 2 years ago

Shomari commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

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

14.17.3

Amplify CLI Version

7.6.5

What operating system are you using?

mac

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

No manual changes made

Amplify Categories

auth, analytics

Amplify Commands

push

Describe the bug

I can't push changes from amplify cli or deploy code. I am always getting error " Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException"

Expected behavior

I should be able to make changes and have my builds complete

Reproduction steps

Added analytics to an already existing project that had auth and api I believe this made some changes to my user pool but not exactly sure what it did. Now I can't build or push new changes

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line `This will overwrite your current graphql queries, mutations and subscriptions Yes ⠙ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS amplify-recommendednext-dev-135335 AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:43 GMT-0600 (Central Standard Time) User Initiated ⠏ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS analyticsrecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:49 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS apirecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:50 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS authrecommended AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:50 GMT-0600 (Central Standard Time) UPDATE_COMPLETE analyticsrecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:51 GMT-0600 (Central Standard Time) ⠦ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS amplify-recommendednext-dev-135335-authrecommended-1WZ8ZJT8ZUTMB AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:51 GMT-0600 (Central Standard Time) User Initiated ⠧ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS amplify-recommendednext-dev-135335-apirecommendednext-IV5UBMFSEAPP AWS::CloudFormation::Stack Thu Jan 13 2022 12:52:50 GMT-0600 (Central Standard Time) User Initiated ⠴ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS hu Jan 13 2022 12:52:58 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS GraphQLAPITransformerSchema3CB2AE18 AWS::AppSync::GraphQLSchema Thu Jan 13 2022 12:52:58 GMT-0600 (Central Standard Time) ⠏ Updating resources in the cloud. This may take a few minutes... UPDATE_COMPLETE Thu Jan 13 2022 12:53:00 GMT-0600 (Central Standard Time) ⠸ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS UserPool AWS::Cognito::UserPool Thu Jan 13 2022 12:53:03 GMT-0600 (Central Standard Time) ⠏ Updating resources in the cloud. This may take a few minutes... UPDATE_FAILED UserPool AWS::Cognito::UserPool Thu Jan 13 2022 12:53:07 GMT-0600 (Central Standard Time) Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: da231749-bcfb-4c6f-9aaa-80f13849794e; Proxy: null) UPDATE_ROLLBACK_IN_PROGRESS amplify-recommendednext-dev-135335-authrecommended-1WZ8ZJT8ZUTMB AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:08 GMT-0600 (Central Standard Time) The following resource(s) failed to update: [UserPool]. ⠋ Updating resources in the cloud. This may take a few minutes... UPDATE_FAILED authrecommended AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:13 GMT-0600 (Central Standard Time) Embedded stack arn:aws:cloudformation:us-east-1:606803379457:stack/amplify-recommendednext-dev-135335-authrecommended-1WZ8ZJT8ZUTMB/e88b2a20-724f-11ec-a572-0a85688e4491 was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to update: [UserPool]. ⠦ Updating resources in the cloud. This may take a few minutes... UPDATE_ROLLBACK_IN_PROGRESS amplify-recommendednext-dev-135335-apirecommendednext-IV5UBMFSEAPP AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:14 GMT-0600 (Central Standard Time) Initiated by parent stack UPDATE_FAILED GraphQLAPITransformerSchema3CB2AE18 AWS::AppSync::GraphQLSchema Thu Jan 13 2022 12:53:14 GMT-0600 (Central Standard Time) Resource update cancelled ⠹ Updating resources in the cloud. This may take a few minutes... UPDATE_FAILED apirecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:25 GMT-0600 (Central Standard Time) Resource update cancelled ⠙ Updating resources in the cloud. This may take a few minutes... UPDATE_ROLLBACK_IN_PROGRESS amplify-recommendednext-dev-135335 AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:26 GMT-0600 (Central Standard Time) The following resource(s) failed to update: [apirecommendednext, authrecommended]. ⠇ Updating resources in the cloud. This may take a few minutes... UPDATE_IN_PROGRESS apirecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:47 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS analyticsrecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:47 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS authrecommended AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:48 GMT-0600 (Central Standard Time) UPDATE_COMPLETE analyticsrecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:53:48 GMT-0600 (Central Standard Time) ⠼ Updating resources in the cloud. This may take a few minutes... UPDATE_COMPLETE UserPool AWS::Cognito::UserPool Thu Jan 13 2022 12:54:18 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS GraphQLAPITransformerSchema3CB2AE18 AWS::AppSync::GraphQLSchema Thu Jan 13 2022 12:54:17 GMT-0600 (Central Standard Time) UPDATE_IN_PROGRESS GraphQLAPIDefaultApiKey215A6DD7 AWS::AppSync::ApiKey Thu Jan 13 2022 12:54:17 GMT-0600 (Central Standard Time) UPDATE_COMPLETE GraphQLAPIDefaultApiKey215A6DD7 AWS::AppSync::ApiKey Thu Jan 13 2022 12:54:19 GMT-0600 (Central Standard Time) ⠇ Updating resources in the cloud. This may take a few minutes... UPDATE_COMPLETE apirecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:22 GMT-0600 (Central Standard Time) ⠸ Updating resources in the cloud. This may take a few minutes... UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS amplify-recommendednext-dev-135335-authrecommended-1WZ8ZJT8ZUTMB AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:29 GMT-0600 (Central Standard Time) ⠧ Updating resources in the cloud. This may take a few minutes... UPDATE_COMPLETE authrecommended AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:35 GMT-0600 (Central Standard Time) UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS amplify-recommendednext-dev-135335 AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:38 GMT-0600 (Central Standard Time) ⠧ Updating resources in the cloud. This may take a few minutes... UPDATE_COMPLETE analyticsrecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:40 GMT-0600 (Central Standard Time) ⠙ Updating resources in the cloud. This may take a few minutes... UPDATE_COMPLETE authrecommended AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:50 GMT-0600 (Central Standard Time) UPDATE_COMPLETE apirecommendednext AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:50 GMT-0600 (Central Standard Time) UPDATE_ROLLBACK_COMPLETE amplify-recommendednext-dev-135335 AWS::CloudFormation::Stack Thu Jan 13 2022 12:54:50 GMT-0600 (Central Standard Time) ⠦ Updating resources in the cloud. This may take a few minutes... Following resources failed Resource Name: us-east-1_90zp5zw6q (AWS::Cognito::UserPool) Event Type: update Reason: Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: da231749-bcfb-4c6f-9aaa-80f13849794e; Proxy: null) URL: https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/arn%3Aaws%3Acloudformation%3Aus-east-1%3A606803379457%3Astack%2Famplify-recommendednext-dev-135335-authrecommended-1WZ8ZJT8ZUTMB%2Fe88b2a20-724f-11ec-a572-0a85688e4491/events Resource Name: xedizi2s55fctk4dhw2ufv7rwmGraphQLSchema (AWS::AppSync::GraphQLSchema) Event Type: update Reason: Resource update cancelled URL: https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/arn%3Aaws%3Acloudformation%3Aus-east-1%3A606803379457%3Astack%2Famplify-recommendednext-dev-135335-apirecommendednext-IV5UBMFSEAPP%2F3b188f00-7253-11ec-8e7c-0a492b04931b/events ```

Additional information

exact same issue as https://github.com/aws-amplify/amplify-cli/issues/2309 but it appears this has come back. Also seems like some else is having the same issue but they closed their issue https://github.com/aws-amplify/amplify-cli/issues/9510

InnovateWithEric commented 2 years ago

Initial fix addressed part of this. Additional documentation to describe high level approach for migration of user pool.

gorjant commented 1 year ago

I have updated the cli to the newest version, but I still get the error. I have sent a diagnostic report. Project ID: 5c8c983e49b7f9ef7d272af952c0ad21

cunneen commented 1 year ago

What's the latest on this? We've hit this issue.

Similar to @Shomari, @dbeck121 , and @djsjr, our deployed user pool, cli-inputs.json, and the #current-cloud-backend cloudformation JSON are all in sync as far as the requiredAttributes go (and other user pool config as far as I can tell).

As with @Shomari , it only manifested when we did amplify add analytics.

The issue occurs in amplify CLI 10.3.1 (downgrading to 7.6.8 gives us the same error).

amplify diagnose --send-report gives: Project Identifier: 85116e8e08029dc0bc4466b8b6573fec .

Below are our cli-inputs.json and root-cloudformation-stack.json.

(aside: This in our CloudFormation Template looks very suspect but I think it's unrelated: "dependsOn": "[object Object],[object Object],[object Object]",)

My amplify/backend/auth/bpedsysauth/cli-inputs.json :

```json { "version": "1", "cognitoConfig": { "identityPoolName": "bpedsys_identitypool", "allowUnauthenticatedIdentities": false, "resourceNameTruncated": "bpedsy2e2f5307", "userPoolName": "bpedsys_userpool", "autoVerifiedAttributes": [ "email" ], "mfaConfiguration": "OPTIONAL", "mfaTypes": [ "TOTP" ], "smsAuthenticationMessage": "Your authentication code is {####}", "smsVerificationMessage": "Your verification code is {####}", "emailVerificationSubject": "Your verification code", "emailVerificationMessage": "Your verification code is {####}", "defaultPasswordPolicy": false, "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [ "Requires Lowercase", "Requires Uppercase", "Requires Numbers" ], "requiredAttributes": [ "name", "email" ], "aliasAttributes": [], "userpoolClientGenerateSecret": true, "userpoolClientRefreshTokenValidity": 30, "userpoolClientWriteAttributes": [ "phone_number", "email", "name" ], "userpoolClientReadAttributes": [ "email", "phone_number", "email_verified", "phone_number_verified" ], "userpoolClientLambdaRole": "bpedsy2e2f5307_userpoolclient_lambda_role", "userpoolClientSetAttributes": false, "authSelections": "identityPoolAndUserPool", "resourceName": "bpedsysauth", "useDefault": "manual", "userPoolGroupList": [ "Admins", "Users" ], "userPoolGroups": false, "usernameAttributes": [ "email" ], "verificationBucketName": "bpedsysauthverificationbucket", "adminQueries": true, "adminQueryGroup": "Admins", "hostedUI": false, "thirdPartyAuth": false, "triggers": { "CustomMessage": [ "verification-link" ], "PostConfirmation": [ "add-to-group" ], "PreTokenGeneration": [ "alter-claims" ] }, "authRoleArn": { "Fn::GetAtt": [ "AuthRole", "Arn" ] }, "unauthRoleArn": { "Fn::GetAtt": [ "UnauthRole", "Arn" ] }, "breakCircularDependency": false, "useEnabledMfas": false, "dependsOn": [ { "category": "function", "resourceName": "bpedsysauthCustomMessage", "triggerProvider": "Cognito", "attributes": [ "Arn", "Name" ] }, { "category": "function", "resourceName": "bpedsysauthPostConfirmation", "triggerProvider": "Cognito", "attributes": [ "Arn", "Name" ] }, { "category": "function", "resourceName": "bpedsysauthPreTokenGeneration", "triggerProvider": "Cognito", "attributes": [ "Arn", "Name" ] } ], "permissions": [ "{\"policyName\":\"AddToGroupCognito\",\"trigger\":\"PostConfirmation\",\"effect\":\"Allow\",\"actions\":[\"cognito-idp:AdminAddUserToGroup\",\"cognito-idp:GetGroup\",\"cognito-idp:CreateGroup\"],\"resource\":{\"paramType\":\"!GetAtt\",\"keys\":[\"UserPool\",\"Arn\"]}}" ], "authTriggerConnections": [ "{\"triggerType\":\"CustomMessage\",\"lambdaFunctionName\":\"bpedsysauthCustomMessage\"}", "{\"triggerType\":\"PostConfirmation\",\"lambdaFunctionName\":\"bpedsysauthPostConfirmation\"}", "{\"triggerType\":\"PreTokenGeneration\",\"lambdaFunctionName\":\"bpedsysauthPreTokenGeneration\"}" ], "serviceName": "Cognito", "authProviders": [], "parentStack": { "Ref": "AWS::StackId" } } } ```

The relevant part of my amplify/#current-cloud-backend/awscloudformation/build/root-cloudformation-stack.json :

```json "authbpedsysauth": { "Type": "AWS::CloudFormation::Stack", "Properties": { "TemplateURL": "https://s3.amazonaws.com/amplify-bpedsys-develop-174413-deployment/amplify-cfn-templates/auth/bpedsysauth-cloudformation-template.json", "Parameters": { "identityPoolName": "bpedsys_identitypool", "allowUnauthenticatedIdentities": false, "resourceNameTruncated": "bpedsy2e2f5307", "userPoolName": "bpedsys_userpool", "autoVerifiedAttributes": "email", "mfaConfiguration": "OPTIONAL", "mfaTypes": "TOTP", "smsAuthenticationMessage": "Your authentication code is {####}", "smsVerificationMessage": "Your verification code is {####}", "emailVerificationSubject": "Your verification code", "emailVerificationMessage": "Your verification code is {####}", "defaultPasswordPolicy": false, "passwordPolicyMinLength": 8, "passwordPolicyCharacters": "Requires Lowercase,Requires Uppercase,Requires Numbers", "requiredAttributes": "name,email", "aliasAttributes": "", "userpoolClientGenerateSecret": true, "userpoolClientRefreshTokenValidity": 30, "userpoolClientWriteAttributes": "phone_number,email,name", "userpoolClientReadAttributes": "email,phone_number,email_verified,phone_number_verified", "userpoolClientLambdaRole": "bpedsy2e2f5307_userpoolclient_lambda_role", "userpoolClientSetAttributes": false, "authSelections": "identityPoolAndUserPool", "resourceName": "bpedsysauth", "useDefault": "manual", "userPoolGroupList": "Admins,Users", "userPoolGroups": false, "usernameAttributes": "email", "verificationBucketName": "bpedsysauthverificationbucket", "adminQueries": true, "adminQueryGroup": "Admins", "hostedUI": false, "thirdPartyAuth": false, "triggers": "{\"CustomMessage\":[\"verification-link\"],\"PostConfirmation\":[\"add-to-group\"],\"PreTokenGeneration\":[\"alter-claims\"]}", "authRoleArn": { "Fn::GetAtt": [ "AuthRole", "Arn" ] }, "unauthRoleArn": { "Fn::GetAtt": [ "UnauthRole", "Arn" ] }, "breakCircularDependency": false, "useEnabledMfas": false, "dependsOn": "[object Object],[object Object],[object Object]", "permissions": "{\"policyName\":\"AddToGroupCognito\",\"trigger\":\"PostConfirmation\",\"effect\":\"Allow\",\"actions\":[\"cognito-idp:AdminAddUserToGroup\",\"cognito-idp:GetGroup\",\"cognito-idp:CreateGroup\"],\"resource\":{\"paramType\":\"!GetAtt\",\"keys\":[\"UserPool\",\"Arn\"]}}", "authTriggerConnections": "{\"triggerType\":\"CustomMessage\",\"lambdaFunctionName\":\"bpedsysauthCustomMessage\"},{\"triggerType\":\"PostConfirmation\",\"lambdaFunctionName\":\"bpedsysauthPostConfirmation\"},{\"triggerType\":\"PreTokenGeneration\",\"lambdaFunctionName\":\"bpedsysauthPreTokenGeneration\"}", "serviceName": "Cognito", "authProviders": "", "parentStack": { "Ref": "AWS::StackId" }, "functionbpedsysauthCustomMessageArn": { "Fn::GetAtt": [ "functionbpedsysauthCustomMessage", "Outputs.Arn" ] }, "functionbpedsysauthCustomMessageName": { "Fn::GetAtt": [ "functionbpedsysauthCustomMessage", "Outputs.Name" ] }, "functionbpedsysauthPostConfirmationArn": { "Fn::GetAtt": [ "functionbpedsysauthPostConfirmation", "Outputs.Arn" ] }, "functionbpedsysauthPostConfirmationName": { "Fn::GetAtt": [ "functionbpedsysauthPostConfirmation", "Outputs.Name" ] }, "functionbpedsysauthPreTokenGenerationArn": { "Fn::GetAtt": [ "functionbpedsysauthPreTokenGeneration", "Outputs.Arn" ] }, "functionbpedsysauthPreTokenGenerationName": { "Fn::GetAtt": [ "functionbpedsysauthPreTokenGeneration", "Outputs.Name" ] }, "env": "develop" } } }, ```
cunneen commented 1 year ago

OK this still happens if I do nothing else other than change the order of requiredAttributes in cli-inputs.json from:

    "requiredAttributes": ["name", "email"]

to:

    "requiredAttributes": ["email", "name"]
owboateng commented 1 year ago

I have the same problem after upgrading the Amplify cli from 9.2.1 to 10.4.0. Please help. Project Identifier: 8917f531808b98396e5b186f78b710ba

cunneen commented 1 year ago

I am also still getting it on 10.4.0. It seems not much is happening on this issue.

owboateng commented 1 year ago

Hi team @josefaidt @Straubulous any updates on this issue, my team is blocked for almost two weeks now with this error. I have sent my project my project identification number: 8917f531808b98396e5b186f78b710ba. I have read through the whole discussions and none of the suggestions worked. Thanks

cunneen commented 1 year ago

Not currently feeling the "Customer Obsession" here.

maupeon commented 1 year ago

I have talked for more than 10 engineers at aws support team and they haven't solved this issue, paying for more than 400 USD.

AWS support does not work.

akshbhu commented 1 year ago

Hi @cuneen @gorjant

I check your project Identifier.
Lets say your current required attributes are : [ 'email' , 'name'].

when upgraded to v7.3 to v7.6.9 due to a bug this required attributes in cfn changes to [ 'name'] which is a successful deployment.

After upgrading to version > v7.6.9 , amplify changes your required attributes back to normal which was previous : ['email' , 'name']. This deployment will result in same error Invalid AttributeDataType input, consider using the provided AttributeDataType enum.

Can you try to push by changing your cli-inputs.json and parameters.json to specific requited attribute which is [ 'name'] ?

As an example: Current cli-inputs.json requited attributes: [ 'email' ,'name']

Change to cli-inputs.json requited attributes: [ ''name'] ;

Change parameters.json requited attributes: [ ''name'] ;

amplify push ( this should change schema section is user pool to only name attribute)

Let me know if these steps works for you ?

@owboateng

Your problem seems different by looking at project. Can you try removing userNameCaseSensitive field from cli-inputs.json and try to push again ?

Let me know if this works for you ?

cunneen commented 1 year ago

Hi @akshbhu thanks for looking into this; We can't push right now as AWS Premium Support engineers are looking into this for us, but we did previously try what you described (based on @johnpc's comments above) and we still encountered the error.

akshbhu commented 1 year ago

Can you tell me which comment is this ?

I reproduced the issue with creating an amplify project with v4.5.x and upgrading to v7.3.0 ( which has the bug in required attributes) (up till here push works fine )and after than upgrading to v10.5.1. I received similar error as above, which got resolved based on my comment above

cunneen commented 1 year ago

Hi @akshbhu I don't think the message you're quoting was in this thread?

Can you tell me which comment is this ?

I reproduced the issue with creating an amplify project with v4.5.x and upgrading to v7.3.0 ( which has the bug in required attributes) (up till here push works fine )and after than upgrading to v10.5.1. I received similar error as above, which got resolved based on my comment above

akshbhu commented 1 year ago

Hi @cunneen

Apologies for being unclear.

When you mentioned :but we did previously try what you described (based on @johnpc's comments above) and we still encountered the error.

I was trying to confirm which comment was it in this thread.

Also this is my investigation on this issue : I reproduced the issue with creating an amplify project with v4.5.x and upgrading to v7.3.0 ( which has the bug in required attributes) (up till here push works fine )and after than upgrading to v10.5.1. I received similar error as above, which got resolved based on my comment above

cunneen commented 1 year ago

Hi @akshbhu , sorry for misunderstanding earlier. AWS support resolved this for us; it looks like their resolution was similar to what you suggested as our cli-inputs.json file now only has ["name"] .

We're no longer encountering this issue; we're on v10.8.1 .

Bandisa commented 1 year ago

I used @julienlaurent-migso solution and it worked. went to the cli-inputs.json and inserted a newline then amplify push, which deployed properly.