Point-out Docs

point-out/lambda-ts is a NestJS app shipped as one container image that runs as two Lambda functions:

  • The HTTP API (dist/main.handler) at ingest.<root_domain>.
  • The job worker (dist/main.jobHandler), fed {kind, payload} messages from SQS.

The lambda-ts/ module, called once from modules.tf, holds all of it: the image registry, the CI deploy role, the functions, the job queue, the ping schedule and the API's distribution.

Architecture

Both functions run the image ECR lambda-ts:<first 7 characters of the deployed branch's head commit>, on arm64. Their roles hold only what this stack creates: their own log group, and for the worker, the job queue.

Functions

lambda-tslambda-ts-worker
Commandthe image's default, dist/main.handlerdist/main.jobHandler
Memory, timeout1024 MB, 60 s (CloudFront's origin read timeout)1024 MB, 900 s; 2048 MB of /tmp
Invoked byits function URL, behind the distributionlambda-ts-jobs: batch size 1, at most 5 at a time
Rolelambda-ts-lambda: its log grouplambda-ts-worker-lambda: its log group, the job queue
Logs/aws/lambda/lambda-ts, 14 days/aws/lambda/lambda-ts-worker, 14 days

The worker's mapping uses the ReportBatchItemFailures response type: jobHandler reports a failed job instead of throwing, and without that response type SQS would delete the failed message. As a result, the worker's Lambda Errors metric stays at zero when jobs fail; the DLQ shows the failures.

The batch size is 1 because a batch runs its jobs one after the other, and one job can take the whole 900 s.

Job queue

QueueVisibilityRetentionRedrive
lambda-ts-jobs900 s4 dayslambda-ts-jobs-dlq after 3 receives
lambda-ts-jobs-dlq14 days

Both are standard queues, encrypted with SSE-SQS. A job that keeps failing, or times out, lands in the DLQ after three tries. To run it again, move the DLQ back with SQS's own redrive (aws sqs start-message-move-task).

Ping schedule

The stack starts one thing on its own: lambda-ts/ping, an EventBridge Scheduler schedule.

  • What it sends: {"kind":"ping","payload":{"at":"<aws.scheduler.scheduled-time>"}} to lambda-ts-jobs every hour. The scheduler fills in the time.
  • What happens: the worker runs the ping job, which logs ping with that time. An hourly ping in the worker's logs shows the schedule, the queue and the worker work.
  • Role: the schedule's role, lambda-ts-scheduler, can only send to the job queue.

Every other job runs only when something sends its message to the queue (see Running a job by hand).

Placeholders

The other jobs read data stores this account does not have: OpenSearch and its rate-limited bulk queue, Redshift, Aurora, the article and FTP buckets, and the author descriptions queue. Those jobs are being reworked away from those stores. Until then:

  • Data stores: the worker gets placeholder values for them (placeholder_environment in lambda-ts/main.tf), and a job that reads one fails.
  • Ingest: INGEST_VALIDATION_ONLY is true, so POST /ingest validates records and delivers nothing.

HTTP API

SettingValue
Hostingest.<root_domain>, A and AAAA alias records to the distribution
CertificateACM in us-east-1, validated with a DNS record in the zone; replaced before it is destroyed
Distributionorigin the function URL over HTTPS (TLS 1.2), origin read timeout 60 s, PriceClass_100, IPv6 on
Cachingmanaged CachingDisabled (it is also what forwards Authorization), managed AllViewerExceptHostHeader
Headersa response headers policy adding HSTS, nosniff, X-Frame-Options: DENY and a referrer policy the app did not set

The function URL is public (authorization_type = NONE), so the app has two gates.

  • Origin secret: the distribution adds a random 64-character x-origin-secret header to every origin request, and the app gets the same value as ORIGIN_SECRET. A request without it gets a 403 before any route runs.
  • Bearer token: every route except GET / then needs Authorization: Bearer <token>. The token is an AWS IAM outbound identity federation JWT for the audience https://ingest.<root_domain>.

outbound-federation.tf turns outbound federation on for the account. Its issuer's /.well-known/jwks.json is the API's AUTH_JWKS.

Callers are listed in the module's clients (lambda-ts/clients.tf), as role name → AWS account ID:

  1. Each entry creates a role here that only that account can assume.
  2. The role can only mint tokens for the API's audience.
  3. Its ARN joins AUTHORIZED_ROLES.

The list is empty today, so no token is accepted.

Deployment

  1. Build. A push to staging (staging) or main (production) of point-out/lambda-ts runs its build-and-push-lambda.yml in the GitHub environment of the same name. The job:

    • assumes github-actions-lambda-ts-role;
    • builds .docker/prod/Dockerfile for arm64;
    • pushes the image as :<sha7> and :latest.
  2. Deploy. Every apply of this stack does the deploy. It reads the head commit of the environment's branch through the GitHub provider: main for production, otherwise the branch named after the environment. It then sets both functions' image to :<sha7>.

    Nothing in lambda-ts triggers an apply. The next apply here (a merge into this repository's staging, or apply.yml by hand) picks up whatever its branch's head is then. An apply that runs before that commit's build has pushed fails on the functions: the image does not exist yet.

The registry's tags are immutable except latest, and it keeps the last 30 images. Thirty pushes without an apply would expire the image the functions run. To roll back, revert the branch, let CI build, and apply.

lambda-ts's production.yml is off (if: false), like production here, until the production account exists.

First deploy of an environment

The functions need an image, and CI needs the registry and deploy role from this stack. So the first apply of an environment fails on the two functions (Source image …:<sha7> does not exist).

If the GitHub environment already has AWS_ROLE, AWS_REGION or AWS_ECR_REPO, the first apply also fails on each of them with 409 Already exists - Variable already exists. The previous Point-out stack set them for its own accounts (see GitHub resources).

  1. Hand the environment's variables over from the previous stack: remove them from its state (below), then delete them in point-out/lambda-ts → Settings → Environments → <env>.
  2. Apply. This creates the registry, the deploy role and the three variables; only the functions fail.
  3. Run the build of the environment's branch of point-out/lambda-ts, push or re-run. CI pushes to whatever AWS_ROLE and AWS_ECR_REPO say when it runs, so a build that ran before step 2 went to the previous account and must run again.
  4. Apply again.

The certificate validates through the zone, so the zone must already be delegated (DNS).

Deploy role

Namegithub-actions-lambda-ts-role
Trusted identitythe account's GitHub OIDC provider, audience sts.amazonaws.com
Subjectrepo:point-out/lambda-ts:environment:<env>: the name-only form, since the repository has not opted into GitHub's id-qualified subjects
ecr:GetAuthorizationToken*
Push and pull layers and imagesthe lambda-ts repository

The role can only push images. What runs is what an apply of this stack sets.

GitHub resources

Managed by the terraform-point-out App, which is installed on every repository of the organization, once per environment.

ResourceInValue
github_repository_environment.mainpoint-out/lambda-tsenvironment <env>, no branch policy
github_actions_environment_variable.mainpoint-out/lambda-ts, environment <env>AWS_ROLE, AWS_REGION, AWS_ECR_REPO
data.github_branch.deployedpoint-out/lambda-tsthe head of the environment's branch

Hand-over from the previous stack

The previous Point-out stack (the old layout of this repository, lambdas/ts/repository.tf) manages the same environments and variables of point-out/lambda-ts for its own accounts. The variable names are the same, so only one stack can own them at a time.

EnvironmentAWS_ROLE / AWS_ECR_REPO point toOwned by
staging468351713122 (this stack's staging), since 2026-11-19this stack. The previous stack still has them in its state (see below)
production418295703085 (the previous production account)the previous stack, with a custom deployment branch policy

Until the previous stack lets go, its next apply in an environment rewrites the variables to its own account, and destroying it deletes the environment. In the previous stack, remove each of these from its state without destroying them:

removed {
  from = module.lambdas.module.ts.github_repository_environment.lambda
  lifecycle { destroy = false }
}
# … and likewise github_actions_environment_variable.lambda_role, .lambda_region and .lambda_ecr_repo.

state rm on the same addresses works too. Do it for staging now. Do it for production before production's first apply here. The previous stack restricts production's environment to custom branches, and github_repository_environment.main sets no policy, so this stack's first apply would drop that restriction. Add a deployment_branch_policy to it first if production should keep one.

Running a job by hand

Send its message to the job queue (output jobs_queue_url of module.lambda_ts):

aws sqs send-message --queue-url https://sqs.eu-central-1.amazonaws.com/<account>/lambda-ts-jobs \
  --message-body '{"kind":"ping","payload":{"at":"by hand"}}'

On this page