-
Notifications
You must be signed in to change notification settings - Fork 31
Backend — Setup Your S3
ff6347 edited this page May 4, 2021
·
6 revisions
As we did for the database we also use Terraform to setup our S3 where we store these files. As mentioned before. You can use the AWS console to setup these resources. The S3 should have public access and we need this policy and CORS rules enabled.
{
"Version": "2012-10-17",
"Id": "Policy-public-read-1",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR BUCKET NAME/*"
}
]
}
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST",
"PUT"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
These are the files that get generated by the harvester.
-
trees.csv
. Used for the initial drawing of the trees on the map. It only contains the id of the tree in our database, the geo coordinates, the radloan (rain) sum and the age of the tree. All additional informations are loaded from the database. -
trees-p1.csv
,trees2-p.csv
,trees-p3.csv
,trees-p4.csv
. Used to generate vector tiles for Mapbox. This is the same astrees.csv
but cut into 4 pieces. -
weather.geojson
. Used for the rain layer visualization
To get this up and running follow these steps:
# clone the repo
git clone https://github.com/technologiestiftung/giessdenkiez-de-aws-s3-terraform.git gdk-s3
# move into the right folder
cd gdk-s3/
# create the secrets file based in the sample
cp terraform.tfvars.sample terraform.tfvars
# fill in the blanks in the file
# Install the used terraform version
asdf install
# Initialize your terraform environment
terraform init
# See if it works
terraform plan
# Apply the setup
terraform apply
You should now have a S3 bucket with the desired policy and CORS rules.