Skip to content

azurerm_kusto_attached_database_configuration - Add support for database_name_override, database_name_prefix, functions_to_exclude, and functions_to_include properties#31470

Merged
sreallymatt merged 10 commits intohashicorp:mainfrom
liuwuliuyun:kusto-attached-db
Mar 31, 2026
Merged

azurerm_kusto_attached_database_configuration - Add support for database_name_override, database_name_prefix, functions_to_exclude, and functions_to_include properties#31470
sreallymatt merged 10 commits intohashicorp:mainfrom
liuwuliuyun:kusto-attached-db

Conversation

@liuwuliuyun
Copy link
Copy Markdown
Collaborator

@liuwuliuyun liuwuliuyun commented Jan 9, 2026

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

This PR adds support for the following new properties to the azurerm_kusto_attached_database_configuration resource:

Top-level properties:

  • database_name_override - Overrides the original database name. Relevant only when attaching to a specific database.
  • database_name_prefix - Adds a prefix to the attached databases name. When following an entire cluster, that prefix would be added to all of the databases' original names from the leader cluster.

Properties in the sharing block:

  • functions_to_exclude - List of functions to exclude from the follower database.
  • functions_to_include - List of functions to include in the follower database.

These properties are already supported by the Azure API (2024-04-13) and the underlying SDK but were not exposed in the Terraform resource.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: "resource_name_here - description of change e.g. adding property new_property_name_here"

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

New Test Cases Added:

  • TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride - Tests the database_name_override property
  • TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix - Tests the database_name_prefix property with database_name = "*"
=== RUN   TestAccKustoAttachedDatabaseConfiguration_basic
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_basic
=== CONT  TestAccKustoAttachedDatabaseConfiguration_basic
--- PASS: TestAccKustoAttachedDatabaseConfiguration_basic (1326.36s)
PASS

Process finished with the exit code 0

=== RUN   TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride
=== CONT  TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride
--- PASS: TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride (1223.11s)
PASS


Process finished with the exit code 0

=== RUN   TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix
=== CONT  TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix
--- PASS: TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix (1355.98s)
PASS


Process finished with the exit code 0

=== RUN   TestAccKustoAttachedDatabaseConfiguration_clusterResourceId
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_clusterResourceId
=== CONT  TestAccKustoAttachedDatabaseConfiguration_clusterResourceId
--- PASS: TestAccKustoAttachedDatabaseConfiguration_clusterResourceId (1264.74s)
PASS


Process finished with the exit code 0

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

AI Assistance Disclosure

  • AI Assisted - This contribution was made by, or with the assistance of, AI/LLMs

This PR was created with the assistance of GitHub Copilot for code generation, test cases, and documentation updates.

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the provider.

Changes to Security Controls

No changes to security controls in this pull request.

@liuwuliuyun liuwuliuyun changed the title azurerm_kusto_attached_database_configuration - support for database related properties azurerm_kusto_attached_database_configuration - Add support for database_name_override, database_name_prefix, functions_to_exclude, and functions_to_include properties Jan 9, 2026
@liuwuliuyun liuwuliuyun marked this pull request as ready for review January 9, 2026 08:03
@liuwuliuyun liuwuliuyun requested review from a team, WodansSon and magodo as code owners January 9, 2026 08:03
@ziyeqf
Copy link
Copy Markdown
Collaborator

ziyeqf commented Jan 13, 2026

Thanks @liuwuliuyun, just one minor question, mostly LGTM

Copy link
Copy Markdown
Collaborator

@magodo magodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR!
I've taken a look through and left some comments inline, but this is mostly looking good to me 👍

…down

Co-authored-by: magodo <wztdyl@sina.com>
magodo
magodo previously approved these changes Jan 13, 2026
"database_name_override": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption is this will have similar limitations as the database_name field (minus the asterisk * as a valid option), validation should be improved. Please confirm and update.

As an example, there definitely are characters that are not supported:

│ Status: "Failed"
│ Code: "BadRequest_EntityNameIsNotValid"
│ Message: "[BadRequest] 'myspecialName@!@#%^^&': 'Name' is not valid for entities of kind 'DatabaseName'. Reason='DatabaseName: Name='myspecialName@!@#%^^&' does not comply with naming rules (contains invalid characters or format mismatch)'"

reference

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will add validation for database name and prefix

"database_name_prefix": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment above, this needs better validation

│ Status: "Failed"
│ Code: "BadRequest_EntityNameIsNotValid"
│ Message: "[BadRequest] 'myspecialPrefix@!@#%^^&acctestkd2-0217': 'Name' is not valid for entities of kind 'DatabaseName'. Reason='DatabaseName: Name='myspecialPrefix@!@#%^^&acctestkd2-0217' does not comply with naming rules (contains invalid characters or format mismatch)'"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This process is a bit complex. Creating and deleting a Kusto cluster and its database can take over two hours. Even after the resource is deleted, it may still appear in the resource group list due to a cache consistency issue in ARM, which can cause the process to timeout repeatedly. If you want the acctest to run until completion, you’ll need to add this flag.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to remove this and run tests locally to see if it works.

