Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_dashboard_grafana - support for grafana_major_version property #24014

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions internal/services/dashboard/dashboard_grafana_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type DashboardGrafanaModel struct {
ZoneRedundancyEnabled bool `tfschema:"zone_redundancy_enabled"`
Endpoint string `tfschema:"endpoint"`
GrafanaVersion string `tfschema:"grafana_version"`
GrafanaMajorVersion string `tfschema:"grafana_major_version"`
OutboundIPs []string `tfschema:"outbound_ip"`
}

Expand Down Expand Up @@ -116,6 +117,17 @@ func (r DashboardGrafanaResource) Arguments() map[string]*pluginsdk.Schema {
Default: true,
},

"grafana_major_version": {
Type: pluginsdk.TypeString,
// TODO: make this field Required (with no default) in 4.0
Optional: true,
ForceNew: true,
Default: "9",
ValidateFunc: validation.StringInSlice([]string{
"9", "10",
}, false),
},

"sku": {
Type: pluginsdk.TypeString,
Optional: true,
Expand Down Expand Up @@ -211,6 +223,7 @@ func (r DashboardGrafanaResource) Create() sdk.ResourceFunc {
AutoGeneratedDomainNameLabelScope: &model.AutoGeneratedDomainNameLabelScope,
DeterministicOutboundIP: &deterministicOutboundIP,
GrafanaIntegrations: expandGrafanaIntegrationsModel(model.AzureMonitorWorkspaceIntegrations),
GrafanaMajorVersion: &model.GrafanaMajorVersion,
PublicNetworkAccess: &publicNetworkAccess,
ZoneRedundancy: &zoneRedundancy,
},
Expand Down Expand Up @@ -374,6 +387,10 @@ func (r DashboardGrafanaResource) Read() sdk.ResourceFunc {
state.GrafanaVersion = *properties.GrafanaVersion
}

if properties.GrafanaMajorVersion != nil {
state.GrafanaMajorVersion = *properties.GrafanaMajorVersion
}

if properties.OutboundIPs != nil {
state.OutboundIPs = *properties.OutboundIPs
}
Expand Down
58 changes: 46 additions & 12 deletions internal/services/dashboard/dashboard_grafana_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ func TestAccDashboardGrafana_complete(t *testing.T) {
})
}

