amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

amplify push after amplify add analytics gives errors

Open apanagos opened this issue 7 years ago • 12 comments

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug I am trying to add Analytics to my build but I get errors when I push.

To Reproduce Steps to reproduce the behavior:

  1. amplify add analytics
  2. amplify push

Expected behavior Analytics is added to the application after push is completed.

Screenshots

amplify add analytics
Using service: Pinpoint, provided by: awscloudformation
? Provide your pinpoint resource name: TrueEdgeMetrics
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 a
llow this when getting started) No
Authorize only authenticated users to send analytics events. Use "amplify update auth" to modify this behavior.
Successfully updated auth resource locally.
Successfully added resource TrueEdgeMetrics locally
amplify push

Current Environment: dev

| Category  | Resource name     | Operation | Provider plugin   |
| --------- | ----------------- | --------- | ----------------- |
| Analytics | TrueEdgeMetrics   | Create    | awscloudformation |
| Auth      | trueedge97d2517a  | Update    | awscloudformation |
| Api       | userManagerLambda | Update    | awscloudformation |
| Function  | userManagerLambda | Update    | awscloudformation |
| Api       | trueEdgeData      | No Change | awscloudformation |
| Storage   | edges3resource    | No Change | awscloudformation |
? Are you sure you want to continue? Yes
| Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS storageedges3resource    AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:08 GMT-0500 (Central Daylight Time)
CREATE_IN_PROGRESS analyticsTrueEdgeMetrics AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:09 GMT-0500 (Central Daylight Time)
UPDATE_COMPLETE    storageedges3resource    AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:09 GMT-0500 (Central Daylight Time)
UPDATE_IN_PROGRESS authtrueedge97d2517a     AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:09 GMT-0500 (Central Daylight Time)
- Updating resources in the cloud. This may take a few minutes...

UPDATE_FAILED               authtrueedge97d2517a         AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:09 GMT-0500 (Central Daylight Time) Parameters: [userpoolClientLogPolicy, openIdRolePolicy, openIdLogPolicy, mfaLambdaLogPolicy, openIdLambdaRoleName, policyName, userpoolClientName, userpoolClientLambdaPolicy, mfaLambdaIAMPolicy, mfaPassRolePolicy, roleName, lambdaLogPolicy, mfaLambdaRole] must have values
CREATE_IN_PROGRESS          analyticsTrueEdgeMetrics     AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:09 GMT-0500 (Central Daylight Time) Resource creation Initiated                                                                                                                                     
CREATE_FAILED               analyticsTrueEdgeMetrics     AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:10 GMT-0500 (Central Daylight Time) Resource creation cancelled                                                                                                                                     
UPDATE_ROLLBACK_IN_PROGRESS true-edge-dev-20190908230237 AWS::CloudFormation::Stack Mon Sep 16 2019 11:24:11 GMT-0500 (Central Daylight Time) The following resource(s) failed to create: [analyticsTrueEdgeMetrics]. The following resource(s) failed to update: [authtrueedge97d2517a]. 

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: amplify -version = 3.0.0

Additional context I noticed that the error above is about a bunch of parameters not having values. I see that these are remove from amplify/backend/auth/trueedge97d2517a/parameters.json after I do "amplify add analytics" parameters-json

apanagos avatar Sep 16 '19 16:09 apanagos

@apanagos did you run amplify auth update by any chance? All those parameters looks like Cognito specific parameters and I'm wondering what CLI operations could have remove those...

If you could provider repro steps that would help.

attilah avatar Sep 17 '19 17:09 attilah

I wish it was more complicated than that but that was the steps. amplify add analytics (I see the details above with those properties removed) amplify push and it fails with the issue above.

I have done this same steps now several times. The last time I deleted everything and checked out code and started from amplify init.

I upgrade to 3.2.0 (I was on 3.0.0) and that introduced its own issues and spent 6 hours last night and this morning trying to figure out why I couldn't push. Seems there is a bug in 3.2.0 that is being worked on. Though they provided a work around for that issue (do amplify update api first before doing the amplify push).

Its not related to this issue but I may try again to see.

I tried to work around this and try to manually create the Pinpoint project and use code to connect but no matter what I do with IAM permissions it fails on a record

