You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: document stackSecretRef and stack connection secrets
Add documentation for the new stackSecretRef field on ProviderConfig,
including how Stack connection secrets are produced, key remapping
(oncall_api_url -> oncall_url, id -> stack_id), precedence order, and
a complete example showing the Stack -> Secret -> ProviderConfig chain.
Copy file name to clipboardExpand all lines: docs/providerconfig-secret-fields.md
+98-3Lines changed: 98 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,98 @@ The following table lists all fields that can be configured in the secret, along
53
53
| `stack_id` | Grafana Cloud stack ID (required for k6 resources) | ✅ Yes | `spec.stackId` |
54
54
| `k6_access_token` | Access token for k6 Cloud API | ❌ No | N/A |
55
55
56
+
## Stack Secret Reference
57
+
58
+
The ProviderConfig supports an optional `stackSecretRef` field that references a Kubernetes Secret produced by a `grafana_cloud_stack` resource (managed or observed) via its `writeConnectionSecretToRef`. This secret contains all the Stack's `atProvider` fields as individual keys using their Terraform attribute names.
59
+
60
+
When `stackSecretRef` is set, the secret's keys are merged into the credential map with the following key remapping applied:
61
+
62
+
| Stack secret key | Remapped to |
63
+
|------------------|-------------|
64
+
| `oncall_api_url` | `oncall_url` |
65
+
| `id` | `stack_id` |
66
+
67
+
All other keys are passed through unchanged (e.g., `url`, `fleet_management_url`, `org_id`).
68
+
69
+
### Precedence (lowest to highest)
70
+
71
+
1. **Primary credential secret** (`credentials.secretRef`) — base credentials
72
+
2. **Stack secret** (`stackSecretRef`) — overrides the primary secret
**Step 3: Reference both secrets in a ProviderConfig:**
111
+
```yaml
112
+
apiVersion: grafana.m.crossplane.io/v1beta1
113
+
kind: ProviderConfig
114
+
metadata:
115
+
name: my-stack-config
116
+
namespace: default
117
+
spec:
118
+
credentials:
119
+
source: Secret
120
+
secretRef:
121
+
name: my-stack-token
122
+
namespace: default
123
+
key: instanceCredentials
124
+
stackSecretRef:
125
+
name: my-stack-details
126
+
namespace: default
127
+
```
128
+
129
+
The ProviderConfig will read:
130
+
- `auth`and `url` from the `instanceCredentials` key in `my-stack-token`
131
+
- `oncall_url`(remapped from `oncall_api_url`), `fleet_management_url`, `org_id`, `stack_id` (remapped from `id`), and all other Stack fields from `my-stack-details`
| `id` | Stack numeric ID (remapped to `stack_id`) | `stackId` |
144
+
| `org_id` | Organization ID | `orgId` |
145
+
146
+
Additional informational keys include: `alertmanager_url`, `prometheus_url`, `logs_url`, `traces_url`, `graphite_url`, `profiles_url`, `otlp_url`, `influx_url`, `slug`, `name`, `status`, `region_slug`, and all service-specific names, statuses, and user IDs.
147
+
56
148
## Override Behavior
57
149
58
150
When a field is marked as "Overridable by ProviderConfig":
@@ -167,6 +259,9 @@ Grafana OnCall resources can be authenticated in two ways:
167
259
For more information on the Grafana Terraform provider configuration, see the [official documentation](https://registry.terraform.io/providers/grafana/grafana/latest/docs).
168
260
169
261
The implementation can be found in:
170
-
- Secret field processing: `internal/clients/grafana.go:201-235`
0 commit comments