Skip to content

Commit 338941f

Browse files
authored
azurerm_dashboard_grafana: add support for sku_size (hashicorp#31047)
[ENHANCEMENT] * `azurerm_dashboard_grafana`- add support for the `sku_size` property
1 parent a57ab07 commit 338941f

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

internal/services/dashboard/dashboard_grafana_resource.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type DashboardGrafanaModel struct {
3535
Location string `tfschema:"location"`
3636
PublicNetworkAccessEnabled bool `tfschema:"public_network_access_enabled"`
3737
Sku string `tfschema:"sku"`
38+
SkuSize string `tfschema:"sku_size"`
3839
Tags map[string]string `tfschema:"tags"`
3940
ZoneRedundancyEnabled bool `tfschema:"zone_redundancy_enabled"`
4041
Endpoint string `tfschema:"endpoint"`
@@ -214,6 +215,14 @@ func (r DashboardGrafanaResource) Arguments() map[string]*pluginsdk.Schema {
214215
}, false),
215216
},
216217

218+
"sku_size": {
219+
Type: pluginsdk.TypeString,
220+
Optional: true,
221+
Default: managedgrafanas.SizeXOne,
222+
ForceNew: true,
223+
ValidateFunc: validation.StringInSlice(managedgrafanas.PossibleValuesForSize(), false),
224+
},
225+
217226
"tags": commonschema.Tags(),
218227

219228
"zone_redundancy_enabled": {
@@ -311,6 +320,10 @@ func (r DashboardGrafanaResource) Create() sdk.ResourceFunc {
311320
Tags: &model.Tags,
312321
}
313322

323+
if model.SkuSize != "" {
324+
properties.Sku.Size = pointer.To(managedgrafanas.Size(model.SkuSize))
325+
}
326+
314327
if err := client.GrafanaCreateThenPoll(ctx, id, *properties); err != nil {
315328
return fmt.Errorf("creating %s: %+v", id, err)
316329
}
@@ -507,6 +520,9 @@ func (r DashboardGrafanaResource) Read() sdk.ResourceFunc {
507520

508521
if model.Sku != nil {
509522
state.Sku = model.Sku.Name
523+
if model.Sku.Size != nil {
524+
state.SkuSize = pointer.FromEnum(model.Sku.Size)
525+
}
510526
}
511527

512528
if model.Tags != nil {

internal/services/dashboard/dashboard_grafana_resource_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ func TestAccDashboardGrafana_withSku(t *testing.T) {
9696
})
9797
}
9898

99+
func TestAccDashboardGrafana_withSize(t *testing.T) {
100+
data := acceptance.BuildTestData(t, "azurerm_dashboard_grafana", "test")
101+
r := DashboardGrafanaResource{}
102+
data.ResourceSequentialTest(t, r, []acceptance.TestStep{
103+
{
104+
Config: r.withSize(data),
105+
Check: acceptance.ComposeTestCheckFunc(
106+
check.That(data.ResourceName).ExistsInAzure(r),
107+
),
108+
},
109+
data.ImportStep(),
110+
})
111+
}
112+
99113
func (r DashboardGrafanaResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
100114
id, err := managedgrafanas.ParseGrafanaID(state.ID)
101115
if err != nil {
@@ -162,6 +176,23 @@ resource "azurerm_dashboard_grafana" "test" {
162176
`, template, data.RandomInteger)
163177
}
164178

179+
func (r DashboardGrafanaResource) withSize(data acceptance.TestData) string {
180+
template := r.template(data)
181+
return fmt.Sprintf(`
182+
%s
183+
184+
resource "azurerm_dashboard_grafana" "test" {
185+
name = "a-dg-%d"
186+
resource_group_name = azurerm_resource_group.test.name
187+
location = azurerm_resource_group.test.location
188+
grafana_major_version = "11"
189+
190+
sku = "Standard"
191+
sku_size = "X1"
192+
}
193+
`, template, data.RandomInteger)
194+
}
195+
165196
func (r DashboardGrafanaResource) requiresImport(data acceptance.TestData) string {
166197
config := r.basic(data)
167198
return fmt.Sprintf(`

website/docs/r/dashboard_grafana.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ resource "azurerm_dashboard_grafana" "example" {
2626
api_key_enabled = true
2727
deterministic_outbound_ip_enabled = true
2828
public_network_access_enabled = false
29+
sku = "Standard"
30+
sku_size = "X1"
2931
3032
identity {
3133
type = "SystemAssigned"
@@ -65,6 +67,8 @@ The following arguments are supported:
6567

6668
* `sku` - (Optional) The name of the SKU used for the Grafana instance. Possible values are `Standard` and `Essential`. Defaults to `Standard`. Changing this forces a new Dashboard Grafana to be created.
6769

70+
* `sku_size` - (Optional) The size of the SKU used for the Grafana instance. Possible values are `X1` and `X2`. Defaults to `X1`. Changing this forces a new Dashboard Grafana to be created.
71+
6872
* `tags` - (Optional) A mapping of tags which should be assigned to the Dashboard Grafana.
6973

7074
* `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.

0 commit comments

Comments
 (0)