Skip to content

Commit 5ce366e

Browse files
anshulsaoclaude
andauthored
feat(datastore/redis): logical flavour (#360)
* feat(datastore/redis): add reference flavour — passthrough of an existing redis datastore's outputs (no resources) Adds modules/datastore/redis/reference/1.0, a reference (passthrough) flavour for the redis intent. It provisions no cloud resource and requires no providers; it re-exposes the @facets/redis outputs of an existing redis datastore (resolved into var.instance.spec.source via the `x-ui-output-type: @facets/redis` spec field) as a separate logical resource. An optional db_index targets a distinct logical Redis DB on a shared physical instance and is reflected into the emitted connection_string. Use case: staging consolidation — a logical cache pointing at a shared physical instance/db-index. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PKZUrLtUbJS5GuEyRA8Vd5 * refactor(datastore/redis): rename reference flavour to logical "reference" clashes with Facets' cross-blueprint reference concept. "logical" better describes the use case: a logical redis datastore hosted on a shared/existing physical instance (optional db_index), re-exposing its connection outputs with no resources created. Renames modules/datastore/redis/reference -> .../logical and updates the flavor field, titles, and descriptions accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PKZUrLtUbJS5GuEyRA8Vd5 --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 080c81f commit 5ce366e

5 files changed

Lines changed: 159 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
intent: redis
2+
flavor: logical
3+
version: '1.0'
4+
clouds:
5+
- aws
6+
- gcp
7+
- azure
8+
description: Logical — a logical redis datastore hosted on an existing/shared instance
9+
(optional db_index); re-exposes its connection outputs (no resources created). Useful
10+
for staging consolidation where a logical cache points at a shared physical instance,
11+
optionally on a separate logical DB index.
12+
intentDetails:
13+
type: Datastores
14+
description: Logical redis datastore hosted on an existing/shared instance (no resources
15+
created)
16+
displayName: Redis
17+
iconUrl: https://raw.githubusercontent.com/Facets-cloud/facets-modules-redesign/main/icons/redis.svg
18+
spec:
19+
title: Redis Logical (Shared Instance)
20+
description: Logical — a logical redis datastore hosted on an existing/shared instance
21+
(optional db_index); re-exposes its connection outputs (no resources created).
22+
Select a source Redis resource whose full outputs are resolved into this resource;
23+
optionally target a different logical DB index on the shared instance.
24+
type: object
25+
x-ui-order:
26+
- source
27+
- db_index
28+
properties:
29+
source:
30+
type: object
31+
title: Source Redis Datastore
32+
description: The existing Redis datastore whose outputs this reference re-exposes.
33+
Resolves to the selected resource's full outputs.
34+
x-ui-output-type: '@facets/redis'
35+
db_index:
36+
type: number
37+
title: Logical DB Index
38+
description: Redis logical database index to target on the shared instance. Use
39+
a distinct index to separate this logical cache from others sharing the same
40+
physical instance.
41+
minimum: 0
42+
maximum: 15
43+
default: 0
44+
required:
45+
- source
46+
inputs: {}
47+
outputs:
48+
default:
49+
type: '@facets/redis'
50+
title: Redis Reference (Passthrough)
51+
iac:
52+
validated_files:
53+
- main.tf
54+
- variables.tf
55+
- locals.tf
56+
- outputs.tf
57+
sample:
58+
kind: redis
59+
flavor: logical
60+
version: '1.0'
61+
disabled: true
62+
spec:
63+
source: {}
64+
db_index: 0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
locals {
2+
# Full outputs of the selected source @facets/redis datastore, resolved into
3+
# var.instance.spec.source via the `x-ui-output-type: @facets/redis` spec field.
4+
source_cluster = lookup(lookup(var.instance.spec.source, "interfaces", {}), "cluster", {})
5+
6+
source_endpoint = lookup(local.source_cluster, "endpoint", null)
7+
source_connection_string = lookup(local.source_cluster, "connection_string", null)
8+
source_auth_token = lookup(local.source_cluster, "auth_token", null)
9+
source_port = lookup(local.source_cluster, "port", null)
10+
source_secrets = lookup(local.source_cluster, "secrets", [])
11+
12+
db_index = lookup(var.instance.spec, "db_index", 0)
13+
14+
# Reflect the logical DB index in the connection string. The source
15+
# @facets/redis connection_string has the form redis://:<auth>@<host>:<port>
16+
# (no DB path), so we append /<db_index> to target the logical DB. If the
17+
# source did not expose a connection_string, leave it null.
18+
connection_string = local.source_connection_string == null ? null : "${local.source_connection_string}/${local.db_index}"
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
}
4+
5+
# Reference (passthrough) flavour.
6+
#
7+
# This module deliberately declares NO resources and requires NO providers.
8+
# It simply re-exposes the outputs of an existing Redis datastore (resolved
9+
# into var.instance.spec.source via the `x-ui-output-type: @facets/redis`
10+
# spec field) as a separate logical resource. See locals.tf / outputs.tf for
11+
# the passthrough wiring.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
locals {
2+
output_attributes = {}
3+
4+
# Pure passthrough of the source Redis datastore's @facets/redis interface,
5+
# with db_index reflected into the connection_string. No resources are created.
6+
output_interfaces = {
7+
cluster = {
8+
endpoint = local.source_endpoint
9+
connection_string = local.connection_string
10+
auth_token = local.source_auth_token
11+
port = local.source_port
12+
secrets = local.source_secrets
13+
}
14+
}
15+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
variable "instance" {
2+
description = "Logical Redis datastore hosted on an existing/shared instance — re-exposes an existing Redis datastore's outputs without provisioning any resource"
3+
type = object({
4+
kind = string
5+
flavor = string
6+
version = string
7+
spec = object({
8+
# Resolved full outputs of the selected source @facets/redis datastore.
9+
source = object({
10+
attributes = optional(object({}), {})
11+
interfaces = optional(object({
12+
cluster = optional(object({
13+
endpoint = optional(string)
14+
connection_string = optional(string)
15+
auth_token = optional(string)
16+
port = optional(string)
17+
secrets = optional(list(string), [])
18+
}), {})
19+
}), {})
20+
})
21+
# Logical Redis DB index to target on the shared instance.
22+
db_index = optional(number, 0)
23+
})
24+
})
25+
26+
validation {
27+
condition = lookup(var.instance.spec, "db_index", 0) >= 0 && lookup(var.instance.spec, "db_index", 0) <= 15
28+
error_message = "db_index must be between 0 and 15"
29+
}
30+
}
31+
32+
variable "instance_name" {
33+
description = "The architectural name for the resource as added in the Facets blueprint designer."
34+
type = string
35+
}
36+
37+
variable "environment" {
38+
description = "An object containing details about the environment."
39+
type = object({
40+
name = string
41+
unique_name = string
42+
cloud_tags = map(string)
43+
})
44+
}
45+
46+
variable "inputs" {
47+
description = "A map of inputs requested by the module developer. This reference flavour requires no inputs."
48+
type = object({})
49+
default = {}
50+
}

0 commit comments

Comments
 (0)