There are two ways to configure your storage in Namviek as follows:
- Configure default AWS S3 storage in
.env
file - Configure AWS S3 storage for each organization
Both you have to create an access token to use AWS S3
Create a bucket
Go to Amazon S3
> Buckets
> Create bucket
to create a new bucket. Ex: namviek-storage.
In development mode, turn off public access for testing. Move to Amazon S3
> Buckets
> [your bucket name]
> Permissions
and scroll to Bucket policy section and paste the following
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::namviek-storage/*"
}
]
}
Remember that if you changed bucket name to something else, please update it to Resource field. Ex: arn:aws:s3:::your-store-name/*
And then, scroll down to Cross-origin resource sharing (CORS) section and paste the following config. One thing to keep in mind that you have to replace the origin with your Frontend url
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT",
"GET"
],
"AllowedOrigins": [
"https://<your-frontend-domain-here>"
],
"ExposeHeaders": []
}
]
Create an IAM user
Next, go to IAM
> Users
and click on Create user to create a new IAM user. In this example, I create an user called namviek-storage-default
At the step Attach policies directly search for AmazonS3FullAccess
and select it
Continue following the guide to create the iam user. After it done, click on the user and go to Security credentials as below
Create access key
In IAM
> Users
> namviek-storage-default
scroll down to Access Keys section and click on Create access key
A new page will be opened that tell you to choose a specified case you want to use access key. For now, just click on Other
option. Press Next and ignore decription tag then Create access key
Save the access key into save place to use in next step.
Option 1: Update .env
file
Open your .env
file and update the following variables. That's it
AWS_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_S3_BUCKET=
Option 2: Update organization configure
Open the app and go to Setting
> About
. Click on Storage configuration and input your aws access token here.