Comment on lines +254 to +293
resource "azurerm_resource_group" "rg" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_kusto_cluster" "cluster1" {
name = "acctestkc1%s"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name

sku {
name = "Dev(No SLA)_Standard_D11_v2"
capacity = 1
}
}

resource "azurerm_kusto_cluster" "cluster2" {
name = "acctestkc2%s"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name

sku {
name = "Dev(No SLA)_Standard_D11_v2"
capacity = 1
}
}

resource "azurerm_kusto_database" "followed_database" {
name = "acctestkd-%d"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
cluster_name = azurerm_kusto_cluster.cluster1.name
}

resource "azurerm_kusto_database" "test" {
name = "acctestkd2-%d"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
cluster_name = azurerm_kusto_cluster.cluster2.name
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a template() function that contains all of these dependencies so there's no need to copy-paste the same config

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, why is this needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same above

@liuwuliuyun
Copy link
Copy Markdown
Collaborator Author

Latest testing results:

PS C:\Users\yunliu1\Documents\terraform-provider-azurerm> go test -v -timeout 120m -run "TestAccKustoAttachedDatabaseConfiguration_basic" ./internal/services/kusto/
=== RUN   TestAccKustoAttachedDatabaseConfiguration_basic
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_basic
=== CONT  TestAccKustoAttachedDatabaseConfiguration_basic
--- PASS: TestAccKustoAttachedDatabaseConfiguration_basic (1484.27s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto 1502.622s
PS C:\Users\yunliu1\Documents\terraform-provider-azurerm> go test -v -timeout 120m -run "TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride" ./internal/services/kusto/
=== RUN   TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride
=== CONT  TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride
--- PASS: TestAccKustoAttachedDatabaseConfiguration_databaseNameOverride (1349.41s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto 1369.040s
PS C:\Users\yunliu1\Documents\terraform-provider-azurerm> go test -v -timeout 120m -run "TestAccKustoAttachedDatabaseConfiguration_update" ./internal/services/kusto/              
=== RUN   TestAccKustoAttachedDatabaseConfiguration_update
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_update
=== CONT  TestAccKustoAttachedDatabaseConfiguration_update
--- PASS: TestAccKustoAttachedDatabaseConfiguration_update (1559.69s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto 1567.957s
PS C:\Users\yunliu1\Documents\terraform-provider-azurerm> go test -v -timeout 120m -run "TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix" ./internal/services/kusto/
=== RUN   TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix
=== CONT  TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix
--- PASS: TestAccKustoAttachedDatabaseConfiguration_databaseNamePrefix (1307.91s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto 1316.266s
PS C:\Users\yunliu1\Documents\terraform-provider-azurerm> go test -v -timeout 120m -run "TestAccKustoAttachedDatabaseConfiguration_clusterResourceId" ./internal/services/kusto/
=== RUN   TestAccKustoAttachedDatabaseConfiguration_clusterResourceId
=== PAUSE TestAccKustoAttachedDatabaseConfiguration_clusterResourceId
=== CONT  TestAccKustoAttachedDatabaseConfiguration_clusterResourceId
--- PASS: TestAccKustoAttachedDatabaseConfiguration_clusterResourceId (1284.11s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto 1291.225s

@liuwuliuyun
Copy link
Copy Markdown
Collaborator Author

Hi @sreallymatt , I've addressed all the review feedback. Here's a summary of the changes:

  1. Validation for database_name_override and database_name_prefix — Replaced validation.StringIsNotEmpty with validate.DatabaseName on both fields, which enforces the Kusto database naming rules (alphanumeric, whitespace, dashes, underscores, dots only).

  2. ConflictsWith on database_name_override / database_name_prefix — Added ConflictsWith on both fields so they cannot be set simultaneously, and added a corresponding note in the documentation.

  3. database_name_override invalid when database_name is * — Added a CustomizeDiff that returns an error if database_name_override is set while database_name is *.

  4. Update test — Added TestAccKustoAttachedDatabaseConfiguration_update that goes from basiccomplete, where the complete config includes multiple strings in each set field (e.g., ["Function1", "Function2"]).

  5. Shared template() function — Extracted all common dependencies (resource group, clusters, databases) into a template() function to eliminate copy-paste across test configs.

  6. Removed prevent_deletion_if_contains_resources = false — Removed the unnecessary provider feature flag from the test configs.

All tests pass locally. Could you please take another look when you get a chance? Thanks!

@liuwuliuyun liuwuliuyun requested a review from sreallymatt March 6, 2026 07:15
@magodo magodo removed their assignment Mar 7, 2026
Copy link
Copy Markdown
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @liuwuliuyun - LGTM ✅

@sreallymatt sreallymatt merged commit 8bb30b3 into hashicorp:main Mar 31, 2026
32 checks passed
@github-actions github-actions bot added this to the v4.67.0 milestone Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants