Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e76a488
Initial commit based on https://github.com/grafana/terraform-provider…
Dasomeone Mar 13, 2026
e692656
Add rule models
Dasomeone Mar 20, 2026
4c48862
Add basic rules install & clean up code slightly
Dasomeone Mar 24, 2026
2175f83
Add config for alert disablement
Dasomeone Mar 24, 2026
e8dedc0
Fix folder UID sanitation
Dasomeone Mar 24, 2026
d979cd1
Cleanup, add support for tracking install drift, remove autoupdate pr…
Dasomeone Mar 26, 2026
70dc430
rename package
Dasomeone Mar 26, 2026
2cc0cf1
rebase cloudintegrationsapi on newer format
Dasomeone Mar 26, 2026
2089427
Delete legacy doc
Dasomeone Mar 26, 2026
ddd27bb
Rebase on plugin framework for cloud integration resource
Dasomeone Mar 26, 2026
2ccfc31
Bit more cleanup
Dasomeone Mar 26, 2026
25671c0
Commit integrationsapi testing
Dasomeone Mar 27, 2026
e8a5329
Add missing folder and dashboard locks and update logic to match
Dasomeone Mar 27, 2026
15d5c69
Add integration docs
Dasomeone Mar 27, 2026
3a88ef8
Fmt terraform files
Dasomeone Mar 27, 2026
0e3e06a
Address lint & fmt
Dasomeone Mar 27, 2026
f3630f5
Add missing access policy scope for Grafana Alerting
Dasomeone Mar 27, 2026
51376a5
Add resource catalog entry for grafana_cloud_integration
Dasomeone Mar 27, 2026
5b2990b
Merge branch 'main' into dasomeone/feat/gcloud-integrations-client
Dasomeone Mar 27, 2026
77dbdbf
Let's try aligning on dashes/underscores
Dasomeone Mar 27, 2026
ebf8f21
Simplify cloud integration configuration
Dasomeone Mar 30, 2026
7775a42
Ah the woes of linting
Dasomeone Mar 30, 2026
743ee08
Updated to use proper `CategoryCloudIntegrations` in resource_cloud_i…
Dasomeone Apr 2, 2026
7f73065
Merge branch 'main' into dasomeone/feat/gcloud-integrations-client
Dasomeone Apr 2, 2026
b35d8f1
Add Cloud Integrations to examples_test.go and fix typo in category name
Dasomeone Apr 2, 2026
854101f
Add resource_cloud_integration_test.go with basic resource management…
Dasomeone Apr 2, 2026
9394b90
Merge remote-tracking branch 'origin/dasomeone/feat/gcloud-integratio…
Dasomeone Apr 2, 2026
fe8758e
Merge branch 'main' into dasomeone/feat/gcloud-integrations-client
Dasomeone Apr 7, 2026
83b87b5
Replace rollout level int with typed value
Dasomeone Apr 7, 2026
ed33be6
Convert to typed response code check & add warn logs
Dasomeone Apr 8, 2026
2e4779f
Use OpenAPI client calls with ctx
Dasomeone Apr 8, 2026
385ff48
Keep state on failure to update
Dasomeone Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
- ./internal/resources/asserts/catalog-resource.yaml
- ./internal/resources/cloud/catalog-resource.yaml
- ./internal/resources/cloudprovider/catalog-resource.yaml
- ./internal/resources/cloudintegrations/catalog-resource.yaml
- ./internal/resources/connections/catalog-resource.yaml
- ./internal/resources/fleetmanagement/catalog-resource.yaml
- ./internal/resources/frontendo11y/catalog-resource.yaml
Expand All @@ -56,4 +57,4 @@ spec:
- ./internal/resources/k6/catalog-data-source.yaml
- ./internal/resources/oncall/catalog-data-source.yaml
- ./internal/resources/slo/catalog-data-source.yaml
- ./internal/resources/syntheticmonitoring/catalog-data-source.yaml
- ./internal/resources/syntheticmonitoring/catalog-data-source.yaml
104 changes: 104 additions & 0 deletions docs/resources/cloud_integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "grafana_cloud_integration Resource - terraform-provider-grafana"
subcategory: "Cloud Integrations"
description: |-
Manages Grafana Cloud integrations.
Official documentation https://grafana.com/docs/grafana-cloud/data-configuration/integrations/
This provider lets you manage Grafana Cloud Integrations.
Alerts can optionally be disabled.
Please note: Grafana Cloud Integrations do not support in-place upgrades, and require a teardown and reapply to resolve version drift.
As such it is recommended to have a separate TF plan for integrations to cleanly destroy them as needed.
Update, only triggered on config change, is implemented as a complete uninstall, then reinstall of the integration in question.
Required access policy scopes:
folders:readfolders:writedashboards:readdashboards:writerules:readrules:write
Based on: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/alerting-migration/#import-rules-with-grafana-alerting
Note: This resource creates folders and dashboards as part of the integration installation process, which requires additional permissions beyond the basic integration scopes.
---

# grafana_cloud_integration (Resource)

Manages Grafana Cloud integrations.

* [Official documentation](https://grafana.com/docs/grafana-cloud/data-configuration/integrations/)

This provider lets you manage Grafana Cloud Integrations.
Alerts can optionally be disabled.

Please note: Grafana Cloud Integrations do not support in-place upgrades, and require a teardown and reapply to resolve version drift.
As such it is recommended to have a separate TF plan for integrations to cleanly destroy them as needed.

Update, only triggered on config change, is implemented as a complete uninstall, then reinstall of the integration in question.

Required access policy scopes:

* folders:read
* folders:write
* dashboards:read
* dashboards:write
* rules:read
* rules:write

Based on: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/alerting-migration/#import-rules-with-grafana-alerting

**Note:** This resource creates folders and dashboards as part of the integration installation process, which requires additional permissions beyond the basic integration scopes.

## Example Usage

```terraform
# install linux-node integration
resource "grafana_cloud_integration" "linux-node" {
slug = "linux-node"
}

# install kafka integration w. alerts disabled
resource "grafana_cloud_integration" "kafka" {
slug = "kafka"
alerts_enabled = false
}

# Output info
output "linux_node_integration" {
value = {
name = grafana_cloud_integration.linux-node.name
latest_version = grafana_cloud_integration.linux-node.latest_version
installed_version = grafana_cloud_integration.linux-node.installed_version
dashboard_folder = grafana_cloud_integration.linux-node.dashboard_folder
}
}
output "kafka_integration" {
value = {
name = grafana_cloud_integration.kafka.name
latest_version = grafana_cloud_integration.kafka.latest_version
installed_version = grafana_cloud_integration.kafka.installed_version
dashboard_folder = grafana_cloud_integration.kafka.dashboard_folder
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `slug` (String) The slug of the integration to install (e.g., 'docker', 'linux-node').

### Optional

- `alerts_enabled` (Boolean) Whether alerts are enabled for this integration.

### Read-Only

- `dashboard_folder` (String) The dashboard folder associated with this integration.
- `id` (String) The Terraform resource ID. Set to the integration slug.
- `installed_version` (String) The version of the installed integration.
- `latest_version` (String) The latest version available for this integration.
- `name` (String) The display name of the integration.

## Import

Import is supported using the following syntax:

```shell
terraform import grafana_cloud_integration.name "{{ slug }}"
```
1 change: 1 addition & 0 deletions examples/resources/grafana_cloud_integration/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import grafana_cloud_integration.name "{{ slug }}"
28 changes: 28 additions & 0 deletions examples/resources/grafana_cloud_integration/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# install linux-node integration
resource "grafana_cloud_integration" "linux-node" {
slug = "linux-node"
}

# install kafka integration w. alerts disabled
resource "grafana_cloud_integration" "kafka" {
slug = "kafka"
alerts_enabled = false
}

# Output info
output "linux_node_integration" {
value = {
name = grafana_cloud_integration.linux-node.name
latest_version = grafana_cloud_integration.linux-node.latest_version
installed_version = grafana_cloud_integration.linux-node.installed_version
dashboard_folder = grafana_cloud_integration.linux-node.dashboard_folder
}
}
output "kafka_integration" {
value = {
name = grafana_cloud_integration.kafka.name
latest_version = grafana_cloud_integration.kafka.latest_version
installed_version = grafana_cloud_integration.kafka.installed_version
dashboard_folder = grafana_cloud_integration.kafka.dashboard_folder
}
}
36 changes: 26 additions & 10 deletions internal/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/grafana/terraform-provider-grafana/v4/internal/common/cloudintegrationsapi"
"github.com/grafana/terraform-provider-grafana/v4/internal/common/cloudproviderapi"
"github.com/grafana/terraform-provider-grafana/v4/internal/common/connectionsapi"
"github.com/grafana/terraform-provider-grafana/v4/internal/common/fleetmanagementapi"
Expand All @@ -36,16 +37,17 @@ type Client struct {
GrafanaOrgID int64
GrafanaStackID int64

GrafanaCloudAPI *gcom.APIClient
SMAPI *SMAPI.Client
MLAPI *mlapi.Client
OnCallClient *onCallAPI.Client
SLOClient *slo.APIClient
CloudProviderAPI *cloudproviderapi.Client
ConnectionsAPIClient *connectionsapi.Client
FleetManagementClient *fleetmanagementapi.Client
FrontendO11yAPIClient *frontendo11yapi.Client
AssertsAPIClient *assertsapi.APIClient
GrafanaCloudAPI *gcom.APIClient
SMAPI *SMAPI.Client
MLAPI *mlapi.Client
OnCallClient *onCallAPI.Client
SLOClient *slo.APIClient
CloudIntegrationsAPIClient *cloudintegrationsapi.Client
CloudProviderAPI *cloudproviderapi.Client
ConnectionsAPIClient *connectionsapi.Client
FleetManagementClient *fleetmanagementapi.Client
FrontendO11yAPIClient *frontendo11yapi.Client
AssertsAPIClient *assertsapi.APIClient

K6APIClient *k6.APIClient
K6APIConfig *k6providerapi.K6APIConfig
Expand Down Expand Up @@ -82,6 +84,13 @@ func WithFolderMutex[T schema.CreateContextFunc | schema.ReadContextFunc | schem
}
}

// WithFolderLock runs f while holding the folder mutex. Used by Plugin Framework resources that need to serialize folder API calls.
func (c *Client) WithFolderLock(f func()) {
c.folderMutex.Lock()
defer c.folderMutex.Unlock()
f()
}

// WithDashboardMutex is a helper function that wraps a CRUD Terraform function with a mutex.
func WithDashboardMutex[T schema.CreateContextFunc | schema.ReadContextFunc | schema.UpdateContextFunc | schema.DeleteContextFunc](f T) T {
return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
Expand All @@ -92,6 +101,13 @@ func WithDashboardMutex[T schema.CreateContextFunc | schema.ReadContextFunc | sc
}
}

// WithDashboardLock runs f while holding the dashboard mutex. Used by Plugin Framework resources that need to serialize dashboard API calls.
func (c *Client) WithDashboardLock(f func()) {
c.dashboardMutex.Lock()
defer c.dashboardMutex.Unlock()
f()
}

func (c *Client) GrafanaSubpath(path string) string {
path = strings.TrimPrefix(path, c.GrafanaAPIURLParsed.Path)
return c.GrafanaAPIURLParsed.JoinPath(path).String()
Expand Down
Loading
Loading