terraform-provider-azurerm
terraform-provider-azurerm copied to clipboard
azurerm_log_analytics_linked_storage_account - data_storage_type - case validation
Is there an existing issue for this?
- [X] I have searched the existing issues
Community Note
- Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
1.1.7
AzureRM Provider Version
3.0.2
Affected Resource(s)/Data Source(s)
azurerm_log_analytics_linked_storage_account
Terraform Configuration Files
resource "azurerm_log_analytics_linked_storage_account" "main" {
data_source_type = "customlogs"
resource_group_name = data.terraform_remote_state.tf_monitoring.outputs.resource_group_name
workspace_resource_id = data.terraform_remote_state.tf_monitoring.outputs.core_azurerm_log_analytics_workspace_id
storage_account_ids = [azurerm_storage_account.main.id]
}
Debug Output/Panic Output
On reapply only you get
# azurerm_log_analytics_linked_storage_account.main must be replaced
-/+ resource "azurerm_log_analytics_linked_storage_account" "main" {
~ data_source_type = "CustomLogs" -> "customlogs" # forces replacement
~ id = "xxxxxxxxxxxxxxxxxx" -> (known after apply)
# (3 unchanged attributes hidden)
}
Expected Behaviour
Plans and applies ok every time
Actual Behaviour
Plans and applies ok the first time without issue but on subsequent plans and applies gives the above output. It looks like the case of data_source_type is being changed by the API upon apply
If you change the code to be
resource "azurerm_log_analytics_linked_storage_account" "main" {
data_source_type = "CustomLogs"
resource_group_name = data.terraform_remote_state.tf_monitoring.outputs.resource_group_name
workspace_resource_id = data.terraform_remote_state.tf_monitoring.outputs.core_azurerm_log_analytics_workspace_id
storage_account_ids = [azurerm_storage_account.main.id]
}
You get the following validation error
Error: expected data_source_type to be one of [customlogs azurewatson query alerts ingestion], got CustomLogs
Steps to Reproduce
No response
Important Factoids
No response
References
No response
Do we know whether this is a Terraform or Azure API issue?
this is still happening on provider version 3.16
# module.backend.azurerm_log_analytics_linked_storage_account.whatevs must be replaced
-/+ resource "azurerm_log_analytics_linked_storage_account" "prisma-analytics-or-whatevs" {
~ data_source_type = "CustomLogs" -> "customlogs" # forces replacement
~ id = "/subscriptions/<myprod>/resourceGroups/<myprod>/providers/Microsoft.OperationalInsights/workspaces/<myprod>/linkedStorageAccounts/customlogs" -> (known after apply)
# (3 unchanged attributes hidden)
}
and of course the obligatory:
t version
Terraform v0.14.11
+ provider registry.terraform.io/hashicorp/azuread v2.26.1
+ provider registry.terraform.io/hashicorp/azurerm v3.16.0
+ provider registry.terraform.io/hashicorp/tls v4.0.1
I understand this is an older version of terraform binary
Hi @w0rldart and @capusta , thanks for the comment. Seems this issue should be fixed in PR https://github.com/hashicorp/terraform-provider-azurerm/pull/16313, and the config should set as below using lower case:
data_source_type = "customlogs"
if there is still diff ("CustomLogs" -> "customlogs"
) shown after Terraform plan
, you can try to use Terraform refresh
to refresh the state, and then run Terraform plan
. If you still have the issue after doing the refresh, feel free to reply here.
Thank you for your reply @teowa, but besides updating the Terraform provider version to 3.19.1
, and running terraform refresh && terraform apply
, I still face this issue.
@w0rldart thanks for the update. Seems I cannot repro your issue by creating a new linkedStorageAccount resource with the latest azurerm provider 3.19.1
or the old 3.1.0
with Terraform config in this link . Looks like service has changed API behaviour. Could you please try calling the REST API to GET the linkedStorageAccounts you have created before, here is a tutorial of calling Azure REST API.
GET https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}/linkedStorageAccounts/customlogs?api-version=2020-08-01
And please check if the dataSourceType
is in lower case. If the property is still the Camel format like CustomLogs
, it should be a service API bug.
@teowa since I have the same issue, I checked via the API. I'm running 3.19.1 as well. I get the following
`> curl -X GET -H "Authorization: Bearer $tk" -H "Content-Type:application/json" -H "Accept:application/json" https://management.azure.com//subscriptions/1234*****/resourceGroups/test-e3a644d5/providers/Microsoft.OperationalInsights/workspaces/test-law/linkedStorageAccounts/customlogs?api-version=2020-08-01
{"properties":{"dataSourceType":"CustomLogs","storageAccountIds":["/subscriptions/1234*****/resourceGroups/test-e3a644d5/providers/Microsoft.Storage/storageAccounts/satest00"]},"location":"northcentralus","id":"/subscriptions/1234*****/resourceGroups/test-e3a644d5/providers/Microsoft.OperationalInsights/workspaces/test-law/linkedstorageaccounts/CustomLogs","name":"CustomLogs","type":"Microsoft.OperationalInsights/workspaces/linkedstorageaccounts"}%`
Hi
data_source_type = "customlogs"
if there is still diff (
"CustomLogs" -> "customlogs"
) shown afterTerraform plan
, you can try to useTerraform refresh
to refresh the state, and then runTerraform plan
. If you still have the issue after doing the refresh, feel free to reply here.
still having the same issue :( I have done a refresh.
# module.backend.azurerm_log_analytics_linked_storage_account.mything must be replaced
-/+ resource "azurerm_log_analytics_linked_storage_account" "mything" {
~ data_source_type = "CustomLogs" -> "customlogs" # forces replacement
~ id = "/subscriptions/<clip>
# (3 unchanged attributes hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
Warning: Resource targeting is in effect
<clip>
Terraform specifically suggests to use it as part of an error message.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
% t version
Terraform v0.14.11
+ provider registry.terraform.io/hashicorp/azuread v1.5.1
+ provider registry.terraform.io/hashicorp/azurerm v3.19.1
+ provider registry.terraform.io/hashicorp/random v3.3.2
+ provider registry.terraform.io/hashicorp/tls v4.0.1
Your version of Terraform is out of date! The latest version
is 1.2.8. You can update by downloading from https://www.terraform.io/downloads.html
The issue is releated to service API issue https://github.com/Azure/azure-rest-api-specs/issues/20619, cases sensitivity differs with locations.
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.