Closed ronaldtse closed 2 years ago
Ping @skalee since this is relevant to you too.
@phuonghuynh could you let us know how this is going? Thanks.
I think we need to update current lambda-redirect
code to support this feature
An other reference link is
@phuonghuynh what's the lambda-redirect code?
@ronaldtse this repo, https://github.com/riboseinc/terraform-aws-lambda-redirect-http-index, we can update code to read S3 objects and perform redirect to objects in latest .done
file
Sure, let's do that.
@ronaldtse how about using SQL Select feature of S3? https://docs.aws.amazon.com/AmazonS3/latest/userguide/selecting-content-from-objects.html
This enable us to save S3 cost; but we need to define a JSON object (max 1MB) for querying data we need.
@phuonghuynh do you mean that we can use a CSV file for index and use S3 Select to return the correct path?
yep, correct, but I think in JSON format would be better for human fast reading?
@ronaldtse the implement code now using CSV format as bellow
lastUpdatedTimestamp,rootDir
1615877411,dir1
1615875912,dir2
When upload progress done, this S3 Config file need to be appended. Required env variables needed for lambda to load it.
- `BUCKET_NAME` (optional): bucket name to set CSV Config File
- `BUCKET_CSV_CONFIG_KEY` (optional): csv config bucket object, sample as bellow
PR sent, https://github.com/riboseinc/terraform-aws-lambda-redirect-http-index/pull/2 Need someone able to test with staging test site
yep, correct, but I think in JSON format would be better for human fast reading?
Agree.
@ronaldtse I switch to use CSV because it easier than JSON when appending new line
Due to the issue in #29 , @strogonoff and I discussed about separating the website upload and website activation phases.
Assume that we have this S3 bucket layout:
index.html
from the newest bucket (the directory is named according to the user's preference, e.g. timestamp of initial upload). The.done
file is created when the bucket is fully uploaded.Then the upload flow would be:
20210401000000/
.20210401000000/.done
./
hits Lambda@Edge, and the function detects that the newest (sorted latest) directory is20210401000000
and it also contains the.done
path.20210401000000/index.html
..done
or the last two copies every hour or every day.This would be a good way of doing zero-downtime deployments.
Due to the additional complexity of this solution, this might better be a separate terraform module that builds on the current one.
Thoughts @strogonoff @phuonghuynh ?