gatsby-plugin-s3 icon indicating copy to clipboard operation
gatsby-plugin-s3 copied to clipboard

Make creation of buckets optional

Open nodesocket opened this issue 5 years ago • 5 comments

It appears if the bucket does not exist, this plugin creates it in us-east-1. Is there a command option instead to fail if the bucket does not exist? We manage bucket creation in Terraform, and don't want this plugin creating random buckets in our AWS account.

 options: {
   bucketName: "will-create-if-it-doesnt-exist" // bad!
 }

nodesocket avatar Apr 28 '20 00:04 nodesocket

Good suggestion! Currently this isn't something we have an option for, I can see why it would be useful. In my opinion, creating a bucket if it doesn't already exist violates Principle of Least Astonishment. I'm hoping we can remove it as the default behaviour, but that will need to wait for the 1.0 release.

In the meantime I'd suggest not granting the plugin the IAM s3:CreateBucket permission. We haven't yet published documentation for which permissions the plugin requires, but you can find a list in #39.

YoshiWalsh avatar Apr 28 '20 00:04 YoshiWalsh

Ok, while I have you here, I don't see in the documentation a list of all options and descriptions. Currently only setting:

const siteAddress = new URL('https://www.ourdomainhere.dev');

options: {
    bucketName: "www.ourdomainhere.dev",
    protocol: siteAddress.protocol.slice(0, -1),
    hostname: siteAddress.hostname,
}

nodesocket avatar Apr 28 '20 00:04 nodesocket

Documentation is definitely somewhere that we have room for improvement. At the moment you can find all of the config options (and descriptions of what they do) in src/constants.ts:

https://github.com/jariz/gatsby-plugin-s3/blob/a0532ed68ead8496004cfcba16456d709ee801ad/src/constants.ts#L26-L89

YoshiWalsh avatar Apr 28 '20 00:04 YoshiWalsh

Thanks. Would be awesome to have all those options and their defaults in the README and documentation.

nodesocket avatar Apr 28 '20 00:04 nodesocket

We would be happy to accept a pull request improving the documentation. Otherwise we will get to it when we get to it. At the moment our focus is on preparing for a 1.0 release.

YoshiWalsh avatar Apr 28 '20 03:04 YoshiWalsh