navapbc / wic-participant-recertification-portal

https://navapbc.github.io/wic-participant-recertification-portal/
Apache License 2.0
0 stars 1 forks source link

[PRP-344] Create IAM user for longer S3 presigned url expiration time #107

Closed rocketnova closed 1 year ago

rocketnova commented 1 year ago

Ticket

https://wicmtdp.atlassian.net/browse/PRP-344

Changes

What was added, updated, or removed in this PR.

Context for reviewers

Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers. Explain how the changes were verified.

According to the AWS documentation, maximum S3 presigned url expiration time for STS is tied to the maximum session duration of the assumed role (which can be 12 hours at most); whereas maximum S3 presigned url expiration time for an IAM user is 7 days.

This PR creates a machine IAM user to take advantage of the longer expiration time. It therefore also lowers the refresh frequency introduced in the previous hotfix #105. This PR changes the Eventbridge check to run once a day and update any urls that haven't been updated in the last 4 days. Important: The first time this is run, we need to refresh all the urls, so that the old expiration times are caught.

This PR also starts to add more inline code documentation to the infra codebase.

Testing

Screenshots, GIF demos, code examples or output to help show the changes working as expected. ProTip: you can drag and drop or paste images into this textbox.

rocketnova commented 1 year ago

Noting that last night's overnight Eventbridge schedule-triggered task in dev did not find any documents to update (log) and the document links in dev this morning appear to all still be working. This is promising.

rocketnova commented 1 year ago

Noting again that last night's overnight Eventbridge schedule-triggered task in dev did not find any documents to update (log) and the document links in dev seem to still be working 🤞

rocketnova commented 1 year ago

Last night's overnight log shows that the Eventbridge schedule-triggered task in dev finally did find some documents to update (log) and all the document links in dev appear to be working.

This shows that the refresh script found documents to update on the correct schedule.

Screenshot 2023-05-21 at 12 30 50 PM

I'm still wary of merging this in while the pilot is running in case we run into more unexpected AWS session expiry, so I'm going to wait until it's over to merge this one.