Describe the bug
I'm attempting to add the analytics category to an Amplify project. It's a React web app project that already contains Auth, Hosting and Api categories that are already published and functioning. When I add the analytics category and push, the push fails as it's apparently trying to modify the Cognito user pool in an invalid way.
To Reproduce
-Set up Amplify project, add auth. (I believe we modified the Cognito setup manually later to have Username sign in but also allow Email as an alias - see screenshot below.)
-Set up the identity pool to allow unauthenticated access so that website guest analytics can be captured (see screenshot below).
-$ amplify add analytics
Using service: Pinpoint, provided by: awscloudformation
? Provide your pinpoint resource name: MyAnalytics
Adding analytics would add the Auth category to the project if not already added.
? Apps need authorization to send analytics events. Do you want to allow guests and unauthenticated users to send analytics events? (we recommend you allow this when getting started) true
Successfully added auth resource locally.
Successfully added resource MyAnalytics locally
-$ amplify push
-The push fails:
UPDATE_FAILED UserPool AWS::Cognito::UserPool Wed Oct 31 2018 23:41:55 GMT-0700 (Pacific Daylight Time) Updating alias attributes is not allowed.
UPDATE_ROLLBACK_IN_PROGRESS [xxxxx] AWS::CloudFormation::Stack Wed Oct 31 2018 23:41:56 GMT-0700 (Pacific Daylight Time) The following resource(s) failed to update: [UserPool].
Expected behavior
It is expected that the Amplify CLI will not try to modify the attributes for the Cognito user pool in this case.
Desktop (please complete the following information):
Additional context
I found the probable cause of this failure. It appears that, after running the amplify add analytics command, theAliasAttributes: ["email"] line gets removed from the Cloud Formation template for auth. When I add this line back in, the push succeeds. However, it is not obvious why the push error is happening and it took some trial an error to figure out why.
UserPool:
# Created upon user selection
# Depends on SNS Role for Arn if MFA is enabled
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: !Ref userPoolName
Schema:
-
Name: email
Required: true
Mutable: true
AliasAttributes: ["email"] <---- This line gets removed by the Amplify CLI, adding back in solved the issue.
AutoVerifiedAttributes: !Ref autoVerifiedAttributes
Screenshots
The user pool setup:

The identity pool setup:

@chrisl777 - Thanks for reaching out. This is related to the updating of the cloudformation template for unauthenticated identities required by analytics. It's definitely a valid issue and I'm getting it into our backlog.
@chrisl777 With the latest version of the CLI (> 1.4.0), we now give you the options to set up your userpool with "email" as an option as well (as a part of the default flow) so that you don't have to manually update your Cloudformation template, that way an update from any other category like analytics won't modify your Cloudformation template. Please feel free to check out this feature and let me know if you think this is still an issue.
I still get this error when adding Analytics with the latest version of the CLI...
edit: "amplify add analytics" modifies also auth. I fixed this by deleting and replacing it by the previous version, as if it wasn't modified
Still getting this error message. Contacted support at Amazon.. and they referred me to this. Yikes. Guess we're on our own. :-)
Got same error as @WillDent amplify add analytics modifies auth category and fails to push
after adding analytics I reverted changes CLI made to Auth category so amplify status shows only Analytics Created status, other resources No Change. Anyway I it's trying to update UserPool
UPDATE_FAILED UserPool AWS::Cognito::UserPool Tue Feb 18 2020 22:48:31 GMT+0300 (Moscow Standard Time) Existing schema attributes cannot be modified or deleted. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: null)
Has anyone able to solve this?
@kaustavghosh06 Is this known by the team and will there be worked on?
I have the same issue. Have Auth up and running in my project and now want to add analytics, but I receive this error:
AWS::Cognito::UserPool Wed Oct 14 2020 16:16:33 GMT+0200 (Central European Summer Time) Existing schema attributes cannot be modified or deleted. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: null; Proxy: null)
UPDATE_IN_PROGRESS UserPool