This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add new bucket to example site * feat: use AWS pre-signed URL to get objects from private buckets * test: add e2e test to check that the example site has 1502 images * chore: remove region plugin option The option is not required anymore when using pre-signed URLs * revert: "chore: remove region plugin option" This reverts commit d870d3c. The AWS SDK apparently still expects a region. * chore(scripts): add local start script with additional env cleanup * docs: add READMEs to the starter and testing directories * docs(tests): add details to the testing README * fix: fix testing folder structure Cypress sees any file in the integrationFolder as a spec. The spec had to be nexted one level deeper to allow for the README * docs: update README * feat: get signed URL only for image files in onCreateNode BREAKING CHANGE: the Url key doesn't exist on s3Object anymore. There is not a public URL for private buckets and file nodes are now sourced with pre-signed URLs that shouldn't be added to the schema.
- Loading branch information
1 parent
a4f06b4
commit 8eb1eab
Showing
9 changed files
with
204 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# gatsby-starter-source-s3 | ||
|
||
This starter is an example of how to source objects from AWS S3 in a Gatsby site | ||
at build time, using `@robinmetral/gatsby-source-s3`. | ||
|
||
It uses a local version of the plugin located in `/src`, and it can be used for | ||
local development and testing. | ||
|
||
To run it locally, you'll need to add the following environment variables in a | ||
`.env` file: | ||
|
||
```bash | ||
AWS_ACCESS_KEY_ID="" | ||
AWS_SECRET_ACCESS_KEY="" | ||
AWS_REGION="" | ||
``` | ||
|
||
## AWS S3 setup | ||
|
||
This site sources images from three separate buckets: | ||
|
||
1. gatsby-source-s3-example (public) | ||
2. gatsby-source-s3-example-2 (public) | ||
3. gatsby-source-s3-continuation-token (private) | ||
|
||
The first two buckets are set up for public access with the following policy: | ||
|
||
```json | ||
{ | ||
"Version": "2008-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "AllowPublicRead", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Action": "s3:GetObject", | ||
"Resource": "arn:aws:s3:::gatsby-source-s3-example/*" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
_Note: the resource is the bucket's arn with the `/*` scope._ | ||
|
||
The third bucket is private, its policy is the default for S3 (i.e. nothing was | ||
changed when creating the bucket). | ||
|
||
## AWS IAM setup | ||
|
||
The AWS access keys used by this example are for a `gatsby-source-s3` user to | ||
which I attached the following access policy: | ||
|
||
```json | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": ["s3:ListBucket"], | ||
"Resource": [ | ||
"arn:aws:s3:::gatsby-source-s3-example", | ||
"arn:aws:s3:::gatsby-source-s3-example-2", | ||
"arn:aws:s3:::gatsby-source-s3-continuation-token" | ||
] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": ["s3:GetObject"], | ||
"Resource": [ | ||
"arn:aws:s3:::gatsby-source-s3-example/*", | ||
"arn:aws:s3:::gatsby-source-s3-example-2/*", | ||
"arn:aws:s3:::gatsby-source-s3-continuation-token/*" | ||
] | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.