Skip to content

feat(datastore/postgres): logical flavour#361

Merged
anshulsao merged 2 commits into
mainfrom
feat/postgres-reference-flavour
Jun 22, 2026
Merged

feat(datastore/postgres): logical flavour#361
anshulsao merged 2 commits into
mainfrom
feat/postgres-reference-flavour

Conversation

@anshulsao

@anshulsao anshulsao commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What

Adds a new logical flavour for datastore/postgres at modules/datastore/postgres/logical/1.0.

This flavour models a logical database hosted on an existing/shared PostgreSQL instance. It creates no cloud resources and declares no providers: it references an existing postgres instance and re-exposes that instance's connection outputs under the same @facets/postgres contract that aws-rds and aws-aurora emit (so consumers can't tell a logical DB from a dedicated instance).

Named logical (not reference) to avoid clashing with Facets' cross-blueprint reference concept; "logical" describes the actual use case — a logical database co-located on a shared physical instance.

How it works

  • spec.source — a spec field with x-ui-output-type: '@facets/postgres'. This resolves to the selected resource's full outputs (interfaces + attributes) injected into var.instance.spec.source. Because it's a spec field, the target is per-environment override-able — the same blueprint resource can point at different shared instances across environments (e.g. via a --flavor/override on stage).
  • spec.database_name — optional, override-only. The logical DB name to target on the shared host. When set, the reader/writer connection_string is rebuilt as postgres://<source-user>:<source-pass>@<source-host>:<source-port>/<database_name> (credentials/host/port inherited from the source; only the database segment swapped). When unset, the source connection string passes through verbatim.
  • main.tf declares no resources; outputs.tf re-emits output_interfaces.reader/writer (host, port, username, password, connection_string, secrets) and passes through output_attributes from the source.

Coverage

Because both aws-rds and aws-aurora emit @facets/postgres, this single logical flavour covers both as source instances.

Use case

Staging DB consolidation — a logical database that points at a shared physical instance. Deploy one real postgres instance, then one postgres/logical per service with source -> the shared instance and database_name -> the service's logical DB. Blueprints stay identical across environments while non-prod consolidates physical infra.

Validation

  • terraform fmt / init -backend=false / validate — clean.
  • raptor create iac-module -f modules/datastore/postgres/logical/1.0 --dry-run — all validations pass (facets.yaml, var.inputs, var.instance.spec, no provider blocks, terraform validate, output types). Trivy not installed locally so the security scan was skipped (no scan findings; nothing security-relevant — module provisions nothing).
  • Catalog updated per the New Module Checklist: README.md, index.html, and all three project-type/{aws,gcp,azure}/project-type.yml (cloud-neutral flavour, added to all). Icon already exists (icons/postgres.svg).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PKZUrLtUbJS5GuEyRA8Vd5

anshulsao and others added 2 commits June 22, 2026 11:37
…xisting postgres datastore's outputs (no resources); enables per-env DB consolidation references

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKZUrLtUbJS5GuEyRA8Vd5
'reference' clashed with Facets' cross-blueprint reference concept. 'logical'
better names the use case: a logical database hosted on an existing/shared
physical postgres instance. Renames the flavour dir, flavor field, titles,
descriptions, and catalog/README/index.html/project-type entries.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKZUrLtUbJS5GuEyRA8Vd5
@anshulsao anshulsao changed the title feat(datastore/postgres): reference flavour feat(datastore/postgres): logical flavour Jun 22, 2026
@anshulsao
anshulsao merged commit b7c9e55 into main Jun 22, 2026
@anshulsao
anshulsao deleted the feat/postgres-reference-flavour branch June 22, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant