-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add s3 bucket for static files, implement in network compose and k8s
- Loading branch information
Showing
16 changed files
with
76 additions
and
4 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,44 @@ | ||
#!/bin/bash | ||
|
||
# Docs: | ||
# Creating buckets: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html | ||
# cli create-bucket: https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html | ||
# cli public access block: https://docs.aws.amazon.com/cli/latest/reference/s3api/put-public-access-block.html | ||
# cli bucket acls: https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-acl.html | ||
# cli bucket website: https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-website.html | ||
|
||
# Context: infra/ | ||
|
||
set -e | ||
|
||
BUCKET_PREFIX="jukebox-client" | ||
REGION="us-east-1" | ||
|
||
# Create bucket with unique name | ||
export bucket_name="$BUCKET_PREFIX-$(uuidgen | tr -d - | tr '[:upper:]' '[:lower:]' )" | ||
aws s3api create-bucket \ | ||
--bucket "$bucket_name" \ | ||
--region "$REGION" \ | ||
--object-ownership BucketOwnerPreferred > /dev/null | ||
|
||
# Disable default security protocols, allow public access | ||
aws s3api put-public-access-block \ | ||
--bucket "$bucket_name" \ | ||
--public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false" > /dev/null | ||
|
||
|
||
# Create policy so public can only read bucket content | ||
aws s3api put-bucket-policy \ | ||
--bucket "$bucket_name" \ | ||
--policy "$(envsubst < ./templates/s3/s3-allow-public-access-policy.json.tpl)" > /dev/null | ||
|
||
# Create s3 static website hosting | ||
aws s3api put-bucket-website \ | ||
--bucket "$bucket_name" \ | ||
--website-configuration '{ "IndexDocument": { "Suffix": "index.html" } }' > /dev/null | ||
|
||
bucket_uri="$bucket_name.s3-website-$REGION.amazonaws.com" | ||
echo "Bucket upload uri: s3://$bucket_name" | ||
echo "Bucket proxy uri: $bucket_uri" | ||
echo "Bucket endpoint: http://$bucket_uri" | ||
|
File renamed without changes.
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,16 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "PublicReadGetObject", | ||
"Effect": "Allow", | ||
"Principal": "*", | ||
"Action": [ | ||
"s3:GetObject" | ||
], | ||
"Resource": [ | ||
"arn:aws:s3:::${bucket_name}/*" | ||
] | ||
} | ||
] | ||
} |
File renamed without changes.
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