func TestAccDashboardGrafana_nonDefaultVersion(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_dashboard_grafana", "test")
r := DashboardGrafanaResource{}
data.ResourceSequentialTest(t, r, []acceptance.TestStep{
{
Config: r.nonDefaultVersion(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccDashboardGrafana_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_dashboard_grafana", "test")
r := DashboardGrafanaResource{}
Expand Down Expand Up @@ -132,9 +146,10 @@ func (r DashboardGrafanaResource) basic(data acceptance.TestData) string {
%s

resource "azurerm_dashboard_grafana" "test" {
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
grafana_major_version = "9"
}
`, template, data.RandomInteger)
}
Expand All @@ -145,24 +160,41 @@ func (r DashboardGrafanaResource) essential(data acceptance.TestData) string {
%s

resource "azurerm_dashboard_grafana" "test" {
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
grafana_major_version = "9"

sku = "Essential"
}
`, template, data.RandomInteger)
}

func (r DashboardGrafanaResource) nonDefaultVersion(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_dashboard_grafana" "test" {
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
grafana_major_version = "10"

}
`, template, data.RandomInteger)
}

func (r DashboardGrafanaResource) requiresImport(data acceptance.TestData) string {
config := r.basic(data)
return fmt.Sprintf(`
%s

resource "azurerm_dashboard_grafana" "import" {
name = azurerm_dashboard_grafana.test.name
resource_group_name = azurerm_dashboard_grafana.test.resource_group_name
location = azurerm_dashboard_grafana.test.location
name = azurerm_dashboard_grafana.test.name
resource_group_name = azurerm_dashboard_grafana.test.resource_group_name
location = azurerm_dashboard_grafana.test.location
grafana_major_version = "9"
}
`, config)
}
Expand All @@ -184,6 +216,7 @@ resource "azurerm_dashboard_grafana" "test" {
api_key_enabled = true
deterministic_outbound_ip_enabled = true
public_network_access_enabled = false
grafana_major_version = "9"

identity {
type = "UserAssigned"
Expand All @@ -207,9 +240,10 @@ func (r DashboardGrafanaResource) update(data acceptance.TestData) string {
%s

resource "azurerm_dashboard_grafana" "test" {
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
name = "a-dg-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
grafana_major_version = "9"

identity {
type = "SystemAssigned"
Expand Down
54 changes: 28 additions & 26 deletions website/docs/r/dashboard_grafana.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,74 +40,76 @@ resource "azurerm_dashboard_grafana" "example" {

The following arguments are supported:

* `name` - (Required) Specifies the name which should be used for this Dashboard Grafana. Changing this forces a new Dashboard Grafana to be created.
- `name` - (Required) Specifies the name which should be used for this Dashboard Grafana. Changing this forces a new Dashboard Grafana to be created.

* `resource_group_name` - (Required) Specifies the name of the Resource Group where the Dashboard Grafana should exist. Changing this forces a new Dashboard Grafana to be created.
- `resource_group_name` - (Required) Specifies the name of the Resource Group where the Dashboard Grafana should exist. Changing this forces a new Dashboard Grafana to be created.

* `location` - (Required) Specifies the Azure Region where the Dashboard Grafana should exist. Changing this forces a new Dashboard Grafana to be created.
- `location` - (Required) Specifies the Azure Region where the Dashboard Grafana should exist. Changing this forces a new Dashboard Grafana to be created.

* `api_key_enabled` - (Optional) Whether to enable the api key setting of the Grafana instance. Defaults to `false`.
- `api_key_enabled` - (Optional) Whether to enable the api key setting of the Grafana instance. Defaults to `false`.

* `auto_generated_domain_name_label_scope` - (Optional) Scope for dns deterministic name hash calculation. The only possible value is `TenantReuse`. Defaults to `TenantReuse`.
- `auto_generated_domain_name_label_scope` - (Optional) Scope for dns deterministic name hash calculation. The only possible value is `TenantReuse`. Defaults to `TenantReuse`.

* `deterministic_outbound_ip_enabled` - (Optional) Whether to enable the Grafana instance to use deterministic outbound IPs. Defaults to `false`.
- `deterministic_outbound_ip_enabled` - (Optional) Whether to enable the Grafana instance to use deterministic outbound IPs. Defaults to `false`.

* `azure_monitor_workspace_integrations` - (Optional) A `azure_monitor_workspace_integrations` block as defined below.
- `grafana_major_version` - (Optional) Which major version of Grafana to deploy. Defaults to `9`. Possible values are `9`, `10`. Changing this forces a new resource to be created.

* `identity` - (Optional) An `identity` block as defined below. Changing this forces a new Dashboard Grafana to be created.
- `azure_monitor_workspace_integrations` - (Optional) A `azure_monitor_workspace_integrations` block as defined below.

* `public_network_access_enabled` - (Optional) Whether to enable traffic over the public interface. Defaults to `true`.
- `identity` - (Optional) An `identity` block as defined below. Changing this forces a new Dashboard Grafana to be created.

* `sku` - (Optional) The name of the SKU used for the Grafana instance. Possible value are `Standard` and `Essential`. Defaults to `Standard`. Changing this forces a new Dashboard Grafana to be created.
- `public_network_access_enabled` - (Optional) Whether to enable traffic over the public interface. Defaults to `true`.

* `tags` - (Optional) A mapping of tags which should be assigned to the Dashboard Grafana.
- `sku` - (Optional) The name of the SKU used for the Grafana instance. The only possible value is `Standard`. Defaults to `Standard`. Changing this forces a new Dashboard Grafana to be created.

* `zone_redundancy_enabled` - (Optional) Whether to enable the zone redundancy setting of the Grafana instance. Defaults to `false`. Changing this forces a new Dashboard Grafana to be created.
- `tags` - (Optional) A mapping of tags which should be assigned to the Dashboard Grafana.

- `zone_redundancy_enabled` - (Optional) Whether to enable the zone redundancy setting of the Grafana instance. Defaults to `false`. Changing this forces a new Dashboard Grafana to be created.

---

An `azure_monitor_workspace_integrations` block supports the following:

* `resource_id` - (Required) Specifies the resource ID of the connected Azure Monitor Workspace.
- `resource_id` - (Required) Specifies the resource ID of the connected Azure Monitor Workspace.

---

An `identity` block supports the following:

* `type` - (Required) Specifies the type of Managed Service Identity. Possible values are `SystemAssigned`, `UserAssigned`. Changing this forces a new resource to be created.
- `type` - (Required) Specifies the type of Managed Service Identity. Possible values are `SystemAssigned`, `UserAssigned`. Changing this forces a new resource to be created.

* `identity_ids` - (Optional) Specifies the list of User Assigned Managed Service Identity IDs which should be assigned to this Dashboard Grafana. Changing this forces a new resource to be created.
- `identity_ids` - (Optional) Specifies the list of User Assigned Managed Service Identity IDs which should be assigned to this Dashboard Grafana. Changing this forces a new resource to be created.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

* `id` - The ID of the Dashboard Grafana.
- `id` - The ID of the Dashboard Grafana.

* `endpoint` - The endpoint of the Grafana instance.
- `endpoint` - The endpoint of the Grafana instance.

* `grafana_version` - The Grafana software version.
- `grafana_version` - The full Grafana software semantic version deployed.

* `identity` - An `identity` block as defined below.
- `identity` - An `identity` block as defined below.

* `outbound_ip` - List of outbound IPs if deterministicOutboundIP is enabled.
- `outbound_ip` - List of outbound IPs if deterministicOutboundIP is enabled.

---

An `identity` block exports the following:

* `principal_id` - The Principal ID associated with this Managed Service Identity.
- `principal_id` - The Principal ID associated with this Managed Service Identity.

* `tenant_id` - The Tenant ID associated with this Managed Service Identity.
- `tenant_id` - The Tenant ID associated with this Managed Service Identity.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:

* `create` - (Defaults to 30 minutes) Used when creating the Dashboard Grafana.
* `read` - (Defaults to 5 minutes) Used when retrieving the Dashboard Grafana.
* `update` - (Defaults to 30 minutes) Used when updating the Dashboard Grafana.
* `delete` - (Defaults to 30 minutes) Used when deleting the Dashboard Grafana.
- `create` - (Defaults to 30 minutes) Used when creating the Dashboard Grafana.
- `read` - (Defaults to 5 minutes) Used when retrieving the Dashboard Grafana.
- `update` - (Defaults to 30 minutes) Used when updating the Dashboard Grafana.
- `delete` - (Defaults to 30 minutes) Used when deleting the Dashboard Grafana.

## Import

Expand Down
Loading