Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple buckets? #5836

Open
ffxsam opened this issue Feb 21, 2018 · 27 comments
Open

Support for multiple buckets? #5836

ffxsam opened this issue Feb 21, 2018 · 27 comments

Comments

@ffxsam
Copy link

@ffxsam ffxsam commented Feb 21, 2018

In the documentation examples:

Amplify.configure(
    Auth: {
        identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', //REQUIRED - Amazon Cognito Identity Pool ID
        region: 'XX-XXXX-X', // REQUIRED - Amazon Cognito Region
        userPoolId: 'XX-XXXX-X_abcd1234', //OPTIONAL - Amazon Cognito User Pool ID
        userPoolWebClientId: 'XX-XXXX-X_abcd1234', //OPTIONAL - Amazon Cognito Web Client ID
    },
    Storage: {
        bucket: '', //REQUIRED -  Amazon S3 bucket
        region: 'XX-XXXX-X', //OPTIONAL -  Amazon service region
    });

What if the web app needs to interact with more than one bucket? It would be nice to have a system where we could specify several and interact with them via their names.

    Storage: {
      bucketOne: {
        bucket: '', //REQUIRED -  Amazon S3 bucket
        region: 'XX-XXXX-X', //OPTIONAL -  Amazon service region
      },
      bucketTwo: { ... }
    });
@tim-thompson
Copy link

@tim-thompson tim-thompson commented Jul 5, 2018

Don't know what the progress on this has been but as it is still open thought I would comment.
I had this same restriction today and after some digging found that it is possible to pass a bucket option into various calls as follows:

Storage.vault.get(key, {bucket: 'alternative-bucket-name'});

Using this I've managed to successfully use multiple buckets in the same app. If it is not specified then it defaults back to the bucket in the global configuration for Amplify.

Loading

@jnreynoso
Copy link

@jnreynoso jnreynoso commented Sep 27, 2018

Hi, what is valud @tim-thompson ? Storage.vault

Loading

@annjawn
Copy link

@annjawn annjawn commented Nov 8, 2018

Is there any update on this? Support for multiple buckets is a really desirable feature.

Loading

@tim-thompson
Copy link

@tim-thompson tim-thompson commented Nov 8, 2018

@annjawn I posted a solution further up this page that works for all my scenarios. If you need more info then I've written about it on my blog in more detail - http://tim-thompson.co.uk/aws-amplify-multiple-buckets.

Loading

@annjawn
Copy link

@annjawn annjawn commented Nov 9, 2018

@tim-thompson i have tried the storage.vault method but it did not work for me for some reason. Also, it looks like only get works with storage.vault however the code suggests otherwise. I've found a solution btw. I am doing storage.config() before each operation by setting the appropriate bucket name. It's less than efficient, but it's getting the job done.

Loading

@rizerzero
Copy link

@rizerzero rizerzero commented Nov 13, 2018

@annjawn Hi, do you have a blog post on your method ? thanks in advance 👍

Loading

@10ky
Copy link

@10ky 10ky commented Dec 2, 2018

If you are able to get content off of a bucket using this statement:

Storage.vault.get(key, {bucket: 'alternative-bucket-name'});

It would be a security issue. Unless you allow it in an IAM role attached the a user. I believe amplify uses this role "s3_amplify_...". This role should be modified automatically according to your aws-exports.js file when you do amplify push. I don't see how the above statement would affect "amplify push".

Loading

@10ky
Copy link

@10ky 10ky commented Dec 2, 2018

@mlabieniec is this feature request removed from the aws-amplify milestone on Jul 19? I thought this is a good feature to have. I think I have a use case where all my resized photos in S3 can be in a separate bucket. Right now, the S3image and album library resizes photo at the client side. If my photo files are very large, that would not be desirable. If the resize file is put in the same directory as in the private user directory, a lambda trigger would not work because S3 trigger does not support regular expression prefix match.

Loading

@ngocketit
Copy link

@ngocketit ngocketit commented Jan 14, 2019

It would be very convenient to have this supported. Currently, I have to call Amplify.configure() with new bucket every time I want to do something with non-default bucket.

Loading

@hoang-innomizetech
Copy link

@hoang-innomizetech hoang-innomizetech commented Mar 28, 2019

