Several copies, one store, and a floor that runs only when it is asked
On this page
- Why
- Turning it on
- What a copy remembered, and where it lives now
- What is in the table, exactly
- What each part of a session's record is trusted for
- Who can do what with it
- The rule, and how each part keeps it
- What it costs to ask
- Where two copies can still be told from one
- What the store has been run against
- On AWS Lambda
- Setting one up
- An address of its own
- One key for every floor
- What a floor costs a month
- What it has been run against
- What comes next
A hosted floor is one copy of the app that is always on. This page is about the first step away from that: a hosted copy that keeps what it must remember in one store, outside itself, so that any number of copies sharing that store behave as one server.
It is off unless you name a table (--store). Without it nothing here applies: the copy is exactly as Hosting describes, and none of this code is even loaded.
#Why
An always-on copy costs what an always-on machine costs, whether anybody opens the floor that day or not. The aim is to pay only when it is used: to run the floor on AWS Lambda, where a copy runs for the length of a request and costs nothing between.
Lambda changes what a copy may assume:
- It is frozen between requests. Nothing happens "behind the scenes" unless a request is being answered.
- Several copies run at once, and any of them may answer any request.
- A copy may vanish at any moment, with whatever was in its memory.
Until now the copy kept a great deal in its own memory: who is signed in, sign-ins part-way through, what was already asked of GitHub, whose turn it is to decide, the newest reading. That ties it to one process that never stops. So everything that must outlive one request, or be the same for every copy, now has a home outside the copy.
The first half of this page is the store, which any hosted copy can be given. The second half is the floor on Lambda, which needs it: the entry, setting one up, an address of its own and moving an always-on floor to Lambda, one key for every floor, and what it costs. It ran on AWS itself for the first time on 3 December 2026, as a trial floor for one project; what that showed, and what on this page has still only been run against a made-up AWS, is at the end.
#Turning it on
python3 -m factory.app --hosted https://floor.example.com --sign-in Iv23... --repo OWNER/REPO \
--keep s3://BUCKET/PREFIX --keep-sign-ins KEY --store dynamodb://TABLE
or FACTORY_STORE=dynamodb://TABLE beside the settings in Hosting. It needs all of:
| Why | |
|---|---|
--hosted | Only a hosted copy has anybody to share with. |
--keep s3://… | Two things are too large for a table (the history with the last reading, and the cost report). They stay in the kept place, and it must be one every copy can reach: a bucket, not a directory. |
--keep-sign-ins KEY | Sessions are then in the table, tokens and all. Nothing that is or could become access is ever in the table unlocked, and the only lock this app has is AWS KMS (why). So no key, no store. |
A copy given a store without every one of those refuses to start, and says which is missing. So does one whose table is not there, or whose role may not use it. A table that only cannot be reached at that moment is said in the log and the copy starts: until the table answers, nobody is taken to be signed in.
The table. One DynamoDB table, with a partition key called name (a string) and no sort key, and time-to-live turned on for the attribute until:
aws dynamodb create-table --table-name factory-floor --billing-mode PAY_PER_REQUEST \
--attribute-definitions AttributeName=name,AttributeType=S --key-schema AttributeName=name,KeyType=HASH
aws dynamodb update-time-to-live --table-name factory-floor --time-to-live-specification Enabled=true,AttributeName=until
Give the copy's role dynamodb:GetItem, PutItem, UpdateItem and DeleteItem on that one table, and nothing else of DynamoDB. It already has s3:GetObject and s3:PutObject on its folder of the bucket, and kms:Encrypt and kms:Decrypt on its key. AWS_REGION says where the table is. For a floor on Lambda, hosting/aws_serverless.py makes the table and the role (below); hosting/aws_floor.py, for a floor that is always on, does not.
Several floors may share one table: every name in it begins with the floor's own address. Turn on encryption at rest and point-in-time recovery as you would for any table; the app does not depend on either.
Turning it on signs everybody out once, as any restart without kept sign-ins does: sessions made before are in the old copy's memory, or in sign-ins.json, and not in the table. A copy with a store does not use sign-ins.json and empties it as it starts.
#What a copy remembered, and where it lives now
The whole list of what the server holds beyond one request. "Lost" means: the copy that held it vanished, or, for the store, the thing was deleted.
| What | Without a store | With a store | How long | If it is lost |
|---|---|---|---|---|
| A session: the person's token, refresh token, when each ends, their GitHub name, how they signed in | Memory (the refresh token also in sign-ins.json, locked, when sign-ins are kept) | The table: session/HASH, the two tokens locked together by KMS | Up to a week (twelve hours where tokens cannot be renewed) | They sign in again |
| A copy's own unlocked copy of a session's token, and the person's floors | Memory | Each copy's memory: a saving only, used only after the table has said, for this request, that the session is there and unchanged | Until the session changes or ends | KMS is asked once, and the door is asked afresh |
A one-click sign-in part-way through: its state, its PKCE verifier | Memory | attempt/HASH: a hash of the state; the verifier locked by KMS | Ten minutes | "That sign-in cannot be finished": they begin again |
| A code sign-in part-way through: GitHub's device code, when GitHub was last asked | Memory | attempt/HASH: the device code locked by KMS; asking/HASH, a lease, so one copy asks GitHub at a time | Fifteen minutes | They begin again |
How many wrong states came back for an attempt | Memory | wrong/HASH, a counter | Ten minutes | The count begins again |
| Who has one of the 200 places, and since when (the house, the two safe minutes) | Memory | house: one small thing, changed by compare-and-set | As long as each place | Nobody is signed out. The count begins from nothing, so more than 200 could be in for a while |
| How often each caller has begun a sign-in | Memory (Callers) | caller/HASH, under a hash of their address | Ten minutes | They may begin five more |
| One renewal at a time for a session | A lock in memory | renewing/HASH, a lease of 45 seconds, and refused/HASH while a refused renewal waits | The renewal | It lapses by itself |
| "GitHub could not be asked to renew a moment ago" (not again for half a minute) | Memory | Each copy's memory | Half a minute | GitHub is asked once more, by one copy at a time |
| What a person may do on each project, when the door last said yes, the grace while GitHub is down, a no not asked about again for a minute | Memory, for each person | Each copy's memory, for each person. A copy asks GitHub itself, with the person's own access, before it shows them anything. Nothing one copy learned lets anybody in on another | Five minutes; a quarter of an hour's grace | The door is asked again |
| What was already asked of GitHub from here (a release, a merge, a go-ahead…) | Memory, for everybody let in (Room.asked), and a note in the history | asked/PROJECT/HASH, written before anything is sent | A quarter of an hour | It could be asked for twice. The note in the history still says it was asked |
| One decision at a time, and how many have had their turn | A lock and a counter in memory | acting/PROJECT, a lease; turns/PROJECT, a counter | A decision | The lease lapses in a minute |
| "This person has just decided: read at once for them" | Memory | In room/PROJECT | A quarter of an hour | Their next look may wait a minute for a reading that failed just before |
| Everybody's newest reading, and when somebody last decided | Memory (Room.newest, decided) | room/PROJECT says which reading is newest; the reading itself is in the kept history | Five minutes | The next person reads GitHub with their own access |
| A person's own last reading, with what it cost them | Memory | Each copy's memory | Five minutes | They are given everybody's newest, which does not say what it cost; or GitHub is read again |
| A reading going on behind an older one that was handed out | A thread | A job in room/PROJECT, and job/reading/PROJECT, a lease | Until it is done | The job is still there for the next copy |
| Why a person's last reading failed (not tried again for five minutes) | Memory, for each person | In room/PROJECT, under a hash of that person's session: said to them on every copy, and to nobody else (it may speak of their own hourly allowance) | Five minutes | It is tried again sooner |
| The cost report | Memory, for an hour | An object in the kept place; room/PROJECT says when it was made | An hour | It is worked out again when somebody asks |
| "A cost report is being worked out", and why the last try failed | Memory | A job in room/PROJECT, and job/cost/PROJECT, a lease; the failure in room/PROJECT | Until it is done; a minute | The lease lapses in a minute and the next copy with the chance does it |
| The history, with the last reading whole and the short history of the cost | One object in the kept place, written whole by one writer, behind the scenes | The same object, written on a condition, in the request that changed it | Kept | Steps older than a week are lost, and nothing more |
The kept sign-ins (sign-ins.json) and their one writer | The kept place, when sign-ins are kept | Not used: sessions are in the table | ||
| What GitHub answered last time, for each person, so as to ask only "has this changed?" | Memory, for each person | Each copy's memory, for each person | The session | A reading on a copy that has not made one for that person is paid for in full from their hourly allowance |
| Who a token is, as GitHub names them | Memory, for each person | Each copy's memory | The session | One request to GitHub |
| "The KMS key said no a moment ago": of everything, when the copy's own test value was refused too; otherwise of the one record asked about (why) | Memory | Each copy's memory | Half a minute | KMS is asked once more |
| How far a reading that is being made has got (on Lambda only) | Not kept | progress/PROJECT, written a handful of times by the run that makes the reading | Said for forty seconds after it was written | The page says only that a reading is being made |
| How long the last sign-in was to last (what the sign-in card tells a newcomer) | Memory | usual, read by each copy once a minute at most | Until the next sign-in | The card says seven days |
#What is in the table, exactly
Every name begins with the floor's address and |. A HASH is a SHA-256.
| Name | What it holds |
|---|---|
house | For each sign-in part-way through and each session: a hash, and two times |
attempt/HASH | Under a hash of what the browser holds while signing in. web, began, until; for one click, state (a hash of the state), used, and the PKCE verifier locked; for a code, interval, asked, and the device code locked |
wrong/HASH | A count |
session/HASH | Under a hash of the session's id. The id is the cookie's value and is never kept, so nothing in the table can be used as a cookie. login, how (click or code), began, until, token_until, renewable, and locked: the access token, the refresh token and when the token lapses, together, locked. What each field is trusted for is below |
refused/HASH | When GitHub first refused to renew a session whose record had not changed, and which version that was: the wait before such a session is ended is one wait for all copies |
caller/HASH | Under a hash of a caller's address: the times they began a sign-in in the last ten minutes |
usual | How long the last sign-in was to last, and whether its token can be renewed |
room/PROJECT | Which reading is newest and which version of the history holds it; when somebody last decided; what is left to be done, with a hash of the session that asked; why the last cost report failed, and why each person's last reading failed (under a hash of their session), in the app's own words; when the cost report was made and what it cost to ask; hashes of the sessions that have just decided; and, on a copy that leaves its readings for later, when each such session's watch last had a reading made and how many it has had |
asked/PROJECT/HASH | Under a hash of what was asked (which line, change or request): when, whether sending it had begun, and whether it was sent |
turns/PROJECT | A count |
asking/HASH, renewing/HASH, acting/PROJECT, job/KIND/PROJECT | Leases: a random word for the owner, and when it lapses |
made/PROJECT | How many readings of the project have been begun: a count. Each reading carries its number, and is ordered by it |
begun/KIND/PROJECT/HASH | How many times one job (under a hash of what it is) has been begun: a count, kept an hour |
progress/PROJECT | On a copy that leaves its readings for later: how far the reading being made has got. The stage (changes, lines or hoppers), how many changes of how many, when that was written, which job it is for and a hash of whose session, and whether the reading will be everybody's. Kept ten minutes; said for forty seconds |
Locked means locked by AWS KMS with the floor's key (its own, or the one floors share), for words that tie it to this floor's address, this session or attempt, and when it began and must end (as for kept sign-ins). Locked bytes moved to another record, another floor or a later ending do not open, and a record that will not open is removed.
No token, refresh token, device code, verifier, state, cookie, client secret or AWS access is in the table in the clear, and none of them, nor anything KMS locked, is ever in a log line, an error or an answer. The tests look for every one of them in the whole table after every case.
The access token is now kept, locked. Without a store it lives only in the memory of the running copy, and a floor that keeps sign-ins keeps only the refresh token. Copies cannot share a session without sharing its token, so this is what a store changes. Decide with that in mind.
And in the kept place, as before: each project's history.json (or OWNER__REPO.history.json for one project), and beside it cost.json (OWNER__REPO.cost.json), the last cost report whole.
#What each part of a session's record is trusted for
Somebody who can write the table can change any of it. So nothing a copy acts on is taken from outside the lock unless changing it is harmless.
| Field | Where | What rests on it |
|---|---|---|
| The access token, the refresh token | Inside the lock | Everything. They open only for this floor, this session's hash, how, began and until |
| When the token lapses, and how long before that it is renewed | Inside the lock | When a copy renews. A copy takes these from what it unlocked, never from beside it |
began, until | Outside, and among the words the lock is tied to | The session's ending. KMS opens the tokens only for the very began and until they were locked for, so a changed one opens nothing and the record is removed. Once a copy has unlocked a record it compares that until with the clock on every request, and refuses and removes the session when it has passed. Every renewal locks the new pair for the same two, so the ending never moves |
how | Outside, and among the words | Which way the session is renewed. A changed one opens nothing |
The record's own time-to-live (DynamoDB's until attribute) | Outside | Nothing. It is tidying: moving it later keeps a dead record in the table and nobody signed in |
token_until beside the lock | Outside | Only the house's count: which session may give up its place when all 200 are taken. Changing it can cost somebody their place (a table writer can sign people out anyway), never give anybody anything |
login | Outside | Never believed by itself. A copy that has not seen the session asks GitHub whose the token is, and if that is not this name the session ends. Otherwise it is only what a reader of the table sees |
renewable | Outside | Nothing. It is for a reader of the table |
| The version | Outside | Whether a copy must unlock again. Changing it costs a KMS request and the door being asked afresh |
#Who can do what with it
- Somebody who can read the table and nothing else learns who is signed in (their GitHub names), how and since when, which projects are being read, and what was decided when. A caller's address is kept as a hash, but there are few enough addresses that a determined reader could try them all. They cannot sign in as anybody: no cookie is there, and every token is locked by a key they cannot use.
- Somebody who can also write the table can sign people out; fill the house so nobody can sign in, or empty it; clear a caller's count; clear the note that something was already asked for (a person would still have to press the button again, the note in the kept history still refuses it, and GitHub still decides whether it happens); hold up decisions and readings by taking leases or writing marks; and leave a job that makes a copy read GitHub as a signed-in person, spending that person's hourly allowance, with the result shown only to people already let in. They cannot make a session that opens, move one to another cookie, or give one a later ending: a session is refused and removed once the clock passes the ending its tokens were locked for, whatever its record has been made to say (below). So the table must be writable by the app alone.
- Somebody who can write the table and also holds a person's cookie can do two things more, both only until that session's own week is up. They can put back the record of a session that was signed out (they must have copied it before), and the cookie is good again: signing out removes the record, and nothing else in the table remembers it. A note of the sign-out kept in the same table would stop nothing, since whoever can put the record back can remove the note; so none is kept, and every request is spared a second read. And they can put back an older record of a session that has since been renewed: its refresh token is spent, GitHub refuses it, and the session ends for everybody a minute and a half later. Taking the note of that refusal (
refused/HASH) out of the table does not make the wait begin again on a copy that has met the refusal, which remembers when it was; on a copy that has not, it buys one more ask of GitHub and one more wait, and that copy shows nothing while it waits. If a cookie and the table may both have been taken, revoke the tokens at GitHub: that is the one thing that ends a session for certain. - Somebody who holds the copy's own role (the table, the bucket and the key) can unlock every token in the table, and so can act on GitHub as each person who is signed in, within what the GitHub App may do for them. That was already so for refresh tokens on a floor that keeps sign-ins; with a store it is so for access tokens too, with no renewal needed. Keep the role to the copies alone. Every unlocking is in AWS's record (CloudTrail), with the floor's address and the session's hash.
- AWS is trusted with the tokens: KMS is sent each one to lock it.
#The rule, and how each part keeps it
Two copies sharing one store cannot be told from one.
Signed in everywhere, signed out everywhere. Every request asks the table whether its session is there: one read. A copy remembers the unlocked token of a session it has seen, so that KMS is not asked every time, but it uses what it remembers only after the table has answered for this request that the session is there and is the same version. Signing out removes the record, so the very next request to any copy is refused. A session's end is checked against the clock on every request. A cookie that matches nothing costs one read and asks nobody else.
A copy that has not seen you asks the door afresh. Before it shows anything, it unlocks your token and asks GitHub, with your own access, what you may do on each project: exactly what a copy does after a restart. GitHub's no on every project ends the session for every copy. If GitHub will not say, that copy lets nobody in on a guess; it tries again half a minute later.
A sign-in begun on one copy is finished on another, once. The attempt is in the table. The copy the browser comes back to marks it used by compare-and-set: of two copies handed the same way back at the same instant, one signs the person in and the other says the attempt was used. Wrong states are counted in one step in the table, so the fifth spends the attempt wherever it arrives. For a code, one copy at a time asks GitHub (a lease), and no more often than GitHub said (the time of the last ask is in the table).
A refresh token is never spent twice, and a renewal that worked is never thrown away. GitHub's refresh token works once. The copy that renews takes a lease on the session (renewing/HASH, 45 seconds), looks again in case another copy has just renewed, asks GitHub, locks the new pair for the session's own first beginning and ending (so a week never grows by being renewed) and puts it in the old one's place only if the record is still the version it read. A copy that finds the lease taken waits up to four seconds for the new pair and otherwise carries on with the token it holds, which is still good for ten minutes. The lease only saves asking twice; it is not what keeps the tokens safe. A lease is a time, and a copy can stall or have a clock that is off, so two copies may both ask GitHub. GitHub answers one of them. The one it refuses reads the record again: if it has moved on, it takes the other's pair up and removes nothing. If it has not, the other copy may be holding the new pair and not yet have saved it, so the record is left alone for a minute and a half from the first such refusal (when it began is kept in the table, so it is one wait for all copies and GitHub is offered the refused token once; and in the refusing copy's own memory, so taking the note out of the table restarts nothing there). While it waits, the session opens nothing on a copy that has met the refusal: not a reading it holds, not what the door said a minute ago. The person sees the sign-in card, and is back where they were, without signing in, at their next request once the other copy's pair is kept. Only when the wait is over is the session ended, and only the version that was read is removed. Then:
| What happens | What comes of it |
|---|---|
| The copy dies before GitHub was asked | The lease lapses in 45 seconds. The next copy renews |
| The copy stalls for longer than its lease, before asking GitHub or after its answer | Another copy renews, or waits for it. Nobody is signed out, whichever finishes first |
| The copy dies after GitHub answered and before the new pair was saved | The lease lapses. The next copy offers the spent token and GitHub refuses. A minute and a half later, the record still unchanged, the session ends: the person signs in again, and nothing worse |
| GitHub answered and the table or KMS would not take the new pair | The save is tried again for about three seconds within the request, the lease taken again each time. If it still will not, that copy keeps the pair and saves it at the person's next request there. If another copy is asked first it is refused by GitHub and waits as above, which is the first copy's time to save. If that runs out, or the copy dies, the session ends for every copy alike and the person signs in again: no copy goes on alone with a pair the others do not have |
| The save was done and only its answer lost | The copy finds that what is kept opens to the pair it holds, and carries on |
| GitHub truly refuses the renewal (the person took the app's authorization away) | The session ends a minute and a half after the first refusal, not at once. Meanwhile a copy that has met the refusal (its own, or the note of another's) shows that person nothing and does not offer GitHub the token again. A copy that has not met it, and whose token is not yet due, goes on as any copy does with a token GitHub has withdrawn: GitHub refuses the token when it is next used there, and what that copy already holds (a reading, the door's last yes) can still be shown until its door is next asked, five minutes at most |
| Somebody signs out, on any copy, while a renewal is under way | The new pair has nowhere to go: nothing is brought back |
The limits are counted once. The 200 places are one thing in the table, changed by compare-and-set, so two copies cannot each let in 200. The two safe minutes and "the oldest unfinished sign-in gives up its place" are worked out from it exactly as before. Before a session is put out as "not used since its token lapsed", its own record is read: one whose token was renewed after all keeps its place, and only the version that was read is removed. A caller's five sign-ins in ten minutes are one list in the table, however many copies they come through. The list is only ever written back over the very version that was read, and an entry is left out only for being older than ten minutes by the clock of the copy that writes, never for seeming to come from the future (another copy's clock may be ahead, and a request that began later may have written first). So the count cannot leak, whatever the order things happen in: sixty at once from one address over three copies begin five.
A decision is sent once, and only in its own turn. Before anything is sent to GitHub, the copy writes down that it is being asked for, and only one copy can write that (put-if-absent): the same button pressed on two copies at the same instant is one request to GitHub and one "already asked for". Decisions are taken one at a time across all copies by a lease the deciding copy keeps taking again while it works; if it dies, the lease lapses in a minute. A decision that cannot have its turn in thirty seconds is refused, and says nothing was sent. Immediately before each request to GitHub the copy confirms the turn is still its own: it takes the lease again and checks that nobody's turn has come between. A copy that was frozen for longer than its lease, and wakes to find another decision was taken meanwhile, sends nothing and asks the person to look again and press again. Then it writes that sending is beginning, and only then sends. So a mark says one of three things, and the words a second person is shown say no more than is known. Written down, sending not begun: whoever wrote it died or was refused before anything was sent, so the next person in their own turn simply takes the mark over. Sending begun, no ending recorded (the copy died in the middle, or the answer was lost): "this may already have been asked for… it is not known whether it was sent", for a quarter of an hour, on every copy. Sent: "this was already asked for from here". Only a decision refused before anything was sent takes its mark back.
One reading, one cost report, one history. The newest reading anybody let in made is everybody's, on every copy; a reading begun before somebody decided is not. The history is one object in the bucket, as before. A copy that adds to it writes it back on the condition that nobody else wrote meanwhile (If-Match); if somebody did, it reads theirs, adds its own steps to that, and writes again. Two copies adding steps at the same instant both end up in it. (Read-change-write on a condition, and not a log to append to, because the app may only read and write an object by name: a log would need listing, and tidying.) An older reading never takes the place of a newer one another copy kept.
A copy never hands out a reading made before one it could know of. Requests reach any copy, and each copy holds the last reading it made for a person. So readings are put in order by the store, not by the copy that holds them: each is numbered as it is begun (made/PROJECT, a counter; the number is in the reading, as serial), and no copy's clock comes into which of two is the later. A copy takes its own reading for current only if it is young, nobody has decided anything since, and no later reading is everybody's. When nothing is young it hands out the later of its own and the one in the kept history, marked reading, while a newer one is made: never its own from before a decision when the kept one is from after. A later reading is never replaced, in the history or as everybody's newest, by an earlier one that happened to end after it. Whether a reading is still young is a matter of time, and is told by the clock of the copy asked: a copy whose clock is behind takes a reading for young that much longer, and no order is upset by it. A person's own reading, with what it cost them, is still theirs; and one made by somebody who may only look is still never everybody's.
Nothing happens behind the scenes that is not written down. Without a store, the copy reads GitHub in a thread behind an older reading it has handed out, and works the cost out behind an answer that says working. With one, what would be done behind the scenes is written in the table as a job (what, which project, a hash of whose session asked, when), the answer says so honestly (reading: true, working: true), and the job is done by whichever copy next has the chance: SignIns.run_jobs(). It is done as the person who asked, with their own access, if they are still signed in and still let in; otherwise it is dropped and the next person to ask leaves it again as themselves. One copy does a job at a time (a lease it keeps taking again); one that dies leaves a lease that lapses in a minute, and the job is still there. A reading that nobody has begun after ten seconds is done by the next request that wants it, within that request.
A copy that is a long-lived process (a container) calls run_jobs() itself, in a thread, as soon as a job is left. On Lambda there is no such thread: the function is run once more, for the jobs alone (below). No answer depends on either having run: the tests freeze it and have another copy do the work.
A job that was begun three times and never ended (each copy that took it died, or was cut off for taking too long) is not begun a fourth time: it is said to have failed, to the person who asked, and a person may ask again.
Fail closed where it matters, soft where it only saves. When the table cannot be asked (refused, throttled, failing, or silent for three seconds): nobody is taken to be signed in, though the copy remembers them; no sign-in is begun or finished; a sign-out that could not be done says so; a decision is refused and says nothing was sent. What is only a saving fails soft: without the shared reading each person reads for themselves, and a history that could not be kept is said once in the log and stops no reading. One person's request waiting on the table holds up nobody else. The bucket is given eight seconds; while one request waits on it for a project's history, others on the same copy who want that history wait behind it, and no longer.
#What it costs to ask
Counted against the made-up table, for one project. A read is one GetItem; a write is one PutItem, UpdateItem or DeleteItem, whether or not its condition held.
| Request | Table reads | Table writes | Bucket | KMS |
|---|---|---|---|---|
Any request from somebody signed in (/me, /projects, describe): is the session there? | 1 | 0 | ||
| …the first on a copy that has not seen them (and the door is asked: one request to GitHub for each project) | 1 | 0 | 1 | |
state or history, when somebody's reading is young | 2 | 0 | a read only when the history has changed since this copy last looked | |
An ordinary page view: /me, /projects, describe, state, history | 7 | 0 | ||
state when the reading has aged: hands out the old one and leaves a job | 4 (5 on Lambda) | 1 | ||
| …each ask while that reading is being made, on Lambda: the session, the room, how far it has got | 3 | 0 | ||
run_jobs() doing that reading (and several hundred requests to GitHub) | 8 | 6; on Lambda some 7 more, saying how far it has got: one as each stage begins and one every five seconds | 1 write | |
run_jobs() with nothing to do | 2 for each project | 0 | ||
| The first reading ever, or "Read again" | 5 | 2 | 2 reads, 1 write | |
Beginning a one-click sign-in (/signin/start), with the caller's count | 3 | 3 | 1 | |
Coming back (/signin/callback) | 3 | 7 | 2 | |
| A request that renews the token (every eight hours for each person) | 3 | 5 | 1 | |
| …the next request on another copy, which takes the new token up | 1 | 0 | 1 | |
| A decision | 10 | 9 | 1 write | |
| The same decision pressed again (refused) | 7 | 4 | ||
cost, a kept report | 2 | 0 | a read the first time on a copy | |
cost, the first ask: leaves a job, then one read a second for up to twenty seconds while it waits | 4 or more | 1 | ||
| Signing out | 1 | 3 |
house is the one thing that grows with the floor: some hundred bytes for each person signed in or signing in, twenty kilobytes with all 200 places taken, read and written whole when somebody signs in or out. Everything else is a few hundred bytes. At DynamoDB's on-demand prices a floor a team uses all day costs cents a month; AWS's own price list is the word on it.
#Where two copies can still be told from one
Nothing here makes a copy more willing than one server would be. In these places it is less, or slower, and they are written down so that nobody has to find them:
- While GitHub cannot be reached, a copy that has not seen you does not show you the floor. One server goes on showing a floor for a quarter of an hour to somebody GitHub said yes to a short while ago. That grace is each copy's own: a copy that has never asked GitHub about you has no yes to go by, and shows the sign-in card until GitHub answers. Your cookie is left alone.
- What a reading cost you is said only by the copy that made it. On another copy you are given the same reading as everybody's newest, which has no
github. - GitHub's "has this changed?" saving is each copy's own. A reading made on a copy that has not made one for you before is paid in full from your hourly allowance. The shared reading means few readings are made at all.
- Somebody who may only read has readings of their own that are never shared (why), so each copy they reach may read GitHub for them once in five minutes.
- A place can be held by nobody for a few minutes. A place taken for a session counts as its own for two minutes, until the session's record is written and says when its token lapses. A copy that dies in between leaves a place that is nobody's two minutes later, and the first to go when the house is full. A sign-out while the house could not be told leaves a place too: before a full house turns a newcomer away it looks at ten of its places, picked at random, and gives up any whose session has no record. The one case that lasts longer: a session's record written by a copy that died before the browser was given its cookie holds a place until its token lapses (eight hours at most), and then goes like any other nobody has used.
- What the copies' clocks are trusted for. Nothing that keeps a token or a decision safe rests on two copies' clocks agreeing: a renewal is saved over a version, GitHub answers one of two that ask, a refused copy takes up the other's pair, and a decision is confirmed against a count of turns before it is sent. Clocks that differ cost time, not safety. A session ends by the clock of the copy that is asked, so it may end sooner or later by the difference; a caller's ten minutes and an attempt's ten minutes likewise; a lease may be taken early or late, so GitHub may be asked to renew twice (one is refused, nobody is signed out), and a turn may be taken while its holder still works (the holder then sends nothing). Tested with copies a hundred seconds apart. Lambda's clocks are kept right by AWS to well within a second.
#What the store has been run against
Everything above is tested against a made-up DynamoDB, S3, KMS and GitHub (tests/test_store.py, test_shared_sign_ins.py, test_shared_rooms.py, test_shared_start.py), with two and three real copies of the server sharing one store, requests going to copies at random, the same request sent to several copies at the same instant many times over, copies with clocks a hundred seconds apart, copies stalled past a lease and frozen in the middle of a decision, copies killed in the middle of a renewal, a decision, a reading, a cost report and a history write, and the store refusing, failing, throttling and hanging. It has been run against AWS once: the trial floor of 3 December 2026 (below), on which one person signed in and read one project through it. That shows the requests are taken as written in the ordinary case; it shows nothing about two copies at the same instant, a refusal, or a freeze. What only AWS can confirm, and one quiet trial did not:
- That DynamoDB takes the requests as written. They are few and are in one place (
factory/store.py, under THE REQUESTS) so they can be read beside AWS's reference. Attribute names are never written into an expression, sincename,value,count,owneranduntilare among the words DynamoDB reserves; each is given a stand-in. The counter's update isADD #count :by SET #until = if_not_exists(#until, :until)with a condition, and makes the item when there is none. - That S3 keeps its conditions as documented:
If-None-Match: *andIf-Match: TAGon a write answer 412 when the condition does not hold (409 when another write of the same object is under way, treated the same), a write answers with the newETag, andIf-None-Match: TAGon a read answers 304. The app assumes an object's tag changes whenever its content does, and nothing else about it.If-Matchon a write needss3:GetObjectas well ass3:PutObject; the floor's role has both. - That DynamoDB's own removal of what has lapsed is only tidying. The app never relies on it: every read and every condition checks
untilitself. - How it behaves under real delays, real throttling, and a real freeze.
#On AWS Lambda
A floor on Lambda is the same server, built from the same settings, with a store. One function, factory/on_lambda.py, at a public address: its Lambda function URL (https://ID.lambda-url.REGION.on.aws), or an address of its own (https://floor.example.com) through an API Gateway HTTP API, and then no function URL at all. It runs for the length of a request and is frozen, or gone, between. While nobody asks, nothing runs and nothing is paid for but its share of the key the floors share.
Nothing listens, and there is one handler. Lambda hands the function one event for each request and takes one answer back. The entry writes the event out as the request it stands for and hands it to app.py's own request handler, in the same process: the very class the HTTP server runs, reading from a buffer where it would read from a connection. What it wrote is read back and handed to Lambda. No server runs inside the function, nothing is added to the app (there is no adapter and no new dependency), and there is no second copy of any route, check or header to keep in step with the first.
That the two answer the same is tested, not taken on trust (tests/test_on_lambda_same.py): the same conversations are held over HTTP with the real server and through the entry, by both fronts (as a function URL hands a request over, and as an HTTP API's $default route and stage do), each body plain and as base64, each with a world made afresh, and every answer is compared: the status, every header, every cookie, and the body byte for byte. They cover the page, every question of the API and every way each can fail, deciding and every way it is refused, signing in with a code and with one click and every way those go wrong, a hosted floor's own address, health check and limit on sign-ins, a floor with a shared store from sign-in to sign-out, HEAD and the other methods this server has no answer to, a 2.6 MB answer, a page that is not text, bodies that are not ASCII, and headers and cookies sent several at a time.
Where the two differ, all of it written down:
Date,Content-LengthandConnectionare written by whoever holds the connection: the HTTP server there, AWS here. The entry leaves them to AWS.- A header sent more than once reaches the function as one, joined by commas: AWS does that before the function sees it. The HTTP server reads the first. For a header this app compares with one value (
Origin,X-Factory) a joined one matches nothing, so the request is refused where the first alone might have passed.Sec-Fetch-Siteis the one the other way about (a joined value is notcross-site); a browser sends it once and a page cannot set it. - Cookies sent as several
Cookieheaders are all read (AWS gathers them into a list); the HTTP server reads the first header. - An answer whose body is over 4.4 MB cannot be carried by Lambda (6 MB for a whole answer, and the body goes as base64). It is answered 503, in words.
- Something the handler did not foresee is answered 500, in words, where the HTTP server would drop the connection. Only the kind of failure is logged.
- An event that could not have been a request (a path with a space or a line end in it, a header value with a line end) is answered 400 and never reaches the handler: nothing a caller sends can become a header they did not send.
- An event AWS says was sent to another address than the floor's own (
requestContext.domainName) is answered 403, and one that came by a stage or a route other than$default404, before the handler sees either (why).
Who is calling is what AWS states: requestContext.http.sourceIp. A container behind a proxy of ours believes the proxy's X-Forwarded-For; here anything in a header was, or could have been, written by the caller. So the handler built for Lambda never reads that header at all (app.handler(…, proxied=False)), not even when the address AWS states is a private one, where a proxy of ours would be. An address that cannot be read counts as one caller, as before. The limit on beginning sign-ins (five in ten minutes for each caller, counted in the table for all copies) rests on this.
Host is checked against the floor's own address exactly as before: FACTORY_HOSTED, which is https://ID.lambda-url.REGION.on.aws for a floor at its function URL and https://floor.example.com for one at an address of its own. (A custom domain through CloudFront was the other way considered, and is not built: it would leave the function URL public unless CloudFront signed its requests, Host would arrive as the URL's while the page's Origin is the custom name, and the caller would have to be taken from a header CloudFront writes. An HTTP API changes none of that: below.)
Built once, and safe to freeze. Everything is built once for each copy, from the function's environment variables, and kept for as long as the copy lives. Nothing relies on a thread running between requests, on a timer, or on a connection kept open:
A cold start does as little as it can, and nothing as the module loads. Lambda allows ten seconds for loading a function, and starts one that overruns them again at the next request, and again. So loading asks nobody anything, and the copy is built at its first event, which has the function's whole timeout. In order: (1) the code is loaded; (2) at the first event, the secret is read from Secrets Manager when one is named (5 seconds at most, tried twice if it could not be reached); (3) the table is asked once whether it is there (3 seconds at most); (4) the event is answered. That is all: at the very worst thirteen seconds, and then an answer or a 503 in words, and a copy that could not be built tries again a quarter of a minute later, not at every request. Each project's history is fetched from the bucket when that project is first asked about (8 seconds at most, inside that request; if it cannot be had the request is answered from what there is, and it is fetched at the next). Removing what an earlier floor without a store kept of sign-ins, which is two asks of the bucket, waits for the copy's first run of the jobs, where nobody is waiting for an answer.
No connection is used across a freeze. The app's calls to AWS each open their own. The one place that keeps a connection open (to GitHub, during a reading) is told at every event that the copy may have been frozen, and opens a new one.
What a copy remembers by itself (how old a reading is, when GitHub last said yes to somebody) is timed by the wall's clock, never by one that counts only while the process runs.
A copy that could not be built (a setting that cannot be, a secret that could not be read, a table that is not there) answers every request 503 and nothing else. It says why in its log once, and builds itself again at a request a quarter of a minute later.
#The sign-in secret
A container is handed the GitHub App's client secret by the platform, as an environment variable filled from Secrets Manager (FACTORY_SIGN_IN_SECRET). Lambda has no such thing: a function's environment variables are plain settings that anybody who may look at the function can read. So there is a second setting, for any hosted copy:
| Setting | What it is |
|---|---|
FACTORY_SIGN_IN_SECRET_FROM | The name or ARN of a secret in AWS Secrets Manager that holds the client secret, as plain text. The copy reads it itself, once, as it starts, with its own role (secretsmanager:GetSecretValue on that one secret), and holds it exactly as the environment's is held: in memory, never printed. (factory/secret.py: one signed https request, no AWS library.) |
FACTORY_SIGN_IN_SECRET works as it always did. Both together are refused. With neither, people sign in with a code.
If the secret cannot be read, nothing is started. A container exits and says why. A copy on Lambda answers every request 503, the page and the health check among them, and tries again a quarter of a minute later. It never comes up signing people in with a code instead (a code can be begun by one person and typed in by another: why a server has one way or the other), and never offers a click it could not finish. Nothing of the secret or of AWS's answer is ever in a log line or an error: only the one word AWS uses for the kind of refusal.
#What is left to be done later
On Lambda a request never reads GitHub for a reading or a cost report: not when the reading has aged, not the first reading of a project, not "Read again". Each is left as a job, the answer says so, and the page asks again:
| Asked | Answered at once | And then |
|---|---|---|
state or history, the reading has aged | The last reading, with reading: true, and progress once a run is at work on the new one | The page shows it at once, says when it was made ("as of 14:20 · reading again…") and how far the new one has got, asks again by itself, and takes the new one up when it lands |
| "Read again" | The last reading, with reading: true | The same |
state or history, there is no reading at all (a new floor) | 503 with reading: true, "This project is being read from GitHub for the first time here…", and progress once a run is at work | The page keeps saying "Reading today's work from GitHub. A busy project takes up to a minute…", with how far it has got beside it, and asks again by itself |
cost, none kept | working: true | The page asks again every 2 seconds |
| A reading that failed | Why, in reading_failed, beside the last reading; or 503 with why when there is none | Not tried again for five minutes, unless the person presses "Read again" |
How far a reading has got. The first reading of the trial floor's project took 25 seconds, and until now the person saw one unchanging line for all of them. The run that makes a reading now says how far it has got, and the answer that says a reading is being made carries it:
"reading": true, "progress": {"stage": "changes", "done": 12, "total": 31, "age": 3, "stale_after": 40}
- What is said. The stage:
changes(the open changes, and those that ended lately and are not settled, read a few at a time:doneoftotal), thenlines(only the release lines are still being read) andhoppers(the hoppers and the bin). The page puts it in its own words beside the line that says a reading is being made: "read 12 of 31 changes", "reading the release lines", "reading the hoppers". It shows nothing the server sent as it came: one of three stages, and whole numbers. Room is kept for the words from the first, so nothing on the page moves when they come, change or go. - What it costs.
status.gatheris handed something to tell, and tells it as it goes; the reading asks GitHub exactly what it asked before, in the same order, and is the same reading. What is told is kept as one small thing in the table,progress/PROJECT, and written a handful of times, never once for each change and never once for each request to GitHub: once as each stage begins, at most once in five seconds while a stage goes on, and once in fifteen seconds when nothing has moved. Six to eight writes for a reading of half a minute, thirty at the very most, each a few hundred bytes: at list price, less than a hundred-thousandth of a dollar a reading. Each ask the page makes while it waits reads it: one read more than before. On a long-lived copy, and without a store, nothing is told, nothing is written and nothing is read: the reading is called exactly as it always was. - A reading that died says nothing. Progress carries when it was written. It is said only beside the very job it was written for, and only for forty seconds after it was written; the answer says how old it is (
age), and the page counts on from there and takes the words away when the forty seconds are up. A run that was cut off, or whose copy died, stops writing: the page goes back to saying only that a reading is being made, never a count that has stopped. (That is what the write every fifteen seconds is for: a reading that is slow and one that is dead can be told apart.) - Who is told. Only somebody the door has let in to that project: the answer that carries it is the same answer that would carry the reading. The progress of a reading made by somebody who may write is said to everybody let in, as the reading itself will be. Somebody who may only look has readings of their own that are never shared, and how far theirs has got is said to them alone.
A returning visit. Somebody who comes back to a floor that has a kept reading is shown that reading at once, with when it was made ("as of 14:20 · reading again…"); a fresh one is left as a job; and the page takes the fresh one up by itself when it lands, with nothing pressed. The crates that are in both readings ride from where they stood to where the new one has them, as they do between steps of the history, and the floor stays where it is on the screen; nothing is swapped under somebody who is watching the history ("Back to now" then shows it). If no newer reading has come in four minutes the page stops asking and says so. Nothing reads GitHub while nobody is looking: the floor has no access of its own, and an absent person's is not used.
How often the page asks while it waits. Every ask is a request somebody pays for, so the page asks at a growing interval and for a bounded time: 2 seconds after the first answer, then 2, 3, 3, 4, 4 and so on up to 10 seconds apart, for four minutes at most. That is 8 asks for a reading of 25 seconds (which is on the page 3 seconds after it lands), and 32 if it never comes; then the page stops, and "Read again" is there.
How a job gets done. When a request has left a job in the store, the function asks Lambda, before it answers, to run this same function once more without waiting for it (the Lambda API's Invoke, invocation type Event, one signed https request), with a small event of our own, {"factory": "jobs"}. That run calls run_jobs() and ends.
- A request is never failed by it. If Lambda cannot be asked, the request is answered as it would have been. The job is still in the store, and an ask that finds it still waiting a quarter of a minute on, with no copy at work on it, asks Lambda again. Asking Lambda waits two seconds and no longer. A try that failed at once without reaching Lambda is made once more; one that was waited out, and Lambda's own no, are not.
- Jobs cannot multiply. Each has a lease: of any number of runs started for one job, one does it and the others end at once. A run that finds nothing to do asks the store twice for each project and nobody else. A run is asked for by the request that left the job, and by no other, however often the page asks while a reading takes its minute: except that a job still waiting fifteen seconds after it was left, with no copy holding its lease (looked at, not taken), is asked for once more by the ask that finds it so, since the first run plainly never began.
- Jobs cannot loop. A run of the jobs never asks for another run, whatever it leaves. Lambda itself is told not to try a failed run again, and to drop a jobs event it could not hand over within a minute.
- Jobs are bounded. A run is cut off by the function's timeout. Its lease lapses within a minute and the job is still there, so the next ask has it begun again. That is safe: a reading adds to the history only what is not there already, and a cost report takes the last one's place. A job begun three times and never ended is not begun again: it is said to have failed, and nothing reads GitHub for it until a person asks.
- Only the function can send the jobs event. A request to the function's URL is always wrapped by AWS in an event of its own shape, whatever the caller sent. Anything that is neither is refused and does nothing.
#How long a request can take
The function has one timeout, for requests and jobs alike: 300 seconds, sized for a job (a reading or a cost report of a busy project). Lambda has no shorter one for requests; what bounds a request is what it may wait for:
| Request | What it waits for | As a rule | At the very worst |
|---|---|---|---|
The page, /healthz | Nothing | Milliseconds | The same |
/api/v1/me, signed out | One read of the table, once a minute | Tens of milliseconds | 3 s (then answered without it) |
| Any request from somebody signed in | One read of the table | Tens of milliseconds | 3 s, then they are taken not to be signed in |
| …the first on a copy that has not seen them | KMS once, and GitHub once for each project (eight at a time): the door | Under a second | KMS 5 s; GitHub, when it is failing, three tries of up to 60 s for each project |
| …when their token is due (every eight hours) | GitHub's token address, once | Under a second | 30 s, plus 4 s when another copy is renewing |
projects, describe, access | One or two small questions to GitHub for each project, kept five minutes | Under a second | As the door |
state, history | Two reads of the table; the history from the bucket when it has changed | Under a tenth of a second | 3 s a read, 8 s for the bucket. Never a reading. |
cost | Two to four reads; the report from the bucket the first time | The same | The same. Never the working out. |
| A decision | The table (a lease: 30 s at most for somebody else's decision), the factory file, and what the decision itself asks of GitHub, sent once | One to three seconds | 30 s for the turn, then GitHub's 60 s for each of a handful of requests |
/signin/start | The table and KMS | A tenth of a second | 5 s |
/signin/callback | GitHub's token address, then the door | A second | 30 s, then as the door |
| A run of the jobs | Several hundred questions to GitHub | Ten seconds to a minute | The timeout: cut off, and begun again (above) |
Everything slow in that table is GitHub being slow, and is the same on a container. A later stage could give requests a short timeout of their own by running the jobs in a second function; that is two functions to keep in step, and is not done.
Five copies at most run at once (reserved concurrency), so a flood cannot run up a bill or ask more of GitHub than five copies can. When all five are busy AWS answers 429 itself; the app is not reached. (A floor at an address of its own has a second, earlier limit, its API's, and a gateway that waits 30 seconds at most: what that cuts off.) The page says that ask failed (in the browser's words, since the answer is AWS's and not the app's), and an ask the page makes by itself is made again at its next turn.
#Setting one up
hosting/aws_serverless.py sets a floor up on Lambda by one command, in the manner of hosting/aws_floor.py, whose bucket, keys, images and rules it uses. It drives the aws command you are signed in with (AWS_PROFILE and AWS_REGION choose the account and region), and docker for image. It holds no secret.
python3 hosting/aws_serverless.py image 0.74.0 # at a checkout of the commit tagged v0.74.0
python3 hosting/aws_serverless.py create shop --repo OWNER/REPO --client-id Iv23... --version 0.74.0 --plan # a dry look: asks AWS nothing
python3 hosting/aws_serverless.py create shop --repo OWNER/REPO --client-id Iv23... --version 0.74.0 [--decide] [--secret factory/shop-sign-in] [--own-key]
python3 hosting/aws_serverless.py create shop … --address https://floor.example.com --zone Z0123456789ABCDEFGHIJ # an address of its own: below
python3 hosting/aws_serverless.py switch shop --zone Z0123456789ABCDEFGHIJ [--plan] # take the address over from an always-on floor
python3 hosting/aws_serverless.py list
python3 hosting/aws_serverless.py update shop --version 0.75.0 # or --all; --decide on|off; --repo …; --secret NAME|none
python3 hosting/aws_serverless.py update shop --shared-key # or --own-key: which KMS key it locks with
python3 hosting/aws_serverless.py cost shop --days 7
python3 hosting/aws_serverless.py delete shop
The package is a container image, hosting/lambda.Dockerfile: AWS's own Python base image for Lambda, the one dependency installed by version and hash as the other image does, the app, and the handler as its command. It is built for arm64 (a fifth cheaper a second than x86; the base image and the dependency both come for it) and pushed to the same registry as the always-on image, under the version with -lambda after it. image is aws_floor.py's own code with another file and another name: only from the commit tagged for the version, only from what git has, never over an image that is there.
Why an image and not a zip file: it is the same road the other image takes, so there is one way a version becomes something that runs, one registry whose names cannot be reused, and one place a dependency is pinned. A zip would start a cold copy some tenths of a second sooner and AWS would patch its Python by itself; against that, the dependency would have to be fetched for Lambda's kind of machine on whichever machine built the zip, and the version would be a label on the function and not the name of the thing it runs. The image costs a cent or two a month to keep, for all floors together. The base image is named by its digest, and the digest in the file is not a real one yet (a row of noughts): image refuses to build until somebody has put the real one there, in a reviewed pull request. An image is not patched by AWS: move the digest now and then.
What create NAME makes. First it asks the aws command itself which version it is (why). Then it asks, and only asks, everything that can be refused: is the image there; is there already a function, a role, a key, a bucket, a table or a log group of the floor's name that this tool did not make (each stops it, with nothing made); is the key it would lock with as this tool makes a key; is the secret there. Then it makes, in this order, each only if it is not there already:
| What | The aws commands | |
|---|---|---|
| 1 | The KMS key: the one every floor here shares, found by its alias alias/factory-floors-sign-ins and made by the first floor that needs it; or, with --own-key, one of the floor's own, alias/factory-floor-NAME-sign-ins. Either is found again when never named by its tags (kms list-keys, kms list-resource-tags), and looked at before it is used (kms get-key-policy, kms list-grants, kms list-aliases) | kms create-key, kms create-alias |
| 2 | The private bucket all floors keep their folders in | s3api create-bucket, put-public-access-block, put-bucket-versioning, put-bucket-lifecycle-configuration, put-bucket-tagging |
| 3 | The floor's own table, factory-floor-NAME: paid for by the request, key name, what has lapsed removed by until | dynamodb create-table, dynamodb update-time-to-live |
| 4 | The function's log group, kept 14 days | logs create-log-group, logs put-retention-policy |
| 5 | The role factory-floor-NAME-lambda, which only Lambda may take and only for this account, with its small policies: all but the one for the key | iam create-role, iam put-role-policy × 4 or 5 |
| 6 | The function, without its address: 256 MB, 300 seconds, arm64 | lambda create-function |
| 7 | Its limits: five copies at once; a jobs event is not tried again and not kept beyond a minute | lambda put-function-concurrency, lambda put-function-event-invoke-config |
| 8 | Its address, with sign-in left to the app (NONE). Nobody can call it yet | lambda create-function-url-config |
| 9 | The role's leave to use the key, for that address and no other (lock-sign-ins). Written whole at every run, so a floor whose address has changed has its leave rewritten | iam put-role-policy |
| 10 | The address, told to the function (FACTORY_HOSTED) | lambda update-function-configuration |
| 11 | Last: leave for anybody to call the address, in two parts. The part an older aws command cannot write goes first; by itself it opens nothing | lambda add-permission × 2 |
A function only has an address once it is there, and the app must be told its address to know which requests are its own page's. So the function is made without one, and a function without one answers every request 503 and asks KMS nothing. Its leave to use the key names its address, so that is written when the address is known, and before the function is told: it never runs asking for a key it may not use. It is public only after it has been told, and never without its limit on copies. Stopped anywhere, create with the same words carries on and makes nothing twice, the key among them: a key is tagged as it is made with what it is for (and, a floor's own, with the floor it is for), and when no key answers to the alias the account's keys are looked through for one so tagged, so a run stopped between making the key and naming it is finished, by the next, with the key it made. (That look is one question for each key in the account. AWS's index of tags across services would be one question, but can be minutes behind a key only just made.) Everything is tagged project=factory.
Before the tool uses a key it did not make in that same run, it looks at the key itself, the shared key exactly as a floor's own. A name and a tag are not proof of who made a key: anybody in the account who may make keys could give one the alias or the tags, with a policy that lets them unlock what it locks. So a key found by its alias, or found unnamed by its tags, is used only if it is in this account and region, switched on, a symmetric key of your own for locking and unlocking, tagged by this tool, with the policy a new key has and nothing more (one statement, handing the key to the account itself, so that only your account's own IAM decides who may use it), and with no grant to anybody (kms get-key-policy, kms list-grants; an unnamed one must also have no alias at all, kms list-aliases, and carry the tags for exactly this purpose: the shared key's, or this floor's). A key that fails any of these is refused by name, with the reason, and nothing is changed: it is not used, and no other key is made beside it. Two unnamed keys that both pass are refused too: the tool does not choose. So leave the key's policy as it was made. Give people the use of the key, if you must, in IAM and not in the key's own policy or by a grant, or the tool will stop using it. (The same for an always-on floor.)
If Lambda will not take the role. The role's trust lets Lambda take it only for this account's functions (aws:SourceAccount). On the trial floor Lambda took the role with that condition (London, 3 December 2026), so --plain-trust was not needed; it stays for an account or a region where it is. If Lambda does not say whose function it is taking a role for, create fails at making the function, with nothing public and nothing answering, and says so: that the condition is the likely cause, and that create with the same words and --plain-trust makes the role one Lambda may take without it, carrying on with everything already made. What that gives up: with the condition, a function in somebody else's account could not be handed this role even by a mistake of AWS's own; without it, the role is still Lambda's alone to take, and only somebody who may already create functions and pass roles in this account can put it to use. It is off unless asked for, and a role is never changed from one to the other except by that flag.
The role may do exactly this, and nothing else:
| Policy | Leave |
|---|---|
keep-own-folder | s3:GetObject, s3:PutObject on NAME/* of the bucket, in this account |
share-own-table | dynamodb:GetItem, PutItem, UpdateItem, DeleteItem on its own table. It cannot scan it, change it or delete it |
lock-sign-ins | kms:Encrypt, kms:Decrypt with the one key it locks with, and only for words that name this floor's own address (below) |
run-own-jobs | lambda:InvokeFunction on itself, and no other function |
write-own-log | logs:CreateLogStream, logs:PutLogEvents in its own log group. Not AWS's broad policy for functions, and it cannot make a log group |
read-sign-in-secret | With --secret: secretsmanager:GetSecretValue on that one secret |
The table is a cache and a session store, so it has no point-in-time recovery: everything in it lapses within a week, and none of it is anything that signing in again or reading GitHub again would not bring back. It is encrypted at rest as every table is.
Memory is 256 MB unless create --memory says otherwise. Lambda gives a function processor in step with its memory and charges for memory times time. A page view is mostly waiting for the table and a reading is mostly waiting for GitHub, and waiting costs the same however much processor there is; so the least memory that runs it well is the cheapest. Nothing in the app is known to need more: it holds the page, a project's history and one reading, some tens of MB in all. Whether 256 is enough on a real floor is in the function's own log, in the REPORT line Lambda writes for every run:
Max Memory Usedwell underMemory Size: 256 MB: enough. Within some tens of MB of it, or a run that ends withRuntime.OutOfMemoryorsignal: killed: give it more.Durationof an ordinary request (not a run of the jobs) in the hundreds of milliseconds, wherecost NAMEshows an average of tens: the processor is what is short. Try 512 and see whethercostcomes out lower or higher: twice the memory is the same money only if the time halves.--secret NAMEis as for an always-on floor (how the secret is put into Secrets Manager), with one difference: the function is told the secret's name and reads it itself. The tool asks only whether the secret is there. The GitHub App's callback URL is the floor's address and/signin/callback, whichcreateprints.updatechanges the version, whether a named floor decides, its projects, its secret, or which key it locks with, and nothing else: every other setting is read from the function and sent back as it was. A secret's leave is given before the setting and taken away after it. Updating signs nobody out, since sessions are in the table: except a change of key, which signs everybody on that floor out once (below).listshows each floor's version, whether it is running (unfinished: made, and not yet public;behind: at an address of its own, finished, and the name still leads elsewhere, untilswitch;asleep: unused for weeks, and woken by the next request), whether it decides, how people sign in, whether it locks with the shared key or one of its own, its address and its projects; and then which floors share the one key.delete NAMEremoves the address, the function and the role. It leaves, and says so: the table, the floor's folder of the bucket, the key and the log group. They hold what was kept, and a key cannot be brought back. The shared key is left too, and when the floor taken away was the last that locked with it, that is said, with what the key goes on costing. Nothing is ever removed that this tool did not make.cost NAMEreads the function's own figures from CloudWatch (requests, time, how many were turned away, the table's read and write units, bytes of log, and for an address of its own the API's requests) and prints what they come to at list prices, for the days asked and as a month of the same. A shared key is one key: its dollar is divided among the floors that lock with it, and the line says among how many and which.
A project set up with Open Factory Floor's older starters on a public repository. Starters up to v0.76.0 start the gate's first status, the automatic reviewer and the leftovers from pull_request_target, and GitHub has not started that trigger on a public repository since about 2 December 2026 unless the owner allows it by an Actions policy (GitHub's note). Such a project either allows it, or moves to the newer starters, which start after a small pull_request workflow and need no policy (why there are two workflows, and how to move). The gate's run when a review record is posted was never affected, and nor is a private repository. (A floor only shows a project's factory; setting the factory up on the project is where this matters.)
What the tool will not do. It never reads a secret's value and never prints one. Every aws command it can run is one of some eighty pairs of service and command written out at the top of the file (ASKS), for fourteen services (App Runner among them, only to be looked at, by switch), and beside them aws --version, which asks the command itself and not AWS; anything else, of those services or of any other, is refused by the tool's own hand before it is run. So it cannot run a function, read or scan a table, read a log, fetch or write an object in a bucket, read a secret's value, lock or unlock with a key, or attach a policy. (hosting/aws_floor.py is held to a list of its own in the same way.) Of a function's settings it keeps the ones it gives and reads; of any other, which somebody put there by hand, it keeps the name and lets the value go, and since Lambda replaces a function's settings whole it refuses a change that would have to send them back. A function that somebody has given the secret itself, in its settings, is not touched.
A floor of the same name as an always-on one keeps its history in the same folder. That is what moving a floor from App Runner to Lambda wants. Do not run both at once: the always-on one writes the history whole, over whatever is there. It does not lock with the always-on floor's key unless it is made with --own-key (a floor's own key has the same alias under both tools); nothing is lost either way, since a floor with a store keeps its sessions in its table and takes nothing from the sign-ins an always-on floor kept.
#The aws command must be new enough
Making a function URL public takes two leaves: lambda:InvokeFunctionUrl, and lambda:InvokeFunction held to calls that come through the URL, which the aws command writes with --invoked-via-function-url. That flag needs AWS CLI 2.43 or so. On the trial an older CLI failed on it with "Unknown options", with the floor made and already answering on the first leave alone. So:
createasksaws --versiononce, before it asks AWS anything, and stops there with nothing made when the CLI is older than 2.43 (or does not say what it is), in plain words that name the version needed.- The leave that needs the flag is now given first. By itself it opens nothing, so a command that fails on it after all leaves the floor closed, and
createsays so and says which version is needed. - The tool never goes round it: by no road does it give everybody
lambda:InvokeFunctionwithout that condition.
(2.43 is this project's reading of the one failure it met, not AWS's stated figure: it is CLI_NEEDS at the top of the tool. Whether the URL would also have answered on the second leave alone, and so whether giving it first leaves the floor closed for certain, has not been run against AWS.)
#An address of its own
A floor at its function URL answers at https://ID.lambda-url.REGION.on.aws. To answer at a name of your own (https://floor.example.com, a name in a Route 53 zone of the same account), give create the address and the zone:
python3 hosting/aws_serverless.py create shop --repo OWNER/REPO --client-id Iv23... --version 0.75.0 --secret factory/shop-sign-in \
--address https://floor.example.com --zone Z0123456789ABCDEFGHIJ [--plan]
The way in is an API Gateway HTTP API, and nothing else. Such a floor has no function URL at all. Its function may be called by one thing: its own API (Lambda's resource policy, below). The API's own address (https://ID.execute-api.REGION.amazonaws.com) is switched off, so the API is reached by the custom domain alone. And the app itself answers only a request that AWS says was sent to its own address. Why an HTTP API: it hands the function an event of the same shape as a function URL's (payload format 2.0) and takes the same answer, so the entry and every check in the app are the ones that already ran; a custom domain needs only a certificate in the floor's own region and a record in the zone; and it is paid for by the request, about a dollar a million. (Not CloudFront: that would leave the function URL public, or need it signed for, and would hide who is calling behind a header.)
What create --address makes, after asking everything that can be refused (as for any floor, and also: is the zone public, and is the name in it; is there a certificate, an API or a custom domain of the floor's that this tool did not make, or not as it makes them; may anything but the floor's own API call its function; has it a function URL):
| What | The aws commands | |
|---|---|---|
| 1 | The certificate for the name, in the floor's own region, proved by DNS: the record ACM names is written to the zone (never over a record of that name that says something else), and the certificate is waited for. It is the slow part, so it is made first: stopped while it waits, nothing else has been made | acm request-certificate, route53 change-resource-record-sets, acm describe-certificate |
| 2–6 | The key, the bucket, the table, the log group and the role, as for any floor; the role's leave to use the key is held to https://floor.example.com and written before the function is made | as above |
| 7 | The function, told its address as it is made (it is known beforehand), and its limits. Nothing may call it yet | lambda create-function, put-function-concurrency, put-function-event-invoke-config |
| 8 | The HTTP API, factory-floor-NAME, with its own address switched off; one Lambda proxy integration with the function, payload format 2.0, 30 seconds; one route, $default; one stage, $default, which deploys itself and holds every request to 5 a second, 25 at once. No access log (the function's own log says what it did) | apigatewayv2 create-api, create-integration, create-route, create-stage |
| 9 | Leave for that API, and nothing else, to call the function | lambda add-permission |
| 10 | The API's custom domain for the name (regional, TLS 1.2, with the certificate), and the mapping that takes all of it to the $default stage | apigatewayv2 create-domain-name, create-api-mapping |
| 11 | Last: the name, an alias record to the custom domain's regional address. Made only if the zone has no record of the name: it is a CREATE, which Route 53 refuses if one has come meanwhile. If the name has a record already, create stops before this step: below | route53 change-resource-record-sets |
Everything is tagged project=factory, floor=NAME, address= the name and zone= the zone (the certificate, the API and its stage, the custom domain), and found again by those and by its name. Stopped anywhere, create with the same words carries on and makes nothing twice; the test cuts it short at every one of its steps. The certificate is waited for ten minutes, asked every ten seconds. ACM usually takes a few minutes once the record is in the zone, now and then half an hour. If it has not issued it by then, create stops, having made nothing public, and says so: run it again with the same words and it carries on, waiting again. If it still waits after an hour, the zone given is probably not the one the world asks about the name (compare dig NS example.com with the zone's own name servers). create … --plan prints every command of a first run, as for any floor, taking the name to have no record yet.
Who may call the function. Lambda's resource policy holds exactly one statement:
{"Sid": "FactoryFloorGateway-API-ID", "Effect": "Allow", "Principal": {"Service": "apigateway.amazonaws.com"},
"Action": "lambda:InvokeFunction", "Resource": "arn:aws:lambda:REGION:ACCOUNT:function:factory-floor-NAME",
"Condition": {"ArnLike": {"AWS:SourceArn": "arn:aws:execute-api:REGION:ACCOUNT:API-ID/*"},
"StringEquals": {"AWS:SourceAccount": "ACCOUNT"}}}
arn:aws:execute-api:REGION:ACCOUNT:API-ID/STAGE/METHOD/PATH is the ARN API Gateway invokes under; the tool holds it to the one API and lets its stage, method and path be any (/*): the API has one route and one stage anyway, and a narrower pattern that turned out not to match AWS's would leave the floor answering nothing. (The console writes API-ID/*/$default for a $default route; that is narrower, and has not been tried here.) create refuses to carry on with a function that has any other statement (a function URL's leave, a stale API's), or a function URL, and says the command that takes it away. The role's own leave to run itself (run-own-jobs) is its own, not this.
#How a request reaches the function
The entry (factory/on_lambda.py) reads an HTTP API's event as it reads a function URL's: the same as_request, the same answer, the same tests. Where the two differ, and what is done about it:
| Function URL | HTTP API, $default route and stage | Done | |
|---|---|---|---|
| The path | rawPath, as sent | rawPath, as sent. A named stage puts its name in front (/prod/api/v1/me) | Only $default is made; an event from any other stage or route is answered 404 and never reaches the app, rather than guessed at |
| Where it was sent | requestContext.domainName: ID.lambda-url.REGION.on.aws | The custom domain, floor.example.com (or ID.execute-api…, switched off) | Must be the floor's own address, or 403 before the app sees it. For an HTTP API AWS says it should equal the incoming Host header, so it is not a second witness; it fails closed because the gateway picks the custom domain, and so the API, by that name, and the app checks Host itself as well |
Host | The URL's | The custom name | Checked by the app against FACTORY_HOSTED, as always |
| Who is calling | requestContext.http.sourceIp | The same | The same: no header is ever believed |
| A header sent twice | Joined by a comma | Joined by a comma | As above |
| Cookies | In cookies, a list | In cookies, a list | Joined with ; into one Cookie header |
| The question | rawQueryString | rawQueryString (and queryStringParameters, joined, not read) | rawQueryString alone |
| The answer | statusCode, headers, cookies, body, isBase64Encoded | The same | Each Set-Cookie goes as one of cookies; the body always as base64 |
| How large an answer | 6 MB (Lambda's own limit) | 10 MB for the API, but it carries Lambda's answer, so 6 MB | The body is held to 4.4 MB, answered 503 in words beyond |
| How long | The function's timeout (300 s) | 30 seconds, then the API answers for itself | Below |
accountId, apiId | anonymous, the URL's id | The account's, the API's | Not read |
Everything the app builds on its own address uses the one configured address, FACTORY_HOSTED, and nothing read from a request: the Host it accepts, the session and attempt cookies (__Host-…, Secure, Path=/, no Domain, so they belong to floor.example.com alone), the redirect_uri sent to GitHub (https://floor.example.com/signin/callback, at both visits), the server in every word sent to KMS (which the role's leave is held to), and the name every record in the table begins with (floor.example.com|…). The tests run a floor at an address of its own through HTTP API events from one-click sign-in to sign-out, with the role's leave held to its address, and find every one of them so (tests/test_on_lambda.py, AnAddressOfItsOwn).
When the API's limit is reached (more than 5 requests a second for longer than 25 at once allow), the API answers 429 Too Many Requests itself, with a body of its own ({"message":"Too Many Requests"}); the function is not run. The page says that ask failed, in the browser's words, and an ask the page makes by itself is made again at its next turn, as when all five copies are busy. A person opening the page makes seven requests at once; a few people at once stay well within 25. One caller sending a few requests a second holds the floor at 429 for everybody: the limit is the whole API's, not each caller's, so somebody who wants to can keep everybody out for as long as they keep sending. That is the price of a bill that cannot run away; a floor that must stay open to its people despite that needs something in front of it that tells callers apart (AWS WAF, which an HTTP API does not take directly, or CloudFront), which this tool does not make. AWS calls its throttles best-effort: targets, not guaranteed ceilings. So the bound on a flood is an expectation, not a promise: at 5 a second a month of it is some 13 million requests, about $13 at the API's list price if AWS counts the ones it turns away (it does not say), and the function behind it is held to five copies whatever the API lets through.
What it costs, beyond a floor at its function URL: the API's requests, $1.00 a million (HTTP API, the first 300 million a month, a request of up to 512 kB counted once), which cost NAME adds (CloudWatch's AWS/ApiGateway Count for the API and its $default stage; --per-gateway-request sets the price). That is under half a cent a month for the quiet floor, and about ten cents for the busy one (some 103,000 requests through the API; the runs of the jobs do not go through it). The certificate costs nothing (ACM's public certificates are free), the custom domain nothing, and Route 53 does not charge for answering an alias to API Gateway, as AWS's price list has it; the zone itself is already paid for. Sent to browsers is charged as before.
#A request that takes over 30 seconds
An HTTP API waits 30 seconds for the function, and then answers the browser itself (503 Service Unavailable, with a body of its own). The function is not stopped: it runs on to the end of what it was doing, and its answer is thrown away.
Readings and cost reports never meet this limit: on Lambda they are jobs, run by a call of the function's own that does not go through the API, and a request only leaves one. An ordinary request takes well under a second (measured), and the longest any request may wait, in the ordinary course, is a few seconds. Only when GitHub, or AWS itself, is slow or failing can one of these run past 30 seconds:
| Request | When | What the person sees, and what is so |
|---|---|---|
| The first request on a copy that has not seen them (the door) | GitHub failing: up to three tries of 60 s for each project | The ask failed; the page asks again. Nothing was changed |
/signin/callback | GitHub's token address slow (it is given 30 s), then the door | The gateway's page in place of "Signed in". The sign-in may finish behind it, but the browser never gets its cookie: the attempt is spent, and they begin again. Nothing is left that opens anything (the session's record lapses unused) |
| A decision | Another decision holds the turn (30 s at most), then GitHub's 60 s for each request | The ask failed. The decision is still sent once, or refused, by the function that goes on running; its mark says which. Pressed again, it says it was already asked for. The page's watch shows it when GitHub does |
| A renewal of somebody's token | GitHub's token address slow | The ask failed; the renewal is kept as usual and the next ask is answered |
| A cold copy's first request | Secrets Manager failing (two tries of 5 s), then the table (3 s): 13 s at most | Under the limit: answered |
None of these is new to Lambda (each is as slow on an always-on floor), and none of them lets anything through: the only difference is that the browser is told sooner that it failed.
#Looking at a new floor before anybody is sent to it
When the name already has a record (an always-on floor answers there today, through App Runner), create --address never writes over it. It makes everything else, stops before the last step, and says what the record says now and how to look at the new floor directly:
NOT SWITCHED. The name floor.example.com already has a record in the zone Z…, and it was left as it is:
CNAME floor.example.com. abcdefghij.eu-west-2.awsapprunner.com (TTL 300)
The floor shop is ready behind it: everything is made but that record. …
curl --connect-to floor.example.com:443:d-abc123.execute-api.eu-west-2.amazonaws.com:443 https://floor.example.com/healthz
When it is as it should be, `switch shop --zone Z… --was abcdefghij.eu-west-2.awsapprunner.com` takes the name to it …
curl --connect-to NAME:443:TARGET:443 https://NAME/… connects to the custom domain's regional address (d-….execute-api.REGION.amazonaws.com, which create prints) and says the floor's own name in the TLS handshake and in Host, exactly as a browser will once the name leads there. That is what an HTTP API's custom domain needs: it picks the domain by the name in the handshake, so asking the regional address by its own name, or with a Host header alone, reaches nothing (or a certificate that does not match). curl --resolve NAME:443:IP https://NAME/… does the same with one of the target's addresses (dig +short d-….execute-api…), which can change. /healthz answers ok; /api/v1/me answers that nobody is signed in, and says whether signing in is by one click. list shows the floor as behind.
Signing in on it first needs the browser's machine to take the name to it, for a while: put one of the target's addresses in /etc/hosts as floor.example.com, sign in, look round, and take the line out again. Without that, GitHub sends the browser back to floor.example.com/signin/callback, which is still the always-on floor, which knows nothing of the sign-in and says it cannot be finished. (The GitHub App needs nothing new: the callback URL is the same address. Nor does the certificate: it is the new floor's own, for the same name.)
#Moving a floor from the always-on kind to Lambda
In order:
- Make the Lambda floor by the same name as the always-on one, at the same address, with the same
--repo,--client-idand--secret:create shop … --address https://floor.example.com --zone ZONE. The same name means the same folder of the bucket (shop/), so the kept history is already there, and nothing is copied. (It is a new function, table, role and API; the always-on floor's App Runner service and role are other things of the same name, and neither tool touches the other's.)createstops before the name, as above. - Look at it with
curl --connect-to …(/healthz,/api/v1/me), and, if you must, sign in on it through/etc/hosts. Do not make a reading on it unless you accept losing it: the always-on floor is still the live one, and its next reading writes the history whole over what the new floor added (below). Opening a project on the new floor leaves a reading to be made whenever the kept one is more than five minutes old, so a look round in a browser usually makes one;curlof/healthzand/api/v1/menever does. - Switch:
switch shop --zone ZONE(--planfirst shows the change and sends nothing). Below. - At once, pause the always-on floor:
python3 hosting/aws_floor.py pause shop(in the sameAWS_REGION). It is whatswitchsays last. It waits until App Runner has paused the service; the service, its address and its settings are kept, and it costs nothing for running while paused. - When you are sure, take the always-on floor away:
python3 hosting/aws_floor.py delete shop --zone ZONE. It removes its service, its role and App Runner's own proof records, and leaves the name, whose record now says something other than what App Runner said for it.
Between the switch and the pause, the two floors can overwrite each other's history. Until it is paused, the always-on floor still answers whoever reaches it: browsers whose resolver asked within the old record's TTL (five minutes as aws_floor.py writes it), and every page already open on it, which keeps asking the same floor over the connection it has until that floor stops answering. A reading made there (any reading, not only after a decision) writes the history whole, from what that floor held when it started plus its own, over whatever is there: the steps the Lambda floor added since are taken out again. The Lambda floor never takes anything out (it reads what is there and adds its steps on a condition). What can be lost is steps of the kept history, never anything on GitHub: decisions are made on GitHub, and a later reading finds them there. Pausing promptly is what keeps the history whole.
What people notice: everybody signs in again, once. Sessions are in each floor's own place (the always-on floor's in its memory, or in sign-ins.json when it keeps them; the Lambda floor's in its table), and nothing carries over. The address, the bookmark and the GitHub App stay as they were. The Lambda floor empties the always-on floor's sign-ins.json the first time its jobs run (it keeps none there itself), so if the always-on floor restarts after that, its people sign in again there too.
The kept history. Both kinds keep each project's history in the floor's folder of the one bucket, s3://factory-floor-keep-ACCOUNT/NAME/, under the same names:
| One project | Several projects | |
|---|---|---|
| The history (with the last reading, and the short history of the cost) | NAME/OWNER__REPO.history.json | NAME/owner/repo/history.json (owner and repository in small letters) |
| The last cost report (on Lambda only) | NAME/OWNER__REPO.cost.json | NAME/owner/repo/cost.json |
A Lambda floor of the same name therefore reads the always-on floor's history as it finds it, and adds to it: it does not begin a new one, and it does not replace the one there. A Lambda floor of another name has a folder of its own, and its role may read only that. To bring the history over, copy each project's object before its first visit, with your own access (the tool cannot read or write an object):
aws s3 cp s3://factory-floor-keep-ACCOUNT/OLD/example__shop.history.json s3://factory-floor-keep-ACCOUNT/NEW/example__shop.history.json
aws s3 cp s3://factory-floor-keep-ACCOUNT/OLD/example/till/history.json s3://factory-floor-keep-ACCOUNT/NEW/example/till/history.json
If the Lambda floor has already written one, the copy replaces it (what the Lambda floor had added is lost, and GitHub is read again). A cost report need not be copied: it is worked out again when somebody asks.
#switch
python3 hosting/aws_serverless.py switch shop --zone ZONE [--was VALUE] [--plan]
It replaces the one record the name has with the alias to this floor's API, in a single Route 53 change: the old record deleted and the alias made together, so the name is never without a record, and the old one is given to Route 53 exactly as it was read (its type, its TTL, its value), so that if it has changed since it was looked at, Route 53 refuses the whole change and nothing moves. --was says the value it must still hold, as create printed it. It refuses, and changes nothing, unless all of this is so:
the floor is at an address of its own, and finished behind it (its API, the leave to call it, its custom domain and mapping);
the name has exactly one record, and it is the one
hosting/aws_floor.pywrites for an always-on floor of ours: oneCNAME, with one value, no routing policy, to the App Runner service in this account and region that answers at that address (asked of App Runner itself:list-services,describe-service,describe-custom-domains, which it only looks at);or the record is already this floor's alias, and then it says so and does nothing.
and the zone given is the one the floor was made in (its
zonetag): another zone of the same name is not the one the world asks.
Afterwards it prints how to put it back, in order (pause, resume, then the one command that puts the record back exactly as it was), the command that takes the always-on floor away for good, and, last, the pause command to run now, and why:
To put it back later, in this order (the same AWS_REGION):
1. AWS_REGION=… python3 hosting/aws_floor.py pause shop (if it is not paused already: it says so, and does nothing)
2. AWS_REGION=… python3 hosting/aws_floor.py resume shop (it starts afresh and reads the history as this floor left it; it waits until it runs)
3. aws route53 change-resource-record-sets --hosted-zone-id ZONE --change-batch '{"Changes": [{"Action": "DELETE", …the alias…}, {"Action": "CREATE", …the old CNAME, exactly…}]}'
…
NOW, AT ONCE: AWS_REGION=… python3 hosting/aws_floor.py pause shop
pause and resume are hosting/aws_floor.py's: App Runner's pause-service and resume-service, each waited for (asked every 15 seconds, twenty minutes at most), only for a service of the floor's name in this region tagged project=factory, only from running (to pause) or paused (to resume); one that is so already is left alone and said; --plan prints the commands and sends none.
#Switching back
In the order switch printed, and no other:
python3 hosting/aws_floor.py pause NAME, even if you never paused it: an always-on floor that ran on unpaused through the move holds the history as it was when it started, and its first reading after the name came back would write that over everything the Lambda floor added. (Paused already: it says so and does nothing.)python3 hosting/aws_floor.py resume NAME: it starts afresh, reads the kept history as the Lambda floor left it, and waits until it runs.- The
aws route53 change-resource-record-sets …commandswitchprinted. The name leads to the always-on floor again within the alias's own time (it follows the API's address, and resolvers hold it about a minute), and people there sign in again, once.
Pages still open on the Lambda floor go on reaching it until the alias lapses for their browser, and the Lambda floor's readings add to the history without taking anything out, so nothing is lost that way round. The Lambda floor is left as it is, behind its API (list shows it behind), and switch takes the name to it again. Put the name back before you delete the Lambda floor, never after: while an always-on floor of ours still claims the address, delete of a floor the name leads to refuses, changes nothing, and prints these three steps again in full (otherwise the name would be left with no record, and the put-back command, which deletes the alias first, would fail).
delete NAME of such a floor refuses, with nothing changed, while the name leads to it and an always-on floor of ours still claims the address (above); once no always-on floor claims it, or the name leads elsewhere, it takes away, in this order: the name, only while it still leads to this floor's API (a record that says anything else is left, and said); the custom domain's mapping and the custom domain; the API (with its integration, route and stage); the function and its role; then the record that proved the name for the certificate (only if it says exactly what ACM said, and no other certificate for the same name, with a key of any kind, is in this account in this region. ACM proves a name with that one record in every region, and other regions are not looked in: delete says so, and prints the record, to be put back if a certificate for the name lives in another region); a custom domain whose API was deleted by hand goes too, with the mapping that led to it and the certificate, unless ACM says something else uses it: then both are left, and said. ACM may not let go of a certificate for a few minutes after its custom domain is gone; it is then left, costing nothing and usable by nothing, and delete again takes it. A delete cut short is finished by the next, which finds what is left by its tags. What holds what was kept is left as for any floor.
#Before the real one: a trial name, in this order
What only a real run on AWS can settle, in the order the review set out. Do it on a name nobody uses (a trial floor, a trial always-on floor at a trial name), and move the real floor only when every point has been seen:
- Update the floor at its function URL to this version first: it must still answer. A 403 "answers at its own address only", or a 400, on every request means a function URL's event is not as AWS's page says;
update --versionback undoes it. create --addresson a name with no record: how long ACM takes; thatget-apisandget-domain-namereturnTags,DisableExecuteApiEndpoint,ApiGatewayDomainNameandHostedZoneIdas read; that the floor answers (which proves the source ARN matches); thencreateagain with the same words: it must say the floor is there (which proves Lambda writes the leave in a form the tool reads back).- One real event from the function's log, compared with the stand-in:
domainName,stage,routeKey,cookies,sourceIp. - From outside:
curlthe execute-api name (it must not reach the function);curl --connect-towith the floor's name in the handshake and anotherHost(403, or nothing); a path beginning with a stage name. - One-click sign-in in a real browser through the gateway, and once with the function's concurrency briefly at zero or its secret unreadable, to see the 503 page and the reload finish the sign-in.
- That API Gateway makes a custom domain for a name an App Runner service in the same account already serves. Everything rests on this.
curl --connect-toand the/etc/hostslook before the switch. Thenswitch --plan,switch, and the printed put-back command pasted exactly as printed (the alias's DELETE, with no final dot on its target, must match what Route 53 holds), thenswitchagain.- After
switch:diguntil the alias answers; what an open tab on the always-on floor does; thatpause(hosting/aws_floor.py) leavesswitchand the put-back usable. - What the gateway answers at 30 seconds and at its limit; whether
Countincludes the 429s and whether they are charged; the real price in the region. deleteon the trial name, twice (ACM letting go of the certificate), and that the zone then holds exactly what it held before.- A plain
http://visit to the name after the switch.
#One key for every floor
A KMS key of your own costs about a dollar a month whether it is used or not, and everything else a quiet floor costs is a few cents. So the floors of an account and region share one key, alias/factory-floors-sign-ins, tagged project=factory, purpose=sign-ins and shared=floors. The first floor made without --own-key makes it; every later one finds it, looks it over as it would any key it did not just make (above), and uses it. --own-key gives a floor a key of its own, as before.
What keeps floors apart is each role's leave, not the key. The key's own policy is the one AWS gives a new key (the account itself), so that only the account's IAM decides who may use it. Each floor's role is given exactly this, as its policy lock-sign-ins:
{"Version": "2012-10-17", "Statement": [{
"Effect": "Allow",
"Action": ["kms:Encrypt", "kms:Decrypt"],
"Resource": "arn:aws:kms:REGION:ACCOUNT:key/KEY-ID",
"Condition": {"StringEquals": {"kms:EncryptionContext:server": "https://ID.lambda-url.REGION.on.aws"}}
}]}
KMS is sent a handful of plain words with everything it locks or unlocks (its encryption context), and unlocks only for the very words a thing was locked for. The app sends its own address among them, as server, in every request it makes of KMS: locking and unlocking a sign-in part-way through (the device code, or the PKCE verifier), locking a new session, unlocking a session a copy has not seen, locking a renewed pair, and its own test value (below). The address is the copy's own setting (FACTORY_HOSTED), never anything read from a record. The condition holds the role to that one value. A request whose words name another address is refused by IAM before KMS looks at what was sent; so is one that sends no words at all, since it has no server to compare. (No list of the other words the app may send is put in the policy: it would add nothing to this, and would break every floor the day the app sent one more.)
What somebody who holds one floor's role can and cannot do to another floor that shares the key:
| Unlock what the other floor locked (its sessions' tokens, were they to get hold of the locked bytes) | No. With the other floor's address in the words, IAM refuses the request (AccessDeniedException). With their own address, KMS finds the words are not the ones the bytes were locked for (InvalidCiphertextException) |
| Lock something the other floor would open | No. They can lock only for words that name their own address, and the other floor only ever asks for its own |
| Read or write the other floor's table, its folder of the bucket, or its log; run its function | No. Each role names its own table, folder, log group and function, and nothing else |
| Change, switch off or delete the key, or give anybody the use of it | No. The role may lock and unlock, and nothing else of KMS |
| Read the GitHub App's client secret | Yes, if the two floors sign in with the same GitHub App: one secret serves every floor that uses it, and each such floor's role may read it. By itself the secret signs nobody in (GitHub also wants a code it handed to that person's browser, and the floor's own half of the PKCE puzzle), but floors that belong to different customers should each have a GitHub App of their own, or sign in by code |
| Use up the account's allowance of KMS requests | Yes. KMS's limit on requests a second is the account's, shared by every floor: a floor that asked KMS very fast could slow the others' sign-ins (each floor runs five copies at most, and asks KMS only when somebody signs in, a token is renewed, or a copy first meets a session) |
| Be told apart afterwards | Yes: every lock and unlock is in AWS's record (CloudTrail) with the address in its words and the role that asked |
Somebody who can change IAM in the account can do anything to any floor, with one key or with many: that was always so.
The two refusals, and what the app makes of each. With the condition in place KMS says no in two different ways, as AWS documents them:
| KMS answers | When | What the app does |
|---|---|---|
InvalidCiphertextException (or IncorrectKeyException) | The words sent meet the condition, and are not the words the bytes were locked for, or the bytes are another key's or nobody's. This is what a record put in a floor's table by somebody else draws, and another floor's record, and one from before the floor changed keys: the app sends its own address, which IAM lets through, and the bytes were not locked for it | The record is removed. That person signs in again. Nobody else is touched |
AccessDeniedException | The words sent do not meet the condition. The app always sends its own address, so by AWS's account this can only be the role's leave being wrong for everything: not written yet, or naming an address the floor no longer has | Nobody's record is removed. People see the sign-in card until the leave is right |
DisabledException, KMSInvalidStateException and the like | The key is switched off, or marked to be deleted | The same |
A no about the key is a no for everybody, so a copy that meets one does not ask KMS again for half a minute, whoever comes. But one record's no is never taken for the key's. If the app relied on the table above being the whole truth, a single record that somehow drew "access denied" from a key in good order would hold everybody out for as long as its cookie kept being sent. So before anybody else is made to wait, the copy puts the no to the test: it locks a test value of its own for its own address and unlocks it again (two requests to KMS, at most once in half a minute). Refused too: the key cannot be used by this copy, and everybody waits, as before. Opened: the key is in good order, so the no was about that one record, and only that record waits out its half minute; it is not removed, and nobody else is held up. This is tested against a made-up role that enforces the condition as AWS documents it, and against a made-up KMS that says "access denied" of one record whatever is sent (tests/test_shared_sign_ins.py, OneKeyForManyFloors).
A floor's records are found under its address in the table, so a floor whose address changes starts with no sessions at all: nobody is signed in, and nothing stale is ever offered to KMS. Run create again with the same words and the leave is rewritten for the new address.
Moving a floor between the two.
python3 hosting/aws_serverless.py update shop --shared-key # from a key of its own to the shared one
python3 hosting/aws_serverless.py update shop --own-key # and back
For floors you name, never for --all. Everything is asked before anything is changed. The role is given leave for both keys while the function changes from one to the other, each held to the floor's address, and then for the new one alone. Everybody on that floor signs in again, once: the app names its key in every request, so what the old key locked does not open, and each kept session is dropped as its cookie comes back. The key the floor had is left, and named in what the tool prints, with what it costs (about a dollar a month) and the one command that schedules its deletion (aws kms schedule-key-deletion --key-id … --pending-window-in-days 30), for you to run when you are sure nothing else locks with it. The tool never deletes a key, the shared one included: delete of the last floor that used it leaves it and says so, and the next floor made takes it up.
A floor made before keys were shared has a key of its own and a leave with no condition. It goes on working as it is. create with the same words rewrites its leave for its address; update NAME --shared-key moves it to the shared key and saves its dollar.
One thing to know: two first floors made at the very same moment can each make a shared key. One gives it the alias; the other stops and says so, and when run again finds the first's. The second key is then left unnamed, costing a dollar a month, until you schedule its deletion (it is tagged shared=floors and has no alias).
#What a floor costs a month
How often the page asks. Nothing ticks: a page left open all day asks nothing. It asks when it is opened (seven requests: the page, me, projects, describe, access, state, history), when somebody presses a button, and in three bounded waits: while a reading is being made, every 2 seconds growing to every 10, for four minutes at most (8 asks for a reading of 25 seconds, 32 at the very most); every 2 seconds while a cost report is (60 at most); and for up to twelve minutes after a decision. An ask costs so little (a request, some hundredth of a second of the function, three reads) that none of these is worth changing: a whole wait is a few thousandths of a cent. What costs is the readings, each some tens of seconds of the function waiting on GitHub.
What a visit asks, counted. For somebody already signed in:
| Requests to the function | Runs of the jobs | |
|---|---|---|
| A first-ever visit to a floor, its first reading taking 25 seconds | 15: the page, me, projects, describe, access; state, answered "being read"; state 8 more times as the page asks again (the eighth has the reading); history | 1, of 25 seconds |
| A returning visit, the kept reading aged, the fresh one taking 25 seconds | 16: the seven that open the page, all answered at once from the kept reading; state 8 times; history | 1 |
| A returning visit within five minutes of somebody's reading | 7 | none |
| A reading that never comes | 7 and 32 more, over four minutes; then the page stops and says so | whatever was begun |
The watch after a decision is gentler on Lambda. The page watches for what was decided by asking for a new reading every half minute until it shows, for up to twelve minutes: twenty-four readings when it never shows. Where every reading is a run that is paid for, the server spaces them out: the first at once, the next no sooner than a minute after it, then two minutes, then four, and four again. With the page asking every half minute that is five readings in twelve minutes where there were twenty-four; an ask that comes sooner is given the reading there is. The price is that a decision which takes two minutes to show on GitHub is seen on the floor at about four minutes and not two and a half. A long-lived copy is as it was. (shared.WATCH_GAPS; the page is not changed.)
How it was measured. On AWS itself, on the trial floor (London, 256 MB, arm64, 3 December 2026), from the lines Lambda writes for every run:
| Measured | |
|---|---|
| A cold start | 573 ms to load and build, and 258 ms for the first request after it |
| An ordinary request | 3 to 20 ms of the function's time; under 0.2 seconds from the browser's ask to its answer |
| Memory | 87 MB at its most, of 256 |
| The first reading of the project | one run of 25 seconds |
| One person's whole first visit: signing in by code, the first reading, a look round | 32 runs of the function and 32 seconds billed in all, the reading's 25 among them: $0.0001 at list price |
So the app's own work is next to nothing, a request is as long as the two or three things it asks of AWS, and the readings are nearly all the time there is. (Before the trial this page guessed 35 ms for each thing asked of AWS and 2 seconds for a cold start. Both were several times too high.) The figures below take what was measured: at 256 MB, 6 ms for each ask of the table, the bucket or KMS and 3 ms for the app's own work, which puts an ordinary request between 3 and 20 ms; 0.83 s for a cold start; and 25 seconds for a quiet project's reading. The busy floor's 40-second reading is still a guess, and so is everything at 512 MB. cost NAME says what a floor of yours really did.
What is counted for each thing that happens (the table and bucket counts are measured, and measured again with the jobs done by runs of their own; a is the seconds one ask of AWS takes, w the app's own work in a request):
| Requests to the function | Seconds of it | Table reads | Table writes | Bucket | KMS | |
|---|---|---|---|---|---|---|
| A view of the page | 7 | 7w + 8a | 8 | 0 | ||
A reading (the ask that leaves it, the run that makes it, p asks while it is made, the history after) | 2 + p | the reading itself + 18a + w + p(3a + w) | 12 + 3p | 8, and one for each time it says how far it has got (about one for every five seconds of the reading, and two) | 1 write, 2 reads | |
| A cold start (and one ask of Secrets Manager, when a secret is named) | 0.83, as measured | 1 | 1 read | 1 | ||
| A decision | 1 | 1.5 + 20a | 10 | 9 | 1 write | |
| A sign-in (off to GitHub, and back) | 2 | 1 + 19a | 6 | 10 | 3 | |
| A token renewed (every eight hours for each person who is about) | 0.5 + 9a | 3 | 5 | 1 |
The formula, with prices P, for a floor with MB of memory:
a month = requests × P.request
+ seconds × MB/1024 × P.gb_second
+ reads × P.read + 2 × writes × P.write (a write is taken as two units: most of what is written is over 1 kB)
+ bucket writes × P.s3_write + bucket reads × P.s3_read
+ KMS requests × P.kms
+ requests × 450 bytes × P.log_gb (the three lines Lambda writes for each run)
+ views × 171 kB × P.out_gb (the page is sent whole, uncompressed, at every view)
+ other answers × their size × P.out_gb (six with each view, and p + 2 with each reading: taken here as 20 kB each.
A busy project's `state` and `history` may be several times that)
+ cold starts × P.secret_request (the secret is read once as a copy is built)
+ GB kept × the price of keeping a GB a month (the table at P.table_gb, the bucket at P.s3_gb with a fortnight of
old copies, half a month's log at P.log_kept_gb: all of it a
fraction of a cent)
+ P.key_month ÷ the floors that share the key (one key for all of them; a floor made with --own-key pays the whole of its own)
Two floors, at 256 MB:
| Quiet: three people, four looks a day each | Busy: twenty people, twenty looks a day each, twenty decisions a day | |
|---|---|---|
| Taken as | 264 views a month; every view finds the reading aged (264 readings of 25 s, 8 asks while each is made) and the function cold; 10 decisions; 12 sign-ins; 66 renewals | 8,800 views; 3,432 readings of 40 s, 11 asks while each is made (one reading every five minutes through the working day, and three after each decision); 400 cold starts; 440 decisions; 80 sign-ins; 440 renewals |
| Lambda requests | 4,522 = $0.0009 | 106,816 = $0.02 |
| Lambda time | 7,196 s = 1,799 GB-seconds = $0.02 | 140,439 s = 35,110 GB-seconds = $0.47 |
| DynamoDB reads | 12,514 = $0.002 | 231,440 = $0.03 |
| DynamoDB writes | 9,000 units = $0.006 | 137,472 units = $0.09 |
| S3 requests | 274 writes, 1,056 reads = $0.002 | 3,872 writes, 7,264 reads = $0.02 |
| KMS requests | 630 = $0.002 | 1,080 = $0.003 |
| Secrets Manager requests (one at each cold start, when a secret is named) | 528 = $0.003 | 400 = $0.002 |
| CloudWatch Logs, taken in | 2 MB = $0.001 | 48 MB = $0.02 |
| Sent to browsers: the page | 45 MB = $0.004 | 1,505 MB = $0.14 |
| Sent to browsers: every other answer, taken as 20 kB each | 84 MB = $0.008 | 1,948 MB = $0.18 |
| Kept: the table (half a MB), the history and its old copies in the bucket (some MB), a fortnight of log | $0.0003 | $0.001 |
| By use | $0.05 | $0.97 |
| Its share of the one KMS key, shared by ten floors | $0.10 | $0.10 |
| A month, sharing the key with nine other floors | $0.15 | $1.07 |
| …sharing it with ninety-nine | $0.06 | $0.98 |
…with a key of its own (--own-key, or the only floor in the account) | $1.05 | $1.97 |
| …at 512 MB instead, if a reading takes no less time for it | 2 cents more | 47 cents more |
Against this page's figures from before the trial: Lambda's time is as it was (a cold start and an ordinary request turned out several times quicker, and the quiet project's reading longer: 25 seconds where 15 were guessed); the reads, the writes and "every other answer" are larger, because the page now asks more often while a reading is made (2 seconds growing to 10, where it asked every 8) and each reading says how far it has got. Both are cents on the busy floor and tenths of a cent on the quiet one. "Every other answer" is generous: an ask while a first reading is being made is answered in a few hundred bytes, not 20 kB.
Shared by every floor in the account, and so not in a floor's column: the images' place in the registry (a quarter of a GB for each version kept, at $0.10 a GB a month: two or three cents a version), and a secret in Secrets Manager (40 cents a month for each GitHub App).
So a quiet floor costs cents a month once it shares its key, and a busy one about a dollar. What moves it, largest first:
- One KMS key for every floor, not one each. At a dollar a key a month, a key of its own was twenty times everything else a quiet floor costs, and half of a busy one's bill. Now the floors of an account share one (how, and what keeps them apart): each floor's share is a dollar divided by the number of floors, and
cost NAMEsays so. The first floor in an account still pays the whole dollar until there is a second. - Memory. Lambda's time is most of a busy floor's use, and nearly all of that time is a reading waiting for GitHub. That is why the tool gives a floor 256 MB: at 512 the busy floor is 47 cents a month dearer. The trial floor used 87 MB at its most and answered ordinary requests in 3 to 20 ms, so 256 is enough there; a much busier project is still to be seen (how to tell).
- The readings after a decision, now spaced out (above): three for a decision that shows in two minutes where there were four, which is 440 readings and about 6 cents a month on the busy floor (12 at 512 MB); and five where there were twenty-four for one that never shows.
- The page is 171 kB and is sent whole each time, with
Cache-Control: no-store. Compressed it would be about a quarter of that. A seventh of a dollar a month on a busy floor. The other answers come to somewhat more if they are 20 kB each, and would shrink the same way; the asks the page makes while a reading is being made are now the larger part of them, and each is sent the reading there is, whole. - One table for every floor saves nothing: a table paid for by the request costs nothing by being there. (The app can share one: every name in it begins with the floor's address.)
- A secret in Secrets Manager is 40 cents a month and is not in the table above: one GitHub App, and so one secret, serves every floor that signs in with it.
- AWS's free allowance is not counted. Lambda's alone (a million requests and 400,000 GB-seconds a month, for a whole account) covers several busy floors or very many quiet ones. A product with many floors in one account outgrows it.
The prices used, in US dollars, for US East (N. Virginia). They are from memory, as of December 2026. Every one needs checking against AWS's own price list for your region before it is relied on, and cost takes each as a flag:
| Price | Check at | |
|---|---|---|
| Lambda, a request | $0.20 a million | aws.amazon.com/lambda/pricing |
| Lambda, a GB-second on arm64 | $0.0000133334 (x86: $0.0000166667) | the same |
| DynamoDB on demand, a read unit (a consistent read of up to 4 kB) | $0.125 a million | aws.amazon.com/dynamodb/pricing/on-demand |
| DynamoDB on demand, a write unit (up to 1 kB) | $0.625 a million | the same |
| S3, a write; a read | $0.005 a thousand; $0.0004 a thousand | aws.amazon.com/s3/pricing |
| KMS, a request; a key | $0.03 for ten thousand; $1 a month | aws.amazon.com/kms/pricing |
| CloudWatch Logs, taken in | $0.50 a GB | aws.amazon.com/cloudwatch/pricing |
| Sent out to the internet | $0.09 a GB | aws.amazon.com/ec2/pricing/on-demand (data transfer) |
| Secrets Manager, a secret; a request | $0.40 a month; $0.05 for ten thousand | aws.amazon.com/secrets-manager/pricing |
| Kept in DynamoDB; in S3; in CloudWatch Logs | $0.25; $0.023; $0.03 a GB a month | the three pages above |
| An image kept in the registry (ECR) | $0.10 a GB a month | aws.amazon.com/ecr/pricing |
They are list prices and not a bill. The way to know what a floor really costs is to run one and ask: python3 hosting/aws_serverless.py cost NAME.
#What it has been run against
It ran on AWS itself for the first time on 3 December 2026: a trial floor for one project, in London, made by hosting/aws_serverless.py as it stood at version 0.74.0, with a key of its own. One person signed in by code, the project was read for the first time, and they looked round. Everything else on this page is tested against a made-up AWS, which is this project's account of how AWS behaves, written from AWS's documentation: tests/test_on_lambda_same.py (it answers as the HTTP server does), tests/test_on_lambda.py (who is calling, the jobs, how far a reading has got, a returning visit, the secret, a copy that cannot be built, a freeze), tests/test_secret.py, tests/test_shared_sign_ins.py (among much else, two floors sharing one key) and tests/test_hosting_serverless.py (the tool, command by command). Before a floor that matters, begin with create … --plan, which prints every command and runs none.
What the trial showed:
- Lambda took the role with its trust held to this account (
aws:SourceAccount).--plain-trustwas not needed. - A function URL answers on
lambda:InvokeFunctionUrlalone. The second leave (lambda:InvokeFunction, with--invoked-via-function-url) needs AWS CLI 2.43 or so; an older one fails with "Unknown options" (what the tool now does about it). - How long things take, and what they cost: 573 ms to start a cold copy and 258 ms for its first request; 3 to 20 ms of the function for an ordinary request, and under 0.2 seconds end to end; 87 MB of memory at its most, of 256; 25 seconds for the first reading; 32 runs and 32 seconds billed for one person's whole first visit, $0.0001 at list price (above).
- And, since a sign-in by code and a first reading went through it from end to end: that the table, the bucket and KMS take the requests those make, that the function can run itself for its jobs, and that it writes to a log group it did not make.
What has been written since the trial, and has not been run against AWS at all:
- One key for many floors. That IAM holds a role to
kms:EncryptionContext:serveras written, withStringEquals; that KMS then answersAccessDeniedExceptionfor words that do not meet it andInvalidCiphertextExceptionfor words that meet it and are not the bytes' own. Both are AWS's documented behaviour, and the app is built to be right either way (above), but neither has been watched happening. Try it on two floors that do not matter before floors of different customers share a key. - A leave that is written just before the function is told its address. The tool waits ten seconds between the two; if IAM takes longer, the first sign-ins are refused in words for half a minute and then go through.
update --shared-keyand--own-key,listandcostwith a shared key, anddeleteof the last floor that used it.aws --version: that the command saysaws-cli/2.43.1 …in the form the tool reads; and that 2.43 is the right figure.- The two leaves in their new order: whether a function URL stays closed with
lambda:InvokeFunctionalone. - How far a reading has got, and the page's new waits: the seven or so writes a reading now makes, and that a real reading's stages come in the order the page says them.
- Everything about an address of its own, and one-click sign-in on Lambda at all (the trial signed in by code). What it rests on, and how sure this project is of each:
- Taken from AWS's documentation, and the app built so that being wrong fails closed: that an HTTP API's
$defaultstage and route hand the function payload format 2.0 with the path as sent, the custom domain inrequestContext.domainNameand the caller inrequestContext.http.sourceIp, cookies incookiesand a header sent twice joined by a comma, and take the same answer as a function URL (a named stage, another route or another address is refused, so a difference there answers nothing rather than something wrong); that--disable-execute-api-endpointleaves the custom domain the only way in; that Lambda's leave forapigateway.amazonaws.comheld byAWS:SourceArntoarn:aws:execute-api:REGION:ACCOUNT:API-ID/*lets that API call the function and nothing else (if the ARN API Gateway calls under did not match, the floor would answer nothing, and say so in the API's own 500s); that an HTTP API's integration waits 30 seconds at most, and that its 10 MB is moot behind Lambda's 6. - Plain http. API Gateway serves https only (AWS's documentation says it has no plain-http endpoint), and App Runner sent
http://on tohttps://. So after the move anhttp://floor.example.combookmark is expected to stop working (the browser cannot connect) where it used to be sent on. Not confirmed from a run; point 11 of the trial below. - To be watched on a real run: how long ACM takes to issue a certificate proved in a zone of the same account; that API Gateway gives a regional custom domain to a name that an App Runner service in the same account already serves (they are separate services, and DNS decides which one a browser reaches: this is the step the whole move rests on); the regional address and zone
create-domain-nameanswers with, and that the alias to them resolves; thatcurl --connect-toreaches the floor through the custom domain before the switch; what the API answers when it cuts a request off at 30 seconds (503 is this page's reading) and when its limit is reached (429); whetherAWS/ApiGatewayCountfor an HTTP API is filed underApiIdandStageascostasks; whether API Gateway charges for requests it turned away at its limit; the alias's TTL as resolvers see it; and thatswitch's one change is taken whole, and refused whole when the old record has changed. - One-click sign-in on Lambda: the attempt cookie (
SameSite=Lax,__Host-) going out through thecookieslist and coming back on GitHub's way back through the gateway; the way back landing on a copy that has never seen the attempt (the tests do this, and a cold copy that cannot read its secret, whose page then says to load it again); and the secret read from Secrets Manager with the floor's role.
- Taken from AWS's documentation, and the app built so that being wrong fails closed: that an HTTP API's
What only AWS can confirm, beyond these and the store's own list, and one quiet trial did not:
- The shape of a function URL's event, beyond the ordinary:
as_event, in the tests, is this project's account of it. WhetherrawPatharrives with its%escapes or without is the one thing the documentation left unsure; either way the path is checked before anything is done with it. - What AWS does with the answer in every case: that a body sent as base64 always arrives byte for byte; what it does with a
Serverheader (it may rename it). - That
sourceIpis always the caller's own address, and what it is for a caller on IPv6. - That an account will set five copies aside. A new account may run too few functions at once to set any aside;
createthen stops before the function has an address, and says so. - Clocks: that the wall's clock in a copy is right after a long freeze.
- Several copies at once, a flood, real throttling, and a floor busier than one person.
- The figures
costreads: the names of CloudWatch's measures and what they are filed under.
#What comes next
- Two floors sharing one key, on AWS itself, with the list above in hand: that each role is held to its own address, and what KMS answers when it is not.
- A busier floor: several people at once, a project whose reading takes a minute, and what
costthen says. - The page sent compressed, and a lighter answer for the asks made while a reading is being made.
- An address of its own, on AWS itself: one floor that does not matter, made with
--addressin a zone of its own, looked at withcurl --connect-to, then an always-on floor's address taken over withswitchand put back, with the list above in hand. - Sharing what is still each copy's own, where it is worth it: the door's last yes (so that the grace is the same on every copy, and a new copy asks GitHub less), and GitHub's "has this changed?" answers for the shared reading.
This guide is docs/SERVERLESS.md in the repository, and this page is made from it. Something wrong or unclear? Open an issue or send a pull request. Next: The two sites.