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_kubernetes_cluster - parse oms log_analytics_workspace_id to ensure correct casing #9976

Merged
merged 1 commit into from
Jan 5, 2021
Merged
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
12 changes: 10 additions & 2 deletions azurerm/internal/services/containers/kubernetes_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
azureHelpers "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"

laparse "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/parse"
)

const (
Expand Down Expand Up @@ -193,7 +195,11 @@ func expandKubernetesAddOnProfiles(input []interface{}, env azure.Environment) (
enabled := value["enabled"].(bool)

if workspaceID, ok := value["log_analytics_workspace_id"]; ok && workspaceID != "" {
config["logAnalyticsWorkspaceResourceID"] = utils.String(workspaceID.(string))
lawid, err := laparse.LogAnalyticsWorkspaceID(workspaceID.(string))
if err != nil {
return nil, fmt.Errorf("parsing Log Analytics Workspace ID: %+v", err)
}
config["logAnalyticsWorkspaceResourceID"] = utils.String(lawid.ID())
}

addonProfiles[omsAgentKey] = &containerservice.ManagedClusterAddonProfile{
Expand Down Expand Up @@ -344,7 +350,9 @@ func flattenKubernetesAddOnProfiles(profile map[string]*containerservice.Managed

workspaceID := ""
if v := kubernetesAddonProfilelocateInConfig(omsAgent.Config, "logAnalyticsWorkspaceResourceID"); v != nil {
workspaceID = *v
if lawid, err := laparse.LogAnalyticsWorkspaceID(*v); err == nil {
workspaceID = lawid.ID()
}
}

omsagentIdentity := flattenKubernetesClusterOmsAgentIdentityProfile(omsAgent.Identity)
Expand Down