We are also looking for this feature, we are building an app that requires access to multiple buckets, so it would be better if we don't have to specify the bucket when configuring amplify (or we can use default bucket), some APIs also need to allow us specify bucket such as get pre-signed url

Loading

@stale
Copy link

@stale stale bot commented Jun 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Loading

@dylan-westbury
Copy link

@dylan-westbury dylan-westbury commented Jun 24, 2019

Something similar with configuring API, you can specify an array of endpoints. Array of buckets could be nice

Loading

@DmitriWolf
Copy link

@DmitriWolf DmitriWolf commented Jul 10, 2019

I also would like to see a feature added to Amplify to support the use of multiple buckets.
Great work. Thank you all, contributors.

Loading

@Off2Race
Copy link

@Off2Race Off2Race commented Oct 27, 2019

I used @tim-thompson's suggestion and it worked for me as well. The documentation for Storage.get probably needs to be updated but the following works fine:

Storage.get(key1, {bucket: 'bucket-1'});  
Storage.get(key2, {bucket: 'bucket-2'});  

I've only tried it for "public" access (any authenticated user of my app) but looking at the code I don't see a reason why it wouldn't work in other scenarios too. In effect, the bucket you specify during the Amplify.configure appears to be a default that can be overridden.

Loading

@jimji1005
Copy link

@jimji1005 jimji1005 commented Dec 27, 2019

above only works if buckets are in the same region, unfortunately. 🤦‍♂

Loading

@Ramesh-Chathuranga
Copy link

@Ramesh-Chathuranga Ramesh-Chathuranga commented May 6, 2020

if you want to add more s3 bucket to your project, use Configuration when uploading file.
this is an example code for multi s3 bucket.

function=(fileName, file, isUser=false)=>{
  if(isUser){
  Storage.configur({ AWSS3: {
          bucket: 'bucketA',
          region: "us-exxxx"
        }});
  return Storage.put(fileName, file, {
        contentType: file.type,
      });
}else {
   Storage.configur({ AWSS3: {
          bucket: 'bucketB',
          region: "us-exxxx"
        }});
  return Storage.put(fileName, file, {
        contentType: file.type,
      });
}}

Loading

@dtelaroli
Copy link

@dtelaroli dtelaroli commented Jun 15, 2020

I'm used to use one bucket and event trigger by environment/account.
It would be great a native cli support for that.

Loading

@aelbokl
Copy link

@aelbokl aelbokl commented Aug 4, 2020

I am just commenting to keep the bot from killing this thread. This feature is much needed and has many use cases.

Loading

@KesleyDavid
Copy link

@KesleyDavid KesleyDavid commented Sep 6, 2020

Also needing this feature

Loading

@sammartinez sammartinez self-assigned this Oct 9, 2020
@cody1024d
Copy link

@cody1024d cody1024d commented Oct 11, 2020

Adding my need for this functionality too

Loading

@PatrykMilewski
Copy link
Contributor

@PatrykMilewski PatrykMilewski commented Oct 27, 2020

Would be nice to have that

Loading

@harrysolovay harrysolovay transferred this issue from aws-amplify/amplify-js Nov 11, 2020
@sammartinez
Copy link
Contributor

@sammartinez sammartinez commented Nov 11, 2020

cc @renebrandel that we need Amplify CLI to do the implementation first prior to us doing anything on Amplify JS

Loading

@r0zar
Copy link
Contributor

@r0zar r0zar commented Nov 13, 2020

Does #3977 solve for this use case? I imagine that it would.

Loading

@stleon
Copy link

@stleon stleon commented Dec 20, 2020

amplify import storage
Scanning for plugins...
Plugin scan successful
? Please select from one of the below mentioned services: S3 bucket - Content (Images, audio, video, etc.)
Amazon S3 storage was already added to your project.

It would be very useful if there were any support for multiple storages.

Loading

@arealmaas
Copy link

@arealmaas arealmaas commented Feb 18, 2021

Ping 🙋

Loading

@santhedan
Copy link

@santhedan santhedan commented Feb 24, 2021

This is a must have feature similar to how you allow multiple APIs to be invoked. Workaround exists for web but not for iOS and Android.

Loading

@nathanagez
Copy link

@nathanagez nathanagez commented Apr 16, 2021

Any status on this feature ? :)

Loading

@sammartinez sammartinez removed their assignment Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet