Point-out Docs

The docs-site/ module serves the static export of point-out/docs at docs.<root_domain>. It is called once from modules.tf with the environment's domain, zone, allow-list and the repositories the docs are built from.

Architecture

The bucket is in eu-central-1. The certificate is in us-east-1, the only region CloudFront takes certificates from. The alias and validation records go in the environment's hosted zone.

Bucket

SettingValue
Namepoint-out-docs-<env>
Public access blockall four settings on
Bucket policys3:GetObject on every object, for the cloudfront.amazonaws.com service principal, only when AWS:SourceArn is this distribution
Writersthe docs deploy role is the only role this stack lets write

Distribution

SettingValue
Aliasdocs.<root_domain>
Originthe bucket's regional domain, signed with an Origin Access Control (SigV4, always sign)
Default root objectindex.html
Price classPriceClass_100 (North America and Europe edges)
Viewer protocolredirect-to-https; TLS 1.2 minimum (TLSv1.2_2021), SNI only
MethodsGET, HEAD, cached; compression on
Cache policymanaged CachingOptimized
Error responseS3 403 becomes 404 with /404.html
CertificateACM in us-east-1, validated with a DNS record; replaced before it is destroyed

Checkov rules skipped inline on the distribution, each with its reason in the code: no access logs (CKV_AWS_86), no WAF since the function limits access (CKV_AWS_68), a single origin (CKV_AWS_310) and no geo restriction (CKV_AWS_374).

Request flow

docs-site/viewer-request.js.tftpl runs on every viewer request. CloudFront allows one function per event type, so the allow-list and the directory index share it. OpenTofu renders docs_allowed_ips into the function's code: both environments allow 193.194.19.225, and an empty list makes the docs public.

  • Directory index. An S3 REST origin resolves no index document below the root, so a path ending in /, or whose last segment has no ., gets index.html appended. This matches the trailingSlash static export of point-out/docs.
  • Missing pages. CloudFront may only read objects, not list the bucket, so S3 answers an unknown key with 403; the distribution turns that into a 404 with the site's /404.html.
  • IPv4 only. There is only an A record and the distribution keeps IPv6 off, so the IPv4 allow-list sees every viewer's address.

Docs deploy role

Namegithub-actions-docs-role
Trusted identitythe account's GitHub OIDC provider, audience sts.amazonaws.com
Subjectrepo:point-out@202773853/docs@1461624979:environment:<env>: jobs of point-out/docs in the environment's GitHub environment, by organization and repository ID, so a renamed or recreated repository doesn't match
s3:ListBucketthe docs bucket
s3:GetObject, s3:PutObject, s3:DeleteObjectthe docs bucket's objects
cloudfront:CreateInvalidationthe docs distribution

Deployment

The resources above, AWS and GitHub alike, are applied by the OpenTofu pipeline. The site's content is built and published by point-out/docs from the docs/ folders of its sources (today only point-out/infrastructure).

A docs build

build-and-deploy.yml starts from a source-updated repository dispatch with { branch, repository, sha }, sent through the GitHub API, or by hand (workflow_dispatch) with a branch to build. The docs branch picks the environment: staging deploys to staging, main to production.

  1. Resolve. The branch must be staging or main; the dispatch's sha must be a full commit SHA.
  2. Fetch. In the environment's job, each source is fetched over SSH with its read-only deploy key, as a depth-1 sparse checkout of docs/. The source that changed is fetched at the dispatch's sha; every other one at the same branch, or its default branch if it has no such branch.
  3. Build. sync-content copies docs/infrastructure into the site's content and docs/aws-icons into its icon pack; then the Next.js static export. The run stops if the export is missing index.html or has fewer than 10 files, since an empty export would wipe the live site.
  4. Deploy. A separate job, in the same environment, assumes github-actions-docs-role with OIDC, syncs out/ into the bucket with --delete and invalidates /*. Runs for the same branch queue (cancel-in-progress: false).

GitHub resources

The module creates these as the terraform-point-out App, once per environment.

ResourceInValue
github_repository_environment.docspoint-out/docsenvironment <env>; deployments from any branch
github_actions_environment_variable.docspoint-out/docs, environment <env>AWS_ROLE, AWS_BUCKET, DISTRIBUTION_ID
github_actions_environment_secret.sourcepoint-out/docs, environment <env><SOURCE>_DEPLOY_KEY per source, today INFRASTRUCTURE_DEPLOY_KEY
github_repository_deploy_key.sourceeach source, today point-out/infrastructureread-only key titled docs build (<env>)
tls_private_key.sourcethe statethe ED25519 key pair behind each deploy key

The environment has no deployment branch policy: a run from any branch of point-out/docs gets its secrets and the deploy role.

The production docs build needs the production environment on point-out/docs, which only exists once the stack is applied to production.

Adding a source

List the repository in the module's sources in modules.tf: the next apply creates its deploy key and secret. The rest of the steps are in point-out/docs (docs/adding-a-source.md).

On this page