Skip to content

Commit

Permalink
fix validation of subscription id of target of automation softeware u…
Browse files Browse the repository at this point in the history
…pdate configuration (#18860)

Co-authored-by: xuwu1 <xuwu1@microsoft.com>
  • Loading branch information
wuxu92 and wuxu92 authored Oct 19, 2022
1 parent ced037f commit 7553745
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2020-01-13-preview/automation"
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
validate4 "github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
validate3 "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/automation/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/automation/validate"
computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate"
Expand Down Expand Up @@ -628,7 +628,7 @@ func (m SoftwareUpdateConfigurationResource) Arguments() map[string]*pluginsdk.S
if len(e) == 0 {
return w, e
}
w, e = validate3.SubscriptionID(i, s)
w, e = commonids.ValidateSubscriptionID(i, s)
return w, e
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func (a SoftwareUpdateConfigurationResource) update(data acceptance.TestData) st
%s
data "azurerm_client_config" "current" {}
resource "azurerm_automation_software_update_configuration" "test" {
automation_account_id = azurerm_automation_account.test.id
name = "acctest-suc-%[2]d"
Expand All @@ -178,7 +180,7 @@ resource "azurerm_automation_software_update_configuration" "test" {
target {
azure_query {
scope = [azurerm_resource_group.test.id]
scope = ["/subscriptions/${data.azurerm_client_config.current.subscription_id}"]
locations = [azurerm_resource_group.test.location]
tags {
tag = "foo"
Expand Down Expand Up @@ -268,7 +270,7 @@ resource "azurerm_automation_software_update_configuration" "test" {

// software update need log analytic location map correct, if use a random location like `East US` will cause
// error like `chosen Azure Automation does not have a Log Analytics workspace linked for operation to succeed`.
// so location hardcode as `West US`
// so location hardcode as `West US`
// see more https://learn.microsoft.com/en-us/azure/automation/how-to/region-mappings
func (a SoftwareUpdateConfigurationResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit 7553745

Please sign in to comment.