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_monitor_private_link_scope - api 2021-07-01-preview - ingestion and query mode access added #25763

Merged
merged 7 commits into from
Jun 20, 2024
2 changes: 1 addition & 1 deletion internal/services/monitor/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2018-03-01/metricalerts"
scheduledqueryrules2018 "github.com/hashicorp/go-azure-sdk/resource-manager/insights/2018-04-16/scheduledqueryrules"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2019-10-17-preview/privatelinkscopedresources"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2019-10-17-preview/privatelinkscopesapis"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2020-10-01/activitylogalertsapis"
diagnosticSettingClient "github.com/hashicorp/go-azure-sdk/resource-manager/insights/2021-05-01-preview/diagnosticsettings"
diagnosticCategoryClient "github.com/hashicorp/go-azure-sdk/resource-manager/insights/2021-05-01-preview/diagnosticsettingscategories"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2021-07-01-preview/privatelinkscopesapis"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2022-06-01/datacollectionendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2022-06-01/datacollectionruleassociations"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2022-06-01/datacollectionrules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2019-10-17-preview/privatelinkscopesapis"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2021-07-01-preview/privatelinkscopesapis"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/monitor/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down Expand Up @@ -47,6 +48,30 @@ func resourceMonitorPrivateLinkScope() *pluginsdk.Resource {
ValidateFunc: validate.PrivateLinkScopeName,
},

"ingestion_access_mode": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(privatelinkscopesapis.AccessModeOpen),
KiPIDesTAN marked this conversation as resolved.
Show resolved Hide resolved
ValidateFunc: validation.StringInSlice(
[]string{
string(privatelinkscopesapis.AccessModeOpen),
string(privatelinkscopesapis.AccessModePrivateOnly),
},
false),
KiPIDesTAN marked this conversation as resolved.
Show resolved Hide resolved
},

"query_access_mode": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(privatelinkscopesapis.AccessModeOpen),
ValidateFunc: validation.StringInSlice(
[]string{
string(privatelinkscopesapis.AccessModeOpen),
string(privatelinkscopesapis.AccessModePrivateOnly),
},
false),
KiPIDesTAN marked this conversation as resolved.
Show resolved Hide resolved
},

"resource_group_name": commonschema.ResourceGroupName(),

"tags": tags.Schema(),
Expand Down Expand Up @@ -78,9 +103,19 @@ func resourceMonitorPrivateLinkScopeCreateUpdate(d *pluginsdk.ResourceData, meta
}
}

ingestionAccessMode := privatelinkscopesapis.AccessMode(d.Get("ingestion_access_mode").(string))
queryaccessMode := privatelinkscopesapis.AccessMode(d.Get("query_access_mode").(string))

parameters := privatelinkscopesapis.AzureMonitorPrivateLinkScope{
Name: &name,
Location: "Global",
Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})),
Properties: privatelinkscopesapis.AzureMonitorPrivateLinkScopeProperties{
AccessModeSettings: privatelinkscopesapis.AccessModeSettings{
IngestionAccessMode: ingestionAccessMode,
QueryAccessMode: queryaccessMode,
},
},
}

if _, err := client.PrivateLinkScopesCreateOrUpdate(ctx, id, parameters); err != nil {
Expand Down Expand Up @@ -119,6 +154,11 @@ func resourceMonitorPrivateLinkScopeRead(d *pluginsdk.ResourceData, meta interfa
if err = d.Set("tags", utils.FlattenPtrMapStringString(model.Tags)); err != nil {
return err
}

props := model.Properties
d.Set("ingestion_access_mode", string(props.AccessModeSettings.IngestionAccessMode))
d.Set("query_access_mode", string(props.AccessModeSettings.QueryAccessMode))

}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2019-10-17-preview/privatelinkscopesapis"
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2021-07-01-preview/privatelinkscopesapis"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestAccMonitorPrivateLinkScope_complete(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data, "Test"),
Config: r.complete(data, "Test", "Open", "Open"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand All @@ -70,14 +70,14 @@ func TestAccMonitorPrivateLinkScope_update(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data, "Test1"),
Config: r.complete(data, "Test1", "Open", "Open"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.complete(data, "Test2"),
Config: r.complete(data, "Test2", "PrivateOnly", "PrivateOnly"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -123,6 +123,7 @@ func (r MonitorPrivateLinkScopeResource) basic(data acceptance.TestData) string
resource "azurerm_monitor_private_link_scope" "test" {
name = "acctest-ampls-%d"
resource_group_name = azurerm_resource_group.test.name

}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -134,21 +135,27 @@ func (r MonitorPrivateLinkScopeResource) requiresImport(data acceptance.TestData
resource "azurerm_monitor_private_link_scope" "import" {
name = azurerm_monitor_private_link_scope.test.name
resource_group_name = azurerm_monitor_private_link_scope.test.resource_group_name

ingestion_access_mode = "Open"
query_access_mode = "Open"
KiPIDesTAN marked this conversation as resolved.
Show resolved Hide resolved
}
`, r.basic(data))
}

func (r MonitorPrivateLinkScopeResource) complete(data acceptance.TestData, tag string) string {
func (r MonitorPrivateLinkScopeResource) complete(data acceptance.TestData, tag string, ingestionAccessMode string, queryAccessMode string) string {
return fmt.Sprintf(`
%s

resource "azurerm_monitor_private_link_scope" "test" {
name = "acctest-AMPLS-%d"
resource_group_name = azurerm_resource_group.test.name

ingestion_access_mode = "%s"
query_access_mode = "%s"

tags = {
ENV = "%s"
}
}
`, r.template(data), data.RandomInteger, tag)
`, r.template(data), data.RandomInteger, ingestionAccessMode, queryAccessMode, tag)
}

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading