fix(lambdas): write main data file under data/ prefix (fixes stale content root cause) - #3
Merged
Merged
Conversation
The Lambdas upload their main output to S3_KEY at the bucket root
("gh-trending.json", "hn-digest.json", "release-radar.json"), but the
IAM policy only grants s3:PutObject on the `data/*` prefix
(tech-bytes-stack.ts:180). Every main-file write therefore failed with
AccessDenied — confirmed in CloudWatch logs:
AccessDenied ... s3:PutObject on .../gh-trending.json because no
identity-based policy allows the s3:PutObject action
Only the archive copies (already under data/archive/) ever persisted.
This is the actual reason the site content was stale: the files the
site reads (data/*.json) and email_digest reads (data/*.json) were
never successfully written — the site fell back to the committed
seed files. The deploy.yml sync (s3://BUCKET/data/) also never saw the
root-level files.
Prefix S3_KEY with `data/` in all three handlers so the write path
matches the IAM grant, the email_digest read keys, the site read path,
and the deploy sync. No infra change needed — data/* is already granted.Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jun 7, 2026
datj9 added a commit
that referenced
this pull request
Jul 11, 2026
The Lambdas upload their main output to S3_KEY at the bucket root
("gh-trending.json", "hn-digest.json", "release-radar.json"), but the
IAM policy only grants s3:PutObject on the `data/*` prefix
(tech-bytes-stack.ts:180). Every main-file write therefore failed with
AccessDenied — confirmed in CloudWatch logs:
AccessDenied ... s3:PutObject on .../gh-trending.json because no
identity-based policy allows the s3:PutObject action
Only the archive copies (already under data/archive/) ever persisted.
This is the actual reason the site content was stale: the files the
site reads (data/*.json) and email_digest reads (data/*.json) were
never successfully written — the site fell back to the committed
seed files. The deploy.yml sync (s3://BUCKET/data/) also never saw the
root-level files.
Prefix S3_KEY with `data/` in all three handlers so the write path
matches the IAM grant, the email_digest read keys, the site read path,
and the deploy sync. No infra change needed — data/* is already granted.
Co-authored-by: Dat <dat.nguyen@ringkas.co.id>
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause of the stale content
While verifying #1 end-to-end (invoking the deployed `gh_trending` Lambda), CloudWatch revealed the actual reason trending/HN/release content was outdated:
```
ERROR Failed to upload to S3
AccessDenied ... s3:PutObject on .../gh-trending.json
because no identity-based policy allows the s3:PutObject action
```
All three Lambdas upload their main file to a bucket-root key (`gh-trending.json`, `hn-digest.json`, `release-radar.json`), but the IAM policy grants `s3:PutObject` on the `data/*` prefix only (`tech-bytes-stack.ts:180`). So every main-file write has always failed with AccessDenied. Only the archive copies (already under `data/archive/`) persisted.
Consequences that all trace back to this:
Change
One-line fix per handler — prefix `S3_KEY` with `data/`:
This aligns the write path with the IAM grant, the `email_digest` read keys, the site read path, and the deploy sync. No infra change — `data/*` is already granted.
Test plan