Closed idanlo closed 4 years ago
Here's what i'm getting with DEBUG enabled
[DEBUG] 28:28.820 Credentials - setting credentials for guest
[DEBUG] 28:29.85 Credentials - Failed to load credentials CognitoIdentityCredentials {expired: true, expireTime: null, refreshCallbacks: Array(0), accessKeyId: undefined, sessionToken: undefined, …}
[DEBUG] 28:29.87 AWSS3Provider - set credentials for storage {accessKeyId: undefined, sessionToken: undefined, secretAccessKey: undefined, identityId: undefined, authenticated: undefined}
I was able to get rid of the issue (temporarily) by setting the credentials. But again, that's not a solution!
import { AWS } from '@aws-amplify/core';
AWS.config.update({
credentials: new AWS.Credentials ({
accessKeyId: "XXXXXX",
secretAccessKey: "XXXXX"
}),
});
@idanlo, I am curious how you came up with that config composition?
const config = {
...aws_config,
graphql_headers: async () => {
try {
const token = (await Auth.currentSession()).getIdToken().getJwtToken();
return { Authorization: token };
} catch (e) {
console.error(e);
return {};
}
}
};
A few additional questions:
Storage.put
?Amplify.configure
?package.json
file?amplify push
from the Amplify CLI inside of your project?aws-exports
file?@jordanranz thanks for responding.
yes, the Amplify.configure
is called with this configuration when the app starts, which is before the call to Storage.put
.
I have set up the storage with the amplify cli according to the docs and I have pushed those changes.
I don't understand why you need my package.json
file, it has nothing special, my aws-amplify
version is 1.1.32
in the aws-exports
file I have these keys -
aws_project_region,
aws_cognito_identity_pool_id,
aws_cognito_region,
aws_user_pools_id,
aws_user_pools_web_client_id,
oauth,
aws_appsync_graphqlEndpoint,
aws_appsync_region,
aws_appsync_authenticationType,
aws_user_files_s3_bucket,
aws_user_files_s3_bucket_region
edit: I wanted to go this way
Amplify.configure({
Auth: {},
API: {}
})
but it is not typed with typescript so I had no idea what the property names are and it is not documented (at least I didn't find it) so I imported the settings from aws-exports
I managed to get it to work.
[DEBUG] 14:19.538 Credentials - Failed to load credentials CognitoIdentityCredentials {expired: true, expireTime: null, refreshCallbacks: Array(0), accessKeyId: undefined, sessionToken: undefined, …}
[DEBUG] 14:19.539 AuthClass - getting session failed InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool.
It turned out that the Trust Relationships were misconfigured for the role.
@faxad how did you configure the Trust Relationships? also how do you enable debug mode?
@idanlo you can window.LOG_LEVEL='DEBUG';
for the logging.
Trust Relationships depends on your use case and what you are trying to achieve.
Mine looks something like this.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "us-west-2:xxxxx"
}
}
}
]
}
@faxad that code, in what file is it? I enabled debug mode but I don't have errors like you did, my Auth and Credentials modules works fine
@idanlo add it before you configure Amplify.
@faxad the debug mode works. I just don't get the errors you get, my Auth and Credential modules are fine and working. I have similar code in my Trust Relationships configuration but the problem persists.
@idanlo did you try to configure the credentials as i mentioned in my first post?
@faxad no because I have no idea where to get those keys and why do I need them at all. It's funny that the types of configuration is not documented at all (at least I didn't find it)
@idanlo You can get that from the IAM user with required permissions to access S3. You are right, you don't need to configure the credentials manually. This is just to test and it helped me to isolate the problem. I say, give it a shot.
@faxad I tried it, the debug mode didn't log any errors, and Storage.put still didn't work with the same errors which I posted in my first comment. My Trust Relationship is auto-generated and I did not touch it so there is nothing wrong with it I assume, the role name is XXX-XXX-XXXXX-authRole and the Trust Relationship is very similar to yours
@idanlo Please share your debug output.
..and the Trust Relationship is very similar to yours
Do you have any other condition besides the check for Identity Pool's ID?
@faxad this is how my trust relationship looks like -
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"ForAnyValue:StringLike": {
"cognito-identity.amazonaws.com:amr": "authenticated"
}
}
}
]
}
@idanlo replace you condition with the following
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "<identity pool id>"
}
}
@faxad but we want only authenticated users to be able to upload files
@idanlo like i said, you need to share the DEBUG logs.
Im facing the same issue as @idanlo and i can't find a fix to move forward
My logs prints:
[DEBUG] 25:43.841 AuthClass - getting current authenticted user
ConsoleLogger.js:80 [DEBUG] 25:43.843 AuthClass - getting current authenticted user
ConsoleLogger.js:80 [DEBUG] 25:43.848 AuthClass - cannot load federated user from auth storage
The error triggered after using Storage.put
was No plugin found in Storage for the provider
when using:
import Amplify from '@aws-amplify/core'
import { amplifyConfig } from './config'
Amplify.configure(amplifyConfig)
But i've tried with other scenario:
import Storage from '@aws-amplify/storage'
import Auth from '@aws-amplify/auth'
import { amplifyConfig } from './config'
Auth.configure(amplifyConfig.Auth)
Storage.configure(amplifyConfig.Storage.AWSS3)
And now the error is different:
- [WARN] 31:35.966 AWSS3Provider - ensure credentials error No Auth module registered in Amplify
- index.js:1 No credentials
Versions:
"@aws-amplify/auth": "^1.2.31",
"@aws-amplify/core": "^1.0.31",
"@aws-amplify/storage": "^1.1.0",
UPDATE:
After updating @aws-amplify/core
to ^1.1.0
the following method works, anyway will be nice to go back to Amplify.configure
only.
import Storage from '@aws-amplify/storage'
import Auth from '@aws-amplify/auth'
import { amplifyConfig } from './config'
Auth.configure(amplifyConfig.Auth)
Storage.configure(amplifyConfig.Storage.AWSS3)
I'm also experiencing this issue. Oddly, the S3Images in one of my components aren't working while the S3Images in another page/component are working -- no clear difference in the amplify initialization path between the two, though. I reimplemented S3Image so that Storage
is the only dependency and am still seeing the same issue.
Edit: It appears to correctly identify that a Storage.AWSS3Provider module exists, but it never calls Storage.confgure. It does call Auth.confgure and Analytics.configure
[DEBUG] 15:53.793 Amplify - amplify config
{…}
aws_appsync_authenticationType: "AMAZON_COGNITO_USER_POOLS"
aws_appsync_graphqlEndpoint: "redactedl"
aws_appsync_region: "us-east-1"
aws_cognito_identity_pool_id: "redacted"
aws_cognito_region: "us-east-1"
aws_mobile_analytics_app_id: "redacted"
aws_mobile_analytics_app_region: "us-east-1"
aws_project_region: "us-east-1"
aws_user_files_s3_bucket: "redacted"
aws_user_files_s3_bucket_region: "us-east-1"
aws_user_pools_id: "redacted"
aws_user_pools_web_client_id: "redacted"
federationTarget: "COGNITO_IDENTITY_POOLS"
oauth: Object { }
<prototype>: Object { … }
breadcrumbs.js:58
[DEBUG] 15:53.817 I18n - configure I18n breadcrumbs.js:58
[DEBUG] 15:53.823 I18n - create I18n instance breadcrumbs.js:58
[DEBUG] 15:53.824 AuthClass - configure Auth breadcrumbs.js:58
[DEBUG] 15:53.825 Parser - parse config
Array(3) [ {…}, "to amplifyconfig", {…} ]
(manually formated array output of parse config)
[
0: SAME CONFIG AS ABOVE
1: "to amplifyconfig"
2: {
Analytics: Object { AWSPinpoint: {…} }
Auth [values are as expected]: Object { userPoolId: "redacted", userPoolWebClientId: "redacted", region: "redacted", … }
Storage: {
AWSS3: {
bucket: "redacted -- looks good",
dangerouslyConnectToHttpEndpointForTesting: undefined,
region: "us-east-1"
}
}
]
breadcrumbs.js:58
[DEBUG] 15:53.839 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.840 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.841 Analytics - on hub capsule auth
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.841 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.865 AuthClass - getting current authenticated user breadcrumbs.js:58
[DEBUG] 15:53.868 AnalyticsClass - configure Analytics
Object { aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "redacted", aws_cognito_region: "us-east-1", aws_user_pools_id: "redacted", aws_user_pools_web_client_id: "redacted", oauth: {}, federationTarget: "COGNITO_IDENTITY_POOLS", aws_appsync_graphqlEndpoint: "redacted", aws_appsync_region: "us-east-1", aws_appsync_authenticationType: "AMAZON_COGNITO_USER_POOLS", … }
breadcrumbs.js:58
[DEBUG] 15:53.869 Parser - parse config
Array(3) [ {…}, "to amplifyconfig", {…} ]
breadcrumbs.js:58
[DEBUG] 15:53.872 AWSPinpointProvider - configure Analytics
Object { disabled: undefined, appId: "redacted", region: "us-east-1" }
breadcrumbs.js:58
[DEBUG] 15:53.874 Hub - Dispatching to analytics with
Object { event: "pinpointProvider_configured", data: null }
breadcrumbs.js:58
[DEBUG] 15:53.879 Analytics - on hub capsule analytics
Object { event: "pinpointProvider_configured", data: null }
breadcrumbs.js:58
[DEBUG] 15:53.889 Hub - Dispatching to analytics with
Object { event: "configured", data: null, message: "The Analytics category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.890 Analytics - on hub capsule analytics
Object { event: "configured", data: null, message: "The Analytics category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.891 AnalyticsClass - current configuration
Object { AWSPinpoint: {…}, aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "redacted", aws_cognito_region: "us-east-1", aws_user_pools_id: "redacted", aws_user_pools_web_client_id: "6l40b9if6t1m4e96tui0tfrco3", oauth: {}, federationTarget: "COGNITO_IDENTITY_POOLS", aws_appsync_graphqlEndpoint: "redacted", aws_appsync_region: "us-east-1", … }
breadcrumbs.js:58
[DEBUG] 15:53.906 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:53.908 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:53.913 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:53.913 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:53.924 AuthClass - getting current authenticated user breadcrumbs.js:58
[DEBUG] 15:53.925 AuthClass - getting current authenticated user breadcrumbs.js:58
[DEBUG] 15:53.927 Amplify - amplify config
{…}
aws_appsync_authenticationType: "AMAZON_COGNITO_USER_POOLS"
aws_appsync_graphqlEndpoint: "redacted"
aws_appsync_region: "us-east-1"
aws_cognito_identity_pool_id: redacted
aws_cognito_region: "us-east-1"
aws_mobile_analytics_app_id:redacted
aws_mobile_analytics_app_region: "us-east-1"
aws_project_region: "us-east-1"
aws_user_files_s3_bucket: redacted
aws_user_files_s3_bucket_region: "us-east-1"
aws_user_pools_id:redacted
aws_user_pools_web_client_id:redacted
federationTarget: "COGNITO_IDENTITY_POOLS"
oauth: Object { }
<prototype>: Object { … }
breadcrumbs.js:58
[DEBUG] 15:53.929 I18n - configure I18n breadcrumbs.js:58
[DEBUG] 15:53.932 I18n - create I18n instance breadcrumbs.js:58
[DEBUG] 15:53.934 AuthClass - configure Auth breadcrumbs.js:58
[DEBUG] 15:53.936 Parser - parse config
Array(3) [ {…}, "to amplifyconfig", {…} ]
breadcrumbs.js:58
[DEBUG] 15:53.947 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.948 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.950 Analytics - on hub capsule auth
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.954 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.958 AuthClass - getting current authenticated user breadcrumbs.js:58
[DEBUG] 15:53.959 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.961 AuthClass - getting current authenticated user breadcrumbs.js:58
[DEBUG] 15:53.962 Hub - Dispatching to auth with
Object { event: "configured", data: null, message: "The Auth category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:53.972 AuthClass - getting current authenticated user breadcrumbs.js:58
[DEBUG] 15:53.974 AnalyticsClass - configure Analytics
Object { aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "redacted", aws_cognito_region: "us-east-1", aws_user_pools_id: "redacted", aws_user_pools_web_client_id: "redacted", oauth: {}, federationTarget: "COGNITO_IDENTITY_POOLS", aws_appsync_graphqlEndpoint: "redactedl", aws_appsync_region: "us-east-1", aws_appsync_authenticationType: "AMAZON_COGNITO_USER_POOLS", … }
breadcrumbs.js:58
[DEBUG] 15:53.975 Parser - parse config
Array(3) [ {…}, "to amplifyconfig", {…} ]
breadcrumbs.js:58
[DEBUG] 15:53.983 AWSPinpointProvider - configure Analytics
Object { disabled: undefined, appId: "redacted", region: "us-east-1" }
breadcrumbs.js:58
[DEBUG] 15:53.991 Hub - Dispatching to analytics with
Object { event: "pinpointProvider_configured", data: null }
breadcrumbs.js:58
[DEBUG] 15:53.994 Analytics - on hub capsule analytics
Object { event: "pinpointProvider_configured", data: null }
breadcrumbs.js:58
[DEBUG] 15:54.0 Hub - Dispatching to analytics with
Object { event: "configured", data: null, message: "The Analytics category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:54.2 Analytics - on hub capsule analytics
Object { event: "configured", data: null, message: "The Analytics category has been configured successfully" }
breadcrumbs.js:58
[DEBUG] 15:54.7 AnalyticsClass - current configuration
Object { AWSPinpoint: {…}, aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "redacted", aws_cognito_region: "us-east-1", aws_user_pools_id: "redacted", aws_user_pools_web_client_id: "redacted", oauth: {}, federationTarget: "COGNITO_IDENTITY_POOLS", aws_appsync_graphqlEndpoint: "redacted", aws_appsync_region: "us-east-1", … }
breadcrumbs.js:58
[DEBUG] 15:54.46 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:54.46 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:54.52 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:54.55 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:54.56 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:54.57 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:54.63 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:54.63 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:54.64 AuthClass - cannot load federated user from auth storage breadcrumbs.js:58
[DEBUG] 15:54.65 AuthClass - get current authenticated userpool user breadcrumbs.js:58
[DEBUG] 15:54.250 AWSPinpointProvider - updateEndpoint success
Object { MessageBody: {…} }
breadcrumbs.js:58
[DEBUG] 15:54.498 Storage - Create Storage Instance breadcrumbs.js:58
[DEBUG] 15:54.502 StorageClass - Storage Options
{}
<prototype>: Object { … }
breadcrumbs.js:58
[DEBUG] 15:54.505 StorageClass - Storage Options
Object { }
breadcrumbs.js:58
[DEBUG] 15:54.506 Amplify - component registered in amplify
Object { _config: {}, _pluggables: [], get: (), put: (), remove: (), list: (), vault: {…}, configure: configure()
}
breadcrumbs.js:58
[DEBUG] 15:54.885 StorageClass - No plugin found with providerName AWSS3 breadcrumbs.js:58
[DEBUG] 15:54.890 StorageClass - No plugin found with providerName AWSS3 breadcrumbs.js:58
[DEBUG] 15:54.893 StorageClass - No plugin found with providerName AWSS3 breadcrumbs.js:58
[DEBUG] 15:54.898 StorageClass - No plugin found with providerName AWSS3 breadcrumbs.js:58
[DEBUG] 15:54.902 StorageClass - No plugin found with providerName AWSS3 breadcrumbs.js:58
[DEBUG] 15:54.906 StorageClass - No plugin found with providerName AWSS3
(console errors)
TypeError: "prov is undefined"
get Storage.js:188
step Storage.js:52
verb Storage.js:33
__awaiter Storage.js:27
__awaiter Storage.js:23
get Storage.js:179
breadcrumbs.js:58
uncaught exception: No plugin found in Storage for the provider
Out of curiosity and a desire to move towards a custom Cloudfront solution, is the gist of the Storage module...
For me what worked,
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
in the root file i.e. App.tsx
It turned out that the Trust Relationships were misconfigured for the role.
In my case the wrong identity pool id in unauth role trust relationship. The value in cognito-identity.amazonaws.com:aud
was wrong.
I also encountered this issue and fixed it by importing Storage from "@aws-amplify/storage" and running Storage.configure(awsExports) in the class where I need Storage.
This is because in my original app.js I imported "@aws-amplify/core" instead of the main Amplify object, to save space. If you are doing that, you will also encounter this issue.
Hope this helps someone.
@cinnabarhorse. Yes your solution will fix a large number of cases like this. But it did not fix my case.
In addition to your suggestion above I had to check for duplicate @aws-amplify/core with the below command: yarn list --pattern "amplify" And then I upgraded @aws-amplify/core and all other amplify modules to make sure no module keep a duplicate module as a dependency.
Based on the above information, it seems to be that the issue is resolved. @alexofob Can you please create a new issue and provide a gist/code snippet and the environment information on the new issue? Resolving issue
I was seeing the same error with a Gatsby app when published to an S3 host. Everything worked fine locally. I was able to solve it by updating the auth resource and adding a user pool group for guests
. (amplify update auth
-- follow prompts)
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.
Which Category is your question related to? Storage
What AWS Services are you utilizing? Amazon S3
Provide additional details e.g. code snippets I am trying to create a simple static file in my S3 bucket with amplify, i have added storage through the amplify cli already and my config has the bucket.
my amplify configuration:
and when I am trying to use the Storage module -
I get 2 errors -
here's an image of the errors -