{"action":"created","issue":{"url":"https://api.github.com/repos/izaakschroeder/vinyl-s3/issues/16","labels_url":"https://api.github.com/repos/izaakschroeder/vinyl-s3/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/izaakschroeder/vinyl-s3/issues/16/comments","events_url":"https://api.github.com/repos/izaakschroeder/vinyl-s3/issues/16/events","html_url":"https://github.com/izaakschroeder/vinyl-s3/issues/16","id":69142178,"number":16,"title":"Question: how to set credentials and region?","user":{"login":"AndreasPizsa","id":103221,"avatar_url":"https://avatars.githubusercontent.com/u/103221?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasPizsa","html_url":"https://github.com/AndreasPizsa","followers_url":"https://api.github.com/users/AndreasPizsa/followers","following_url":"https://api.github.com/users/AndreasPizsa/following{/other_user}","gists_url":"https://api.github.com/users/AndreasPizsa/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasPizsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasPizsa/subscriptions","organizations_url":"https://api.github.com/users/AndreasPizsa/orgs","repos_url":"https://api.github.com/users/AndreasPizsa/repos","events_url":"https://api.github.com/users/AndreasPizsa/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasPizsa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-17T13:45:22Z","updated_at":"2015-04-17T17:49:08Z","closed_at":null,"body":"Hi Izaak @izaakschroeder,\r\nthank you for this wonderful idea and implementation!\r\n\r\nMay I ask you for your advice, as I'm having trouble setting AWS options and am not sure where and how to set them correctly. I understand that `vinyl-s3` builds upon `aws-sdk`, so I read their docs and had some success.\r\n\r\nI tried setting AWS options with `AWS.config.update` before instantiating `vinyl-s3`, but unfortunately that had no effect at all (and I don't quite understand why). What did work was setting environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` - fair enough. \r\n\r\nWhere I'm still having difficulty is the region.\r\n\r\nI tried setting `AWS_DEFAULT_REGION` but unfortunately that was not successful.\r\nI then tried `AWS.config.update({region:'eu-west-1'});`, but I'm still getting \r\n\r\n    PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.\r\n\r\nI'm a bit stuck here and am hoping you might have an idea?\r\n\r\nThank you very much for your help!\r\n\r\nBest,\r\nAndreas\r\n\r\n**UPDATE**: setting `AWS_REGION` worked - but I'm still wondering if and how it's possible to set options programmatically? Thank you!"},"comment":{"url":"https://api.github.com/repos/izaakschroeder/vinyl-s3/issues/comments/94038029","html_url":"https://github.com/izaakschroeder/vinyl-s3/issues/16#issuecomment-94038029","issue_url":"https://api.github.com/repos/izaakschroeder/vinyl-s3/issues/16","id":94038029,"user":{"login":"izaakschroeder","id":206921,"avatar_url":"https://avatars.githubusercontent.com/u/206921?v=3","gravatar_id":"","url":"https://api.github.com/users/izaakschroeder","html_url":"https://github.com/izaakschroeder","followers_url":"https://api.github.com/users/izaakschroeder/followers","following_url":"https://api.github.com/users/izaakschroeder/following{/other_user}","gists_url":"https://api.github.com/users/izaakschroeder/gists{/gist_id}","starred_url":"https://api.github.com/users/izaakschroeder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izaakschroeder/subscriptions","organizations_url":"https://api.github.com/users/izaakschroeder/orgs","repos_url":"https://api.github.com/users/izaakschroeder/repos","events_url":"https://api.github.com/users/izaakschroeder/events{/privacy}","received_events_url":"https://api.github.com/users/izaakschroeder/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T17:49:08Z","updated_at":"2015-04-17T17:49:08Z","body":"Hey @AndreasPizsa!\r\n\r\nSo the reason the above error is happening is that in the `vinyl-s3` module I list `aws-sdk` as a direct dependency (so you don't have to install anything); the problem is that it means `vinyl-s3` has its OWN copy of the `AWS` variable; the one you're trying to access is different, even though it looks the same.\r\n\r\nTo address this I could list `aws-sdk` in `peerDependencies` instead, but that would also mean that you must then install `aws-sdk` as part of your package's `dependencies` _in addition to_ having `vinyl-s3`.\r\n\r\nYou will also note that the `plugin` object (as in `var plugin = require('vinyl-s3`);` has its own S3 instance attached. You could do something like `plugin.s3 = new AWS.S3({ accessKeyId: ... });` to override it with your own S3 instance from your specific `aws-sdk` which will include the configuration settings.\r\n\r\nI'm not certain of this, but I think you might also be able to pass the parameters you want as part of the `src` or `dest` functions. e.g. `s3.src('s3://foo/bar/*.jpg?region=eu-west-1')`. I'm not sure exactly on the syntax or variables for this.\r\n\r\nI recommend keeping them in environment variables since it's supported by the AWS SDK out of the box and allows you to transition easily to other safer authentication methods where supported (e.g. on an EC2 instance you can use the role assigned to the instance instead)."}}