Closed sky4git closed 3 years ago
Facing the same issue here.
I'm not getting this anymore it seems that I needed to configure the IdentityPool with an UnauthRole and it works now.
I was getting this issue too. Amplify Analytics had previously been working but has suddenly stopped. The identity pool has authenticated and unauthenticated roles with analytics permissions.
I had originally been using these deps, but after upgrading, it appears to be working again:
diff --git a/package.json b/package.json
index adbc753d..3b296a65 100644
--- a/package.json
+++ b/package.json
@@ -13,15 +13,15 @@
"dependencies": {
- "@aws-amplify/analytics": "^3.2.7",
- "@aws-amplify/api": "^3.2.16",
- "@aws-amplify/auth": "^3.4.16",
- "@aws-amplify/core": "^3.8.8",
- "@aws-amplify/storage": "^3.3.16",
- "@aws-sdk/client-s3": "3.0.0",
- "@aws-sdk/s3-request-presigner": "3.0.0",
- "@aws-sdk/util-create-request": "3.0.0",
- "@aws-sdk/util-format-url": "3.0.0",
+ "@aws-amplify/analytics": "^4.0.16",
+ "@aws-amplify/api": "^3.2.28",
+ "@aws-amplify/auth": "^3.4.28",
+ "@aws-amplify/core": "^3.8.20",
+ "@aws-amplify/storage": "^3.3.28",
+ "@aws-sdk/client-s3": "3.3.0",
+ "@aws-sdk/s3-request-presigner": "3.3.0",
+ "@aws-sdk/util-create-request": "3.6.1",
+ "@aws-sdk/util-format-url": "3.6.1",
Possibly related to #7951 ?
I'm not getting this anymore it seems that I needed to configure the IdentityPool with an UnauthRole and it works now.
Can you show me howz your permissions in iam role look like? Thank you.
Yep you need to upgrade also `"@aws-amplify/analytics": "^4.0.16". These are my roles,
IdentityPool:
Type: AWS::Cognito::IdentityPool
Properties:
IdentityPoolName: !Ref AWS::StackName
AllowUnauthenticatedIdentities: true
CognitoIdentityProviders:
- ProviderName: !Sub cognito-idp.${AWS::Region}.amazonaws.com/${UserPool}
ClientId: !Ref UserPoolClient
ServerSideTokenCheck: true
AuthenticatedRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Deny
Principal:
Service:
- cognito-identity.amazonaws.com
Action:
- sts:AssumeRoleWithWebIdentity
Policies:
- PolicyName: !Sub ${AWS::StackName}-authenticated-role
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- mobiletargeting:PutItems
- mobiletargeting:UpdateEndpoint
- mobiletargeting:PutEvents
Resource: !Sub
- arn:aws:mobiletargeting:*:${AWS::AccountId}:apps/${ApplicationId}*
- ApplicationId: !Ref PinPointApp
- Effect: Allow
Action:
- mobileanalytics:*
- cognito-sync:*
- cognito-identity:*
Resource: '*'
UnauthenticatedRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Deny
Principal:
Service:
- cognito-identity.amazonaws.com
Action:
- sts:AssumeRoleWithWebIdentity
Policies:
- PolicyName: !Sub ${AWS::StackName}-authenticated-role
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- mobiletargeting:PutItems
- mobiletargeting:UpdateEndpoint
- mobiletargeting:PutEvents
Resource: !Sub
- arn:aws:mobiletargeting:*:${AWS::AccountId}:apps/${ApplicationId}*
- ApplicationId: !Ref PinPointApp
- Effect: Allow
Action:
- mobileanalytics:*
- cognito-sync:*
- cognito-identity:*
Resource: '*'
IdentityPoolAuthRole:
Type: AWS::Cognito::IdentityPoolRoleAttachment
Properties:
IdentityPoolId: !Ref IdentityPool
Roles:
authenticated: !GetAtt AuthenticatedRole.Arn
unauthenticated: !GetAtt UnAuthenticatedRole.Arn
@pyros2097 I have almost same permissions, except sts:AssumeRoleWithWebIdentity is allowed.
However, in my case, I think its the issue is on front-end library. Especially with AWSPinpointProvider.js. I have never changed the permissions on unauth or auth role, but the error started appearing after npm update.
I have tried reverting the changes but then the error didnt went away which is really problematic.
In my case, in package.json, I had both included @aws-amplify/ui-react: ^0.2.34 aws-amplify: ^3.3.14
However, it is not required. I removed @aws-amplify/ui-react from package.json and ran npm update.
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 or Discussions for those types of questions.
Before opening, please confirm:
Is this a production issue?
JavaScript Framework
React
Amplify APIs
Authentication, Analytics, REST API, GraphQL API
Amplify Categories
auth, function, api, analytics
Environment information
Describe the bug
Suddenly started appearing in dev environment and subsequently in production environment.
Expected behavior
Not sure why this error is coming in first place. I am using Analytics Pinpoint and recording various event through out the app. The bug description doesn't help to understand where and what is going wrong.
Reproduction steps
Its happening on home and all pages of my app. so just visit localhost:3000 to see the error.
Code Snippet
Log output
aws-exports.js
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