diff --git a/docs/resources/custom_dashboard.md b/docs/resources/custom_dashboard.md
deleted file mode 100644
index 9d834d5a2..000000000
--- a/docs/resources/custom_dashboard.md
+++ /dev/null
@@ -1,342 +0,0 @@
----
-layout: "fastly"
-page_title: "Fastly: custom_dashboard"
-sidebar_current: "docs-fastly-resource-custom_dashboard"
-description: |-
- Provides a Custom Dashboard which can be viewed in the Fastly Web UI.
----
-
-# fastly_custom_dashboard
-
-Provides a Custom Dashboard which can be viewed in the Fastly Web UI.
-
-## Example Usage
-
-```terraform
-resource "fastly_custom_dashboard" "example" {
- name = "Example Custom Dashboard"
- description = "This is an example custom dashboard. A few dashboard items are provided to help you get started."
-
- dashboard_item {
- title = "Total Requests"
- subtitle = "Number of requests processed."
-
- data_source {
- type = "stats.edge"
- config = {
- metrics = ["requests"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Hit Ratio"
- subtitle = "Ratio of requests served from Fastly."
-
- data_source {
- type = "stats.edge"
- config {
- metrics = ["hit_ratio"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "percent"
- plot_type = "donut"
- calculation_method = "latest"
- }
- }
- }
-
- dashboard_item {
- title = "Client & Server Errors"
- subtitle = "Total errors served from the client or server."
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "status_4xx",
- "status_5xx"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "bar"
- }
- }
- }
-
- dashboard_item {
- title = "Domains Requests"
- subtitle = "Requests by Domain."
- span = 6
-
- data_source {
- type = "stats.domain"
- config {
- metrics = ["requests"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Origin Responses"
- subtitle = "Responses by Origin."
- span = 6
-
- data_source {
- type = "stats.origin"
- config {
- metrics = ["all_responses"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Total Bandwidth"
- subtitle = "Total bandwidth served."
- span = 12
-
- data_source {
- type = "stats.edge"
- config {
- metrics = ["bandwidth"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "bytes"
- plot_type = "bar"
- }
- }
- }
-
- dashboard_item {
- title = "Products - Image Optimizer & Real-Time Log Streaming"
- subtitle = "Total IO images served and log statements sent."
- span = 8
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "imgopto",
- "log"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Transport Protocols & Security"
- subtitle = "HTTP Protocols & TLS."
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "http1",
- "http2",
- "http3",
- "tls_v10",
- "tls_v11",
- "tls_v12",
- "tls_v13"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Origin Miss Latency"
- subtitle = "Miss latency times for your origins."
- span = 12
-
- data_source {
- type = "stats.edge"
- config {
- metrics = ["origin_latency"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "milliseconds"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "DDOS - Request Flood Attempts"
- subtitle = "Number of connections the limit-streams action was applied."
- span = 6
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "ddos_action_limit_streams_connections",
- "ddos_action_limit_streams_requests"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "DDOS - Malicious Bot Attack"
- subtitle = "Number of times the blackhole action was taken."
- span = 6
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "ddos_action_close",
- "ddos_action_blackhole"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "number"
- plot_type = "line"
- }
- }
- }
-
-}
-```
-
-## Import
-
-Fastly Custom Dashboards can be imported using their ID, e.g.
-
-```sh
-$ terraform import fastly_custom_dashboard.example xxxxxxxxxxxxxxxxxxxx
-```
-
-
-## Schema
-
-### Required
-
-- `name` (String) A human-readable name.
-
-### Optional
-
-- `dashboard_item` (Block List, Max: 100) A list of dashboard items. (see [below for nested schema](#nestedblock--dashboard_item))
-- `description` (String) A short description of the dashboard.
-
-### Read-Only
-
-- `id` (String) Dashboard identifier (UUID).
-
-
-### Nested Schema for `dashboard_item`
-
-Required:
-
-- `data_source` (Block List, Min: 1, Max: 1) An object which describes the data to display. (see [below for nested schema](#nestedblock--dashboard_item--data_source))
-- `subtitle` (String) A human-readable subtitle for the dashboard item. Often a description of the visualization.
-- `title` (String) A human-readable title for the dashboard item.
-- `visualization` (Block List, Min: 1, Max: 1) An object which describes the data visualization to display. (see [below for nested schema](#nestedblock--dashboard_item--visualization))
-
-Optional:
-
-- `span` (Number) The number of columns for the dashboard item to span. Dashboards are rendered on a 12-column grid on "desktop" screen sizes.
-
-
-### Nested Schema for `dashboard_item.data_source`
-
-Required:
-
-- `config` (Block List, Min: 1, Max: 1) Configuration options for the selected data source. (see [below for nested schema](#nestedblock--dashboard_item--data_source--config))
-- `type` (String) The source of the data to display. One of: `stats.edge`, `stats.domain`, `stats.origin`.
-
-
-### Nested Schema for `dashboard_item.data_source.config`
-
-Required:
-
-- `metrics` (List of String) The metrics to visualize. Valid options are defined by the selected data source: [stats.edge](https://www.fastly.com/documentation/reference/api/observability/custom-dashboards/metrics/edge/), [stats.domain](https://www.fastly.com/documentation/reference/api/observability/custom-dashboards/metrics/domain/), [stats.origin](https://www.fastly.com/documentation/reference/api/observability/custom-dashboards/metrics/origin/).
-
-
-
-
-### Nested Schema for `dashboard_item.visualization`
-
-Required:
-
-- `config` (Block List, Min: 1, Max: 1) Configuration options for the selected data source. (see [below for nested schema](#nestedblock--dashboard_item--visualization--config))
-- `type` (String) The type of visualization to display. One of: `chart`.
-
-
-### Nested Schema for `dashboard_item.visualization.config`
-
-Required:
-
-- `plot_type` (String) The type of chart to display. One of: `line`, `bar`, `single-metric`, `donut`.
-
-Optional:
-
-- `calculation_method` (String) The aggregation function to apply to the dataset. One of: `avg`, `sum`, `min`, `max`, `latest`, `p95`.
-- `format` (String) The units to use to format the data. One of: `number`, `bytes`, `percent`, `requests`, `responses`, `seconds`, `milliseconds`, `ratio`, `bitrate`.
diff --git a/examples/resources/components/custom_dashboard_import_cmd.txt b/examples/resources/components/custom_dashboard_import_cmd.txt
deleted file mode 100644
index e4c8d3dd3..000000000
--- a/examples/resources/components/custom_dashboard_import_cmd.txt
+++ /dev/null
@@ -1 +0,0 @@
-$ terraform import fastly_custom_dashboard.example xxxxxxxxxxxxxxxxxxxx
diff --git a/examples/resources/custom_dashboard_basic_usage.tf b/examples/resources/custom_dashboard_basic_usage.tf
deleted file mode 100644
index f2f058117..000000000
--- a/examples/resources/custom_dashboard_basic_usage.tf
+++ /dev/null
@@ -1,251 +0,0 @@
-resource "fastly_custom_dashboard" "example" {
- name = "Example Custom Dashboard"
- description = "This is an example custom dashboard. A few dashboard items are provided to help you get started."
-
- dashboard_item {
- title = "Total Requests"
- subtitle = "Number of requests processed."
-
- data_source {
- type = "stats.edge"
- config = {
- metrics = ["requests"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Hit Ratio"
- subtitle = "Ratio of requests served from Fastly."
-
- data_source {
- type = "stats.edge"
- config {
- metrics = ["hit_ratio"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "percent"
- plot_type = "donut"
- calculation_method = "latest"
- }
- }
- }
-
- dashboard_item {
- title = "Client & Server Errors"
- subtitle = "Total errors served from the client or server."
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "status_4xx",
- "status_5xx"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "bar"
- }
- }
- }
-
- dashboard_item {
- title = "Domains Requests"
- subtitle = "Requests by Domain."
- span = 6
-
- data_source {
- type = "stats.domain"
- config {
- metrics = ["requests"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Origin Responses"
- subtitle = "Responses by Origin."
- span = 6
-
- data_source {
- type = "stats.origin"
- config {
- metrics = ["all_responses"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Total Bandwidth"
- subtitle = "Total bandwidth served."
- span = 12
-
- data_source {
- type = "stats.edge"
- config {
- metrics = ["bandwidth"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "bytes"
- plot_type = "bar"
- }
- }
- }
-
- dashboard_item {
- title = "Products - Image Optimizer & Real-Time Log Streaming"
- subtitle = "Total IO images served and log statements sent."
- span = 8
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "imgopto",
- "log"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Transport Protocols & Security"
- subtitle = "HTTP Protocols & TLS."
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "http1",
- "http2",
- "http3",
- "tls_v10",
- "tls_v11",
- "tls_v12",
- "tls_v13"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "Origin Miss Latency"
- subtitle = "Miss latency times for your origins."
- span = 12
-
- data_source {
- type = "stats.edge"
- config {
- metrics = ["origin_latency"]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "milliseconds"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "DDOS - Request Flood Attempts"
- subtitle = "Number of connections the limit-streams action was applied."
- span = 6
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "ddos_action_limit_streams_connections",
- "ddos_action_limit_streams_requests"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "requests"
- plot_type = "line"
- }
- }
- }
-
- dashboard_item {
- title = "DDOS - Malicious Bot Attack"
- subtitle = "Number of times the blackhole action was taken."
- span = 6
-
- data_source {
- type = "stats.edge"
- config {
- metrics = [
- "ddos_action_close",
- "ddos_action_blackhole"
- ]
- }
- }
-
- visualization {
- type = "chart"
- config {
- format = "number"
- plot_type = "line"
- }
- }
- }
-
-}
diff --git a/fastly/provider.go b/fastly/provider.go
index f2c2407d4..bb67bf1f9 100644
--- a/fastly/provider.go
+++ b/fastly/provider.go
@@ -72,7 +72,6 @@ func Provider() *schema.Provider {
"fastly_alert": resourceFastlyAlert(),
"fastly_configstore": resourceFastlyConfigStore(),
"fastly_configstore_entries": resourceFastlyConfigStoreEntries(),
- "fastly_custom_dashboard": resourceFastlyCustomDashboard(),
"fastly_integration": resourceFastlyIntegration(),
"fastly_kvstore": resourceFastlyKVStore(),
"fastly_secretstore": resourceFastlySecretStore(),
diff --git a/fastly/resource_fastly_custom_dashboard.go b/fastly/resource_fastly_custom_dashboard.go
deleted file mode 100644
index 0331de998..000000000
--- a/fastly/resource_fastly_custom_dashboard.go
+++ /dev/null
@@ -1,448 +0,0 @@
-package fastly
-
-import (
- "context"
- "errors"
- "fmt"
- "log"
-
- gofastly "github.com/fastly/go-fastly/v9/fastly"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
-)
-
-var (
- schemaDataSource = schema.Schema{
- Type: schema.TypeList,
- Required: true,
- Description: "An object which describes the data to display.",
- MaxItems: 1,
- MinItems: 1,
- Elem: &schema.Resource{
- Schema: map[string]*schema.Schema{
- "config": &schemaDataSourceConfig,
- "type": {
- Type: schema.TypeString,
- Required: true,
- Description: "The source of the data to display. One of: `stats.edge`, `stats.domain`, `stats.origin`.",
- ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(
- []string{"stats.edge", "stats.domain", "stats.origin"},
- false,
- )),
- },
- },
- },
- }
-
- schemaDataSourceConfig = schema.Schema{
- Type: schema.TypeList,
- Required: true,
- Description: "Configuration options for the selected data source.",
- MaxItems: 1,
- MinItems: 1,
- Elem: &schema.Resource{
- Schema: map[string]*schema.Schema{
- "metrics": {
- Type: schema.TypeList,
- Required: true,
- Description: "The metrics to visualize. Valid options are defined by the selected data source: [stats.edge](https://www.fastly.com/documentation/reference/api/observability/custom-dashboards/metrics/edge/), [stats.domain](https://www.fastly.com/documentation/reference/api/observability/custom-dashboards/metrics/domain/), [stats.origin](https://www.fastly.com/documentation/reference/api/observability/custom-dashboards/metrics/origin/).",
- Elem: &schema.Schema{Type: schema.TypeString},
- },
- },
- },
- }
-
- schemaVisualization = schema.Schema{
- Type: schema.TypeList,
- Required: true,
- Description: "An object which describes the data visualization to display.",
- MaxItems: 1,
- MinItems: 1,
- Elem: &schema.Resource{
- Schema: map[string]*schema.Schema{
- "config": &schemaVisualizationConfig,
- "type": {
- Type: schema.TypeString,
- Required: true,
- Description: "The type of visualization to display. One of: `chart`.",
- ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(
- []string{"chart"},
- false,
- )),
- },
- },
- },
- }
-
- schemaVisualizationConfig = schema.Schema{
- Type: schema.TypeList,
- Required: true,
- Description: "Configuration options for the selected data source.",
- MaxItems: 1,
- MinItems: 1,
- Elem: &schema.Resource{
- Schema: map[string]*schema.Schema{
- "calculation_method": {
- Type: schema.TypeString,
- Optional: true,
- Description: "The aggregation function to apply to the dataset. One of: `avg`, `sum`, `min`, `max`, `latest`, `p95`.",
- ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(
- []string{"avg", "sum", "min", "max", "latest", "p95"},
- false,
- )),
- },
- "format": {
- Type: schema.TypeString,
- Optional: true,
- Description: "The units to use to format the data. One of: `number`, `bytes`, `percent`, `requests`, `responses`, `seconds`, `milliseconds`, `ratio`, `bitrate`.",
- ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(
- []string{"number", "bytes", "percent", "requests", "responses", "seconds", "milliseconds", "ratio", "bitrate"},
- false,
- )),
- },
- "plot_type": {
- Type: schema.TypeString,
- Required: true,
- Description: "The type of chart to display. One of: `line`, `bar`, `single-metric`, `donut`.",
- ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(
- []string{"line", "bar", "single-metric", "donut"},
- false,
- )),
- },
- },
- },
- }
-)
-
-func resourceFastlyCustomDashboard() *schema.Resource {
- return &schema.Resource{
- CreateContext: resourceFastlyCustomDashboardCreate,
- ReadContext: resourceFastlyCustomDashboardRead,
- UpdateContext: resourceFastlyCustomDashboardUpdate,
- DeleteContext: resourceFastlyCustomDashboardDelete,
- Importer: &schema.ResourceImporter{
- StateContext: schema.ImportStatePassthroughContext,
- },
-
- Schema: map[string]*schema.Schema{
- "dashboard_item": {
- Type: schema.TypeList,
- Optional: true,
- Description: "A list of dashboard items.",
- MinItems: 0,
- MaxItems: 100,
- Elem: &schema.Resource{
- Schema: map[string]*schema.Schema{
- "data_source": &schemaDataSource,
- "span": {
- Type: schema.TypeInt,
- Optional: true,
- Default: 4,
- Description: "The number of columns for the dashboard item to span. Dashboards are rendered on a 12-column grid on \"desktop\" screen sizes.",
- },
- "subtitle": {
- Type: schema.TypeString,
- Required: true,
- Description: "A human-readable subtitle for the dashboard item. Often a description of the visualization.",
- },
- "title": {
- Type: schema.TypeString,
- Required: true,
- Description: "A human-readable title for the dashboard item.",
- },
- "visualization": &schemaVisualization,
- },
- },
- },
- "description": {
- Type: schema.TypeString,
- Optional: true,
- Description: "A short description of the dashboard.",
- },
- "id": {
- Type: schema.TypeString,
- Computed: true,
- Description: "Dashboard identifier (UUID).",
- },
- "name": {
- Type: schema.TypeString,
- Required: true,
- Description: "A human-readable name.",
- },
- },
- }
-}
-
-func resourceFastlyCustomDashboardCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
- conn := meta.(*APIClient).conn
-
- input := gofastly.CreateObservabilityCustomDashboardInput{
- Name: d.Get("name").(string),
- }
-
- if v, ok := d.GetOk("description"); ok {
- input.Description = gofastly.ToPointer(v.(string))
- }
-
- items, err := resourceItems(d)
- if err != nil {
- return diag.FromErr(err)
- }
- input.Items = items
-
- dash, err := conn.CreateObservabilityCustomDashboard(&input)
- if err != nil {
- return diag.FromErr(err)
- }
-
- d.SetId(dash.ID)
-
- return resourceFastlyCustomDashboardRead(ctx, d, meta)
-}
-
-func resourceFastlyCustomDashboardRead(_ context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
- log.Printf("[DEBUG] Refreshing Custom Dashboard for (%s)", d.Id())
- conn := meta.(*APIClient).conn
-
- dash, err := conn.GetObservabilityCustomDashboard(&gofastly.GetObservabilityCustomDashboardInput{
- ID: gofastly.ToPointer(d.Id()),
- })
- if err != nil {
- return diag.FromErr(err)
- }
-
- d.SetId(dash.ID)
- if len(dash.Name) > 0 {
- err = d.Set("name", dash.Name)
- if err != nil {
- return diag.FromErr(err)
- }
- }
- if len(dash.Description) > 0 {
- err = d.Set("description", dash.Description)
- if err != nil {
- return diag.FromErr(err)
- }
- }
- if len(dash.Items) > 0 {
- itemList := flattenDashboardItems(dash.Items)
- err = d.Set("dashboard_item", itemList)
- if err != nil {
- return diag.FromErr(err)
- }
- }
- return nil
-}
-
-func resourceFastlyCustomDashboardUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
- conn := meta.(*APIClient).conn
-
- var items = make([]gofastly.DashboardItem, 0)
- input := gofastly.UpdateObservabilityCustomDashboardInput{
- Description: gofastly.ToPointer(d.Get("description").(string)),
- ID: gofastly.ToPointer(d.Id()),
- Name: gofastly.ToPointer(d.Get("name").(string)),
- }
-
- items, err := resourceItems(d)
- if err != nil {
- return diag.FromErr(err)
- }
- input.Items = &items
-
- _, err = conn.UpdateObservabilityCustomDashboard(&input)
- if err != nil {
- return diag.FromErr(err)
- }
-
- return resourceFastlyCustomDashboardRead(ctx, d, meta)
-}
-
-func resourceFastlyCustomDashboardDelete(_ context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
- conn := meta.(*APIClient).conn
-
- err := conn.DeleteObservabilityCustomDashboard(&gofastly.DeleteObservabilityCustomDashboardInput{
- ID: gofastly.ToPointer(d.Id()),
- })
- if err != nil {
- return diag.FromErr(err)
- }
-
- return nil
-}
-
-func flattenDashboardItems(remoteState []gofastly.DashboardItem) []map[string]interface{} {
- var result []map[string]any
- for _, di := range remoteState {
- dataSource := map[string]any{
- "type": di.DataSource.Type,
- "config": []any{map[string]any{"metrics": di.DataSource.Config.Metrics}},
- }
-
- vizConfig := map[string]any{
- "plot_type": di.Visualization.Config.PlotType,
- }
- if di.Visualization.Config.CalculationMethod != nil {
- vizConfig["calculation_method"] = string(*di.Visualization.Config.CalculationMethod)
- }
- if di.Visualization.Config.Format != nil {
- vizConfig["format"] = string(*di.Visualization.Config.Format)
- }
- visualization := map[string]any{
- "type": di.Visualization.Type,
- "config": []any{vizConfig},
- }
-
- result = append(result, map[string]interface{}{
- "title": di.Title,
- "subtitle": di.Subtitle,
- "span": di.Span,
- "data_source": []any{dataSource},
- "visualization": []any{visualization},
- })
- }
- return result
-}
-
-func resourceItems(d *schema.ResourceData) ([]gofastly.DashboardItem, error) {
- var items []gofastly.DashboardItem
- var errs []error
- if v, ok := d.GetOk("dashboard_item"); ok {
- for i, r := range v.([]any) {
- if m, ok := r.(map[string]any); ok {
- item, err := mapToDashboardItem(m)
- if err != nil {
- errs = append(errs, fmt.Errorf("item #%d is invalid: %w", i, err))
- }
- items = append(items, *item)
- }
- }
- }
- if errs != nil {
- return nil, errors.Join(errs...)
- }
- return items, nil
-}
-
-func mapToDashboardItem(m map[string]any) (*gofastly.DashboardItem, error) {
- var errs []error
- var (
- title, subtitle string
- span int
-
- dataSourceList, sourceConfigList []any
- dataSource, sourceConfig map[string]any
- sourceType string
- metrics []string
-
- vizList, vizConfigList []any
- visualization, visualizationConfig map[string]any
- visualizationType string
- plotType, format, calcMethod string
- )
-
- var ok bool
-
- // Top-level fields
- if title, ok = m["title"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid title: %#v", m["title"]))
- }
- if subtitle, ok = m["subtitle"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid subtitle: %#v", m["subtitle"]))
- }
- if span, ok = m["span"].(int); !ok {
- errs = append(errs, fmt.Errorf("invalid span: %#v", m["span"]))
- }
- if dataSourceList, ok = m["data_source"].([]any); !ok {
- errs = append(errs, fmt.Errorf("invalid data_source: %#v", m["data_source"]))
- }
- if len(dataSourceList) != 1 {
- errs = append(errs, fmt.Errorf("invalid data_source: %#v", m["data_source"]))
- } else {
- if dataSource, ok = dataSourceList[0].(map[string]any); !ok {
- errs = append(errs, fmt.Errorf("invalid data_source: %#v", m["data_source"]))
- }
- }
-
- if vizList, ok = m["visualization"].([]any); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization: %#v", m["visualization"]))
- }
- if len(vizList) != 1 {
- errs = append(errs, fmt.Errorf("invalid visualization: %#v", m["visualization"]))
- } else {
- if visualization, ok = vizList[0].(map[string]any); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization: %#v", m["visualization"]))
- }
- }
-
- // Nested DataSource
- if sourceType, ok = dataSource["type"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid data_source.type: %#v", dataSource["type"]))
- }
- if sourceConfigList, ok = dataSource["config"].([]any); !ok {
- errs = append(errs, fmt.Errorf("invalid data_source.config: %#v", dataSource["config"]))
- }
- if len(sourceConfigList) != 1 {
- errs = append(errs, fmt.Errorf("invalid data_source.config: %#v", dataSource["config"]))
- } else {
- if sourceConfig, ok = sourceConfigList[0].(map[string]any); !ok {
- errs = append(errs, fmt.Errorf("invalid data_source.config: %#v", dataSource["config"]))
- }
- }
- if metricsList, ok := sourceConfig["metrics"].([]any); !ok {
- errs = append(errs, fmt.Errorf("invalid data_source.config.metrics: %#v", sourceConfig["metrics"]))
- } else {
- for _, m := range metricsList {
- metrics = append(metrics, m.(string))
- }
- }
-
- // Nested Visualization
- if visualizationType, ok = visualization["type"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization.type: %#v", visualization["type"]))
- }
- if vizConfigList, ok = visualization["config"].([]any); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization.config: %#v", visualization["config"]))
- }
- if len(vizConfigList) != 1 {
- errs = append(errs, fmt.Errorf("invalid visualization.config: %#v", visualization["config"]))
- } else {
- if visualizationConfig, ok = vizConfigList[0].(map[string]any); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization.config: %#v", visualization["config"]))
- }
- }
- if plotType, ok = visualizationConfig["plot_type"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization.config.plot_type: %#v", visualizationConfig["plot_type"]))
- }
- if format, ok = visualizationConfig["format"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization.config.format: %#v", visualizationConfig["format"]))
- }
- if calcMethod, ok = visualizationConfig["calculation_method"].(string); !ok {
- errs = append(errs, fmt.Errorf("invalid visualization.config.calculation_method: %#v", visualizationConfig["calculation_method"]))
- }
-
- if len(errs) > 0 {
- return nil, errors.Join(errs...)
- }
-
- return &gofastly.DashboardItem{
- DataSource: gofastly.DashboardDataSource{
- Config: gofastly.DashboardSourceConfig{
- Metrics: metrics,
- },
- Type: gofastly.DashboardSourceType(sourceType),
- },
- Span: uint8(span),
- Subtitle: subtitle,
- Title: title,
- Visualization: gofastly.DashboardVisualization{
- Config: gofastly.VisualizationConfig{
- CalculationMethod: gofastly.ToPointer(gofastly.CalculationMethod(calcMethod)),
- Format: gofastly.ToPointer(gofastly.VisualizationFormat(format)),
- PlotType: gofastly.PlotType(plotType),
- },
- Type: gofastly.VisualizationType(visualizationType),
- },
- }, nil
-}
diff --git a/fastly/resource_fastly_custom_dashboard_test.go b/fastly/resource_fastly_custom_dashboard_test.go
deleted file mode 100644
index 304841078..000000000
--- a/fastly/resource_fastly_custom_dashboard_test.go
+++ /dev/null
@@ -1,259 +0,0 @@
-package fastly
-
-import (
- "bytes"
- "fmt"
- "strings"
- "testing"
- "text/template"
-
- gofastly "github.com/fastly/go-fastly/v9/fastly"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
-)
-
-func generateDashboardParams(t *testing.T) (name, description string, items []gofastly.DashboardItem) {
- t.Helper()
-
- rand := acctest.RandString(10)
- name = fmt.Sprintf("Custom Dashboard %s", rand)
- description = fmt.Sprintf("Created by tf-test-%s", rand)
- items = []gofastly.DashboardItem{
- {
- DataSource: gofastly.DashboardDataSource{
- Config: gofastly.DashboardSourceConfig{
- Metrics: []string{"requests"},
- },
- Type: gofastly.SourceTypeStatsEdge,
- },
- Span: 4,
- Subtitle: "This is the first chart",
- Title: "Chart #1",
- Visualization: gofastly.DashboardVisualization{
- Config: gofastly.VisualizationConfig{
- PlotType: gofastly.PlotTypeBar,
- },
- Type: gofastly.VisualizationTypeChart,
- },
- },
- {
- DataSource: gofastly.DashboardDataSource{
- Config: gofastly.DashboardSourceConfig{
- Metrics: []string{"status_4xx", "status_5xx"},
- },
- Type: gofastly.SourceTypeStatsDomain,
- },
- Span: 12,
- Subtitle: "This is chart, the second",
- Title: "Chart #2",
- Visualization: gofastly.DashboardVisualization{
- Config: gofastly.VisualizationConfig{
- PlotType: gofastly.PlotTypeLine,
- CalculationMethod: gofastly.ToPointer(gofastly.CalculationMethodAvg),
- },
- Type: gofastly.VisualizationTypeChart,
- },
- },
- }
-
- return
-}
-
-func TestAccFastlyCustomDashboard_Basic(t *testing.T) {
- dashboardName, dashboardDescription, dashboardItems := generateDashboardParams(t)
-
- createDashboard := gofastly.CreateObservabilityCustomDashboardInput{
- Name: dashboardName,
- Description: gofastly.ToPointer(dashboardDescription),
- Items: dashboardItems,
- }
-
- // Leave one item alone
- updatedItems := []gofastly.DashboardItem{}
- updatedItems = append(updatedItems, dashboardItems[0])
-
- // Update one item in place
- updatedItems = append(updatedItems, dashboardItems[1])
- updatedItems[1].Visualization.Config.PlotType = gofastly.PlotTypeDonut
- updatedItems[1].Visualization.Config.CalculationMethod = nil
-
- // Add a new item
- updatedItems = append(updatedItems, gofastly.DashboardItem{
- Title: "NEW Chart",
- Subtitle: "This is the new Chart #3",
- DataSource: gofastly.DashboardDataSource{
- Type: gofastly.SourceTypeStatsOrigin,
- Config: gofastly.DashboardSourceConfig{Metrics: []string{"all_status_2xx"}},
- },
- Visualization: gofastly.DashboardVisualization{
- Type: gofastly.VisualizationTypeChart,
- Config: gofastly.VisualizationConfig{PlotType: gofastly.PlotTypeSingleMetric},
- },
- })
-
- updatedName := "This is an updated dashboard"
- update1 := gofastly.UpdateObservabilityCustomDashboardInput{
- Description: &dashboardDescription,
- Items: &updatedItems,
- Name: &updatedName,
- }
-
- // Update again, deleting first and last item
- update2 := update1
- update2.Items = &[]gofastly.DashboardItem{updatedItems[1]}
-
- resource.ParallelTest(t, resource.TestCase{
- PreCheck: func() {
- testAccPreCheck(t)
- },
- ProviderFactories: testAccProviders,
- CheckDestroy: testAccCheckCustomDashboardDestroy,
- Steps: []resource.TestStep{
- {
- Config: testAccObservabilityCustomDashboard(t, createDashboard),
- Check: resource.ComposeTestCheckFunc(
- testAccCustomDashboardRemoteState(dashboardName),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "name", dashboardName),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "description", dashboardDescription),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.#", "2"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.0.title", "Chart #1"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.1.title", "Chart #2"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.1.visualization.0.config.0.plot_type", "line"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.1.visualization.0.config.0.calculation_method", "avg"),
- ),
- },
- {
- Config: testAccObservabilityCustomDashboard(t, update1),
- Check: resource.ComposeTestCheckFunc(
- testAccCustomDashboardRemoteState(updatedName),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "name", updatedName),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "description", dashboardDescription),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.#", "3"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.0.title", "Chart #1"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.1.title", "Chart #2"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.1.visualization.0.config.0.plot_type", "donut"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.1.visualization.0.config.0.calculation_method", ""),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.2.title", "NEW Chart"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.2.span", "4"),
- ),
- },
- {
- Config: testAccObservabilityCustomDashboard(t, update2),
- Check: resource.ComposeTestCheckFunc(
- testAccCustomDashboardRemoteState(updatedName),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "name", updatedName),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "description", dashboardDescription),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.#", "1"),
- resource.TestCheckResourceAttr("fastly_custom_dashboard.example", "dashboard_item.0.title", "Chart #2"),
- ),
- },
- {
- ResourceName: "fastly_custom_dashboard.example",
- ImportState: true,
- ImportStateVerify: true,
- },
- },
- })
-
-}
-
-func testAccCustomDashboardRemoteState(dashboardName string) resource.TestCheckFunc {
- return func(_ *terraform.State) error {
- conn := testAccProvider.Meta().(*APIClient).conn
-
- dashboards, err := conn.ListObservabilityCustomDashboards(&gofastly.ListObservabilityCustomDashboardsInput{})
- if err != nil {
- return fmt.Errorf("error listing all Custom Dashboards: %s", err)
- }
-
- var got *gofastly.ObservabilityCustomDashboard
- var found bool
- for _, dash := range dashboards.Data {
- if dash.Name == dashboardName {
- found = true
- got = &dash
- break
- }
- }
- if !found || got == nil {
- return fmt.Errorf("error looking up the dashboard")
- }
-
- return nil
- }
-}
-
-func testAccObservabilityCustomDashboard(t *testing.T, input any) string {
- t.Helper()
- f := template.FuncMap{"join": strings.Join, "quote": func(s []string) []string {
- final := make([]string, len(s))
- for i, q := range s {
- final[i] = fmt.Sprintf("%q", q)
- }
- return final
- }}
- tmpl := template.Must(template.New("dashboard_items").Funcs(f).Parse(`
- resource "fastly_custom_dashboard" "example" {
- name = "{{ .Name }}"
- description = "{{ .Description }}"
-
- {{ range .Items -}}
- dashboard_item {
- {{if .ID -}}
- id = "{{- .ID -}}"
- {{- end}}
- title = "{{- .Title -}}"
- subtitle = "{{- .Subtitle -}}"
- {{if .Span -}}
- span = "{{- .Span -}}"
- {{- end}}
- data_source {
- type = "{{- .DataSource.Type -}}"
- config {
- metrics = [{{- join (quote .DataSource.Config.Metrics) "," -}}]
- }
- }
- visualization {
- type = "chart"
- config {
- plot_type = "{{- .Visualization.Config.PlotType -}}"
- {{if .Visualization.Config.CalculationMethod -}}
- calculation_method = "{{- .Visualization.Config.CalculationMethod -}}"
- {{- end}}
- {{if .Visualization.Config.Format -}}
- format = "{{- .Visualization.Config.Format -}}"
- {{- end}}
- }
- }
- }
- {{ end }}
- }
- `))
- b := new(bytes.Buffer)
- if err := tmpl.Execute(b, input); err != nil {
- t.Fatal(err)
- }
- return b.String()
-}
-
-func testAccCheckCustomDashboardDestroy(s *terraform.State) error {
- for _, rs := range s.RootModule().Resources {
- if rs.Type != "fastly_custom_dashboard" {
- continue
- }
-
- conn := testAccProvider.Meta().(*APIClient).conn
- dashResp, err := conn.ListObservabilityCustomDashboards(&gofastly.ListObservabilityCustomDashboardsInput{})
- if err != nil {
- return fmt.Errorf("error listing custom dashboards when checking dashboard destroy (%s): %s", rs.Primary, err)
- }
-
- for _, dash := range dashResp.Data {
- if dash.ID == rs.Primary.ID {
- return fmt.Errorf("tried deleting dashboard (%s), but was still found", rs.Primary.ID)
- }
- }
- }
- return nil
-}
diff --git a/templates/resources/custom_dashboard.md.tmpl b/templates/resources/custom_dashboard.md.tmpl
deleted file mode 100644
index b84ef1b45..000000000
--- a/templates/resources/custom_dashboard.md.tmpl
+++ /dev/null
@@ -1,23 +0,0 @@
----
-layout: "fastly"
-page_title: "Fastly: custom_dashboard"
-sidebar_current: "docs-fastly-resource-custom_dashboard"
-description: |-
- Provides a Custom Dashboard which can be viewed in the Fastly Web UI.
----
-
-# fastly_custom_dashboard
-
-Provides a Custom Dashboard which can be viewed in the Fastly Web UI.
-
-## Example Usage
-
-{{ tffile "examples/resources/custom_dashboard_basic_usage.tf" }}
-
-## Import
-
-Fastly Custom Dashboards can be imported using their ID, e.g.
-
-{{ codefile "sh" "examples/resources/components/custom_dashboard_import_cmd.txt" }}
-
-{{ .SchemaMarkdown | trimspace }}