import Amplify from "aws-amplify";
const analyticsConfig = {
  autoSessionRecord: true,
  AWSPinpoint: {
        // Amazon Pinpoint App Client ID
        appId: 'xxxxxxxxxxxxxxxxxxxx4e1b',
        // Amazon service region
        region: 'us-east-1',
        mandatorySignIn: false,
  }
};

Analytics.configure(analyticsConfig); but it gives a permissions error even though I have the following on each IAM role generated

    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:PutEvents",
                "mobileanalytics:PutEvents",
                "mobiletargeting:UpdateEndpoint"
            ],
            "Resource": "*"
        }
    ]
}

So I am stuck.

Can't do it through amplify add analytics and cant do it manually.

Any other suggestions I am open. BUT I will try again again now and see if the current changes do anything.

apanagos avatar Sep 17 '19 22:09 apanagos

I have the exact same behaviour.

D:\projects\git\true-edge>**amplify --version**
3.2.0

D:\projects\git\true-edge>**amplify status**

Current Environment: devandrew

| Category | Resource name     | Operation | Provider plugin   |
| -------- | ----------------- | --------- | ----------------- |
| Auth     | trueedge97d2517a  | No Change | awscloudformation |
| Api      | trueEdgeData      | No Change | awscloudformation |
| Api      | userManagerLambda | No Change | awscloudformation |
| Function | userManagerLambda | No Change | awscloudformation |
| Storage  | edges3resource    | No Change | awscloudformation |

GraphQL endpoint: https://xxxxxxxxxxxxxxxx.appsync-api.us-east-1.amazonaws.com/graphql


D:\projects\git\true-edge>**amplify add analytics**
Using service: Pinpoint, provided by: awscloudformation
? Provide your pinpoint resource name: TrueEdgeTraining
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 a
llow this when getting started) Yes
Successfully updated auth resource locally.
Successfully added resource TrueEdgeTraining locally

Some next steps:
"amplify push" builds all of your local backend resources and provisions them in the cloud
"amplify publish" builds all your local backend and front-end resources (if you have hosting category added) and provisions them in the cloud

At this point a whole bunch of stuff has been removed from parameters.json in the auth directory as seen in the screen shot above previously.

I get back to a working system I do amplify remove analytics Which unfortunately does not fix the files. I just have to restore from git to get back to a working system.

apanagos avatar Sep 17 '19 23:09 apanagos

@apanagos could you please tell us what version of the CLI you were initially using to create the project? Or in the last comment you started with 3.2.0 and did not use an existing project?

attilah avatar Sep 19 '19 17:09 attilah

I had used 3.0.0 initially when I saw the problem then upgraded to 3.2.0

apanagos avatar Sep 19 '19 21:09 apanagos

Hi - I'm using v 3.11.0 and seeing the same behavior. After running amplify add analytics the same keys from @apanagos screenshot are removed from my parameters.json file and the push fails with the same error message. I can confirm that I had no other pending changes to the auth service or any other service. The only thing I did was add analytics.

kmagilavy avatar Oct 03 '19 02:10 kmagilavy

Marking this pending-release as PR #2587 fixes this issue by removing the unnecessary params from the template as well

SwaySway avatar Oct 18 '19 00:10 SwaySway

I'm having an error to add analytics on my project also:

  • I ran "amplify add analytics" ane then...

after run "amplify push" command:

Following resources failed UPDATE_FAILED UserPool AWS::Cognito::UserPool Thu Oct 31 2019 18:38:33 GMT-0300 (Brasilia Standard Time) Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: edbef4b1-f997-4fa5-be99-848f15360061)

Resource Name: us-east-1_wo6PE2Dmb (AWS::Cognito::UserPool) Event Type: update Reason: Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException; Request ID: edbef4b1-f997-4fa5-be99-848f15360061)

wellmmer avatar Oct 31 '19 21:10 wellmmer

If anyone gets to a stuck environment after trying to add analytics, I found via another issue you can back out to what the current environment has by running amplify env pull --restore

Also having this issue, same type of output as @wellmmer

dbhagen avatar Nov 01 '19 03:11 dbhagen

When will this be released?

apanagos avatar Nov 08 '19 23:11 apanagos

Closing as the fix was included the 3.16 release and onward. Should you run into this issue again please comment below.

SwaySway avatar Dec 12 '19 23:12 SwaySway

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 26 '21 20:05 github-actions[bot]