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_application_insight : optional workspace_id set to null when no value set as input. #15576

Closed
pajcarpentier opened this issue Feb 23, 2022 · 4 comments · Fixed by #15621

Comments

@pajcarpentier
Copy link

Hello,

using following terraform version and providers :

`tf_1.1 C:...\Infras\IsolatedWeb - 5.1>terraform -v
Terraform v1.1.6
on windows_amd64

  • provider registry.terraform.io/hashicorp/azurerm v2.97.0
  • provider registry.terraform.io/hashicorp/random v3.1.0
  • provider registry.terraform.io/hashicorp/template v2.2.0`

having the following resource :

resource "azurerm_application_insights" "my_application_insights" { name = module.name.full_name location = var.location tags = var.tags resource_group_name = var.resource_group_name application_type = "web" }

The workspace_id as been set outside of terraform, so when terraform plan we have the following (but workspaci_id is not set as modified) :

`Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the
last "terraform apply":

module.my_app_insight["westeurope_00"].azurerm_application_insights.my_application_insights has changed

~ resource "azurerm_application_insights" "my_application_insights" {
+ force_customer_storage_for_profiler = false
id = "/subscriptions/bc046308-e9d7-4ad4-a8e6-de54fdb5d58f/resourceGroups/z-adf-csa-web-npd-ew1-rgp01/providers/Microsoft.Insights/components/z-adf-csa-web-npd-ew1-ain01"
name = "z-adf-csa-web-npd-ew1-ain01"
tags = {
"global-app" = "CSA"
"global-dataclass" = "Confidential"
"global-dcs" = "DIO"
"global-env" = "NPD"
"global-opco" = "ADF"
"global-project" = "DAFR"
"local-owner" = "[email protected]"
}
# (15 unchanged attributes hidden)
}
`
a terraform plan will figure this output :

`Terraform will perform the following actions:

module.my_app_insight["westeurope_00"].azurerm_application_insights.my_application_insights will be updated in-place

~ resource "azurerm_application_insights" "my_application_insights" {
id = "/subscriptions/bc046308-e9d7-4ad4-a8e6-de54fdb5d58f/resourceGroups/z-adf-csa-web-npd-ew1-rgp01/providers/Microsoft.Insights/components/z-adf-csa-web-npd-ew1-ain01"
name = "z-adf-csa-web-npd-ew1-ain01"
tags = {
"global-app" = "CSA"
"global-dataclass" = "Confidential"
"global-dcs" = "DIO"
"global-env" = "NPD"
"global-opco" = "ADF"
"global-project" = "DAFR"
"local-owner" = "[email protected]"
}
- workspace_id = "(workspace_id)" -> null
# (15 unchanged attributes hidden)
}
`
The workspace_id of the application insights want to be nullify, but no input for this workspace_id as been set.

looking at the azurerm_application_insight component at https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights
it appears that the workspace_id is optionnal, and not set by default to null.

could be fine that this value is not nullify if not set as input.

thank-you,

best regards,

Philippe

@pajcarpentier
Copy link
Author

In fact, Workspace_id is not really set to null.
After apply, the workspace is always set to application insight.

It is only a terraform message that inform the changes, but do not apply it in facts.

@myc2h6o
Copy link
Contributor

myc2h6o commented Feb 28, 2022

Hi @pajcarpentier Thanks for raising the issue. I've been looking at this property and according to the Application Insights Workspace-Based Migration: The migration process is permanent, and cannot be reversed." Although the API doesn't throw an error, it doesn't change the workspace_id. As for updating it to null, you can do a Force Re-creation if the existing data in this resource doesn't matter:
terraform apply -replace="azurerm_application_insights.my_application_insights".
And from the provider side, we'll improve the document to include this

@pajcarpentier
Copy link
Author

pajcarpentier commented Apr 8, 2022

thanks for your answer @myc2h6o.
I can close this issue as comments will be updated :)

@github-actions
Copy link

github-actions bot commented May 9, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2022
@github-actions github-actions bot added this to the v3.12.0 milestone Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants