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
| Setting | Value |
|---|---|
| Name | point-out-docs-<env> |
| Public access block | all four settings on |
| Bucket policy | s3:GetObject on every object, for the cloudfront.amazonaws.com service principal, only when AWS:SourceArn is this distribution |
| Writers | the docs deploy role is the only role this stack lets write |
Distribution
| Setting | Value |
|---|---|
| Alias | docs.<root_domain> |
| Origin | the bucket's regional domain, signed with an Origin Access Control (SigV4, always sign) |
| Default root object | index.html |
| Price class | PriceClass_100 (North America and Europe edges) |
| Viewer protocol | redirect-to-https; TLS 1.2 minimum (TLSv1.2_2021), SNI only |
| Methods | GET, HEAD, cached; compression on |
| Cache policy | managed CachingOptimized |
| Error response | S3 403 becomes 404 with /404.html |
| Certificate | ACM 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., getsindex.htmlappended. This matches thetrailingSlashstatic export ofpoint-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 a404with the site's/404.html. - IPv4 only. There is only an
Arecord and the distribution keeps IPv6 off, so the IPv4 allow-list sees every viewer's address.
Docs deploy role
| Name | github-actions-docs-role |
| Trusted identity | the account's GitHub OIDC provider, audience sts.amazonaws.com |
| Subject | repo: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:ListBucket | the docs bucket |
s3:GetObject, s3:PutObject, s3:DeleteObject | the docs bucket's objects |
cloudfront:CreateInvalidation | the 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.
- Resolve. The branch must be
stagingormain; the dispatch'sshamust be a full commit SHA. - 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'ssha; every other one at the same branch, or its default branch if it has no such branch. - Build.
sync-contentcopiesdocs/infrastructureinto the site's content anddocs/aws-iconsinto its icon pack; then the Next.js static export. The run stops if the export is missingindex.htmlor has fewer than 10 files, since an empty export would wipe the live site. - Deploy. A separate job, in the same environment, assumes
github-actions-docs-rolewith OIDC, syncsout/into the bucket with--deleteand 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.
| Resource | In | Value |
|---|---|---|
github_repository_environment.docs | point-out/docs | environment <env>; deployments from any branch |
github_actions_environment_variable.docs | point-out/docs, environment <env> | AWS_ROLE, AWS_BUCKET, DISTRIBUTION_ID |
github_actions_environment_secret.source | point-out/docs, environment <env> | <SOURCE>_DEPLOY_KEY per source, today INFRASTRUCTURE_DEPLOY_KEY |
github_repository_deploy_key.source | each source, today point-out/infrastructure | read-only key titled docs build (<env>) |
tls_private_key.source | the state | the 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).