Skip to content

New Resource - azurerm_log_analytics_workspace_table_custom_log#30800

Merged
sreallymatt merged 23 commits intomainfrom
wyatt/log-analytics-local-new-table-resources-custom-log
Nov 25, 2025
Merged

New Resource - azurerm_log_analytics_workspace_table_custom_log#30800
sreallymatt merged 23 commits intomainfrom
wyatt/log-analytics-local-new-table-resources-custom-log

Conversation

@wyattfry
Copy link
Contributor

@wyattfry wyattfry commented Oct 7, 2025

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

Adds a new resource: azurerm_log_analytics_workspace_table_custom_log

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)
=== RUN   TestAccLogAnalyticsWorkspaceTableCustomLog_basic
=== PAUSE TestAccLogAnalyticsWorkspaceTableCustomLog_basic
=== RUN   TestAccLogAnalyticsWorkspaceTableCustomLog_requiresImport
=== PAUSE TestAccLogAnalyticsWorkspaceTableCustomLog_requiresImport
=== RUN   TestAccLogAnalyticsWorkspaceTableCustomLog_complete
=== PAUSE TestAccLogAnalyticsWorkspaceTableCustomLog_complete
=== RUN   TestAccLogAnalyticsWorkspaceTableCustomLog_update
=== PAUSE TestAccLogAnalyticsWorkspaceTableCustomLog_update
=== RUN   TestAccLogAnalyticsWorkspaceTableCustomLog_planBasic
=== PAUSE TestAccLogAnalyticsWorkspaceTableCustomLog_planBasic
=== CONT  TestAccLogAnalyticsWorkspaceTableCustomLog_basic
=== CONT  TestAccLogAnalyticsWorkspaceTableCustomLog_update
=== CONT  TestAccLogAnalyticsWorkspaceTableCustomLog_complete
=== CONT  TestAccLogAnalyticsWorkspaceTableCustomLog_planBasic
=== CONT  TestAccLogAnalyticsWorkspaceTableCustomLog_requiresImport
--- PASS: TestAccLogAnalyticsWorkspaceTableCustomLog_requiresImport (163.71s)
--- PASS: TestAccLogAnalyticsWorkspaceTableCustomLog_basic (167.89s)
--- PASS: TestAccLogAnalyticsWorkspaceTableCustomLog_planBasic (184.24s)
--- PASS: TestAccLogAnalyticsWorkspaceTableCustomLog_complete (204.12s)
--- PASS: TestAccLogAnalyticsWorkspaceTableCustomLog_update (303.90s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/loganalytics  305.818s

Change Log

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

  • azurerm_resource - support for the thing1 property [GH-00000]

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)

Fixes #0000

AI Assistance Disclosure

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

Rollback Plan

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

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @wyattfry, thanks for this PR. Left some comments around some of the design decisions


"type": {
Type: pluginsdk.TypeString,
Required: true,
Copy link
Member

Choose a reason for hiding this comment

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

Since this is Required, you should move it above any optional properties in the schema

Plan: pointer.To(tables.TablePlanEnum(config.Plan)),
Schema: &tables.Schema{
Categories: pointer.To(config.Categories),
Columns: expandColumns(&config.Columns),
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to pass the address here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! Changed to take the struct instead of pointer.


if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
if pointer.From(props.Plan) == tables.TablePlanEnumAnalytics {
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused about this whole check. Can you give some context for why this is here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to clarify with variable naming. Better?

state.Solutions = pointer.From(props.Schema.Solutions)

// The `Categories` property is not retrievable, we attempt to obtain from config. Imports will need `ignore_changes`.
if props.Schema.Categories != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Having an if that doesn't do anything past the check seems odd. I'm for removing categories altogether but something to keep in mind if you see something like this in the future

},
},

"retention_in_days": {
Copy link
Member

Choose a reason for hiding this comment

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

And O+C this

@wyattfry
Copy link
Contributor Author

make depscheck should pass once #30839 is merged.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @wyattfry, thanks for addressing those comments. Left a few more but we're getting there

Comment on lines +80 to +81
Type: pointer.To(tables.ColumnTypeEnum(column.Type)),
DataTypeHint: pointer.To(tables.ColumnDataTypeHintEnum(column.TypeHint)),
Copy link
Member

Choose a reason for hiding this comment

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

These should be wrapped in pointer.ToEnum instead


var defaultRetentionInDaysSentinelValue = pointer.To(int64(-1))

type Column struct {
Copy link
Member

Choose a reason for hiding this comment

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

In case Column isn't unique later down the line, we should be more explicit and expand this out to something likeWorkspaceTableColumn

Comment on lines +294 to +301
planAllowsCustomRetention := props.Plan != nil && *props.Plan == tables.TablePlanEnumAnalytics
if planAllowsCustomRetention {
if !pointer.From(props.RetentionInDaysAsDefault) {
state.RetentionInDays = pointer.From(props.RetentionInDays)
}
if !pointer.From(props.TotalRetentionInDaysAsDefault) {
state.TotalRetentionInDays = pointer.From(props.TotalRetentionInDays)
}
Copy link
Member

Choose a reason for hiding this comment

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

If this is O+C, do we even need to check if we want to set this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose not.

Comment on lines +360 to +372
if metadata.ResourceData.HasChange("retention_in_days") {
props.RetentionInDays = defaultRetentionInDaysSentinelValue
if config.RetentionInDays != 0 {
props.RetentionInDays = pointer.To(config.RetentionInDays)
}
}

if metadata.ResourceData.HasChange("total_retention_in_days") {
props.TotalRetentionInDays = pointer.To(config.TotalRetentionInDays)
if config.TotalRetentionInDays == 0 {
props.TotalRetentionInDays = defaultRetentionInDaysSentinelValue
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason the logic here is flipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just an oversight, I'll make them the same.

Copy link
Member

Choose a reason for hiding this comment

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

Should this should be moved up above the ---?

@mbfrahry
Copy link
Member

Also a test is failing

=== CONT  TestAccLogAnalyticsWorkspaceTableCustomLog_planBasic
    testcase.go:173: Step 1/3 error: Error running apply: exit status 1
        Error: creating Data Collection Rule (Subscription: "*******"
        Resource Group Name: "acctestRG-251021175350599834"
        Data Collection Rule Name: "acctestdcr-251021175350599834"): unexpected status 400 (400 Bad Request) with error: InvalidPayload: Data collection rule is invalid
          with azurerm_monitor_data_collection_rule.test,
          on terraform_plugin_test.tf line 52, in resource "azurerm_monitor_data_collection_rule" "test":
          52: resource "azurerm_monitor_data_collection_rule" "test" {
        creating Data Collection Rule (Subscription:
        "*******"
        Resource Group Name: "acctestRG-251021175350599834"
        Data Collection Rule Name: "acctestdcr-251021175350599834"): unexpected
        status 400 (400 Bad Request) with error: InvalidPayload: Data collection rule
        is invalid
--- FAIL: TestAccLogAnalyticsWorkspaceTableCustomLog_planBasic (150.86s)
FAIL

wyattfry and others added 8 commits November 7, 2025 09:28
Co-authored-by: Matthew Frahry <mbfrahry@gmail.com>
Co-authored-by: sreallymatt <106555974+sreallymatt@users.noreply.github.com>
@sreallymatt sreallymatt force-pushed the wyatt/log-analytics-local-new-table-resources-custom-log branch from c2dee3a to dd79a33 Compare November 7, 2025 16:29
@sreallymatt
Copy link
Collaborator

Updated test results:
image

@sreallymatt sreallymatt requested a review from a team November 7, 2025 20:55
@MatthiasHuygelen
Copy link

MatthiasHuygelen commented Nov 19, 2025

Any timeframe for when this will be further reviewed ?

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @sreallymatt, this looks good but I did find one minor issue if you want to take a look

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM

@sreallymatt sreallymatt merged commit 3812491 into main Nov 25, 2025
50 checks passed
@sreallymatt sreallymatt deleted the wyatt/log-analytics-local-new-table-resources-custom-log branch November 25, 2025 15:43
@github-actions github-actions bot added this to the v4.55.0 milestone Nov 25, 2025
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 Dec 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants