-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource: azurerm_monitor_diagnostic_setting
/ New Data Source: azurerm_monitor_diagnostic_categories
#1291
New Resource: azurerm_monitor_diagnostic_setting
/ New Data Source: azurerm_monitor_diagnostic_categories
#1291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @janboll
Thanks for this PR :)
I've taken a look through and left some comments in-line and have tried to provide code samples for all of the issues I've raised - but this is off to a good start 👍
Thanks!
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
DiffSuppressFunc: ignoreCaseDiffSuppressFunc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove the DiffSuppressFunc
here, since this should force a recreation if the casing changes on the resource we're monitoring?
return err | ||
} | ||
if read.ID == nil { | ||
return fmt.Errorf("Cannot read Diagnostic Settings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this error message clearer to match the other resources? e.g. fmt.Errorf("Cannot read ID for Monitor Diagnostics %q", name)
1ffa1f6
to
a70de22
Compare
I had to change the schema cause of the way the Azure API behaves. If you omit one of MetricSettings or LogSettings it will just create these loggings with default settings instead of skipping them. |
This comment has been minimized.
This comment has been minimized.
Hi @tombuildsstuff did you have time to check on my changes yet? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6ed0caf
to
5c0ae0c
Compare
@janboll apologies for the really delayed re-review here - I'm going to take another look through this |
@janboll hey - just to let you know that I'm taking a look at this at the moment. As a part of this I've pulled the code locally to read through properly, and have rebased this on top of master/switched to using the same API as the rest of the resources which use the |
5c0ae0c
to
a433d5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @janboll
Thanks for pushing those updates / apologies for the delayed review here!
I've pushed a couple of commits to rebase this and then fix the ID as mentioned in the comments/add some TODO's. Taking a look through this I think the schema needs some tweaking to get it right, in particular I think we need to add a data source to return the available (Metrics/Logs) Categories for a particular Diagnostic Setting, and probably look at the schema for the Metric and Log fields, since I think these want to be nested blocks; what do you think?
Thanks!
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
DiffSuppressFunc: ignoreCaseDiffSuppressFunc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove the DiffSuppressFunc
from this? in addition we can validate this using ValidateFunc: azure.ValidateResourceID
(rather than the azure.ValidateResourceIDOrEmpty
which is intended for optional fields)
azurerm/monitor_diagnostics.go
Outdated
func retrieveDiagnosticName(diagnosticSettingId string) string { | ||
substring := "/providers/microsoft.insights/diagnosticSettings/" | ||
return diagnosticSettingId[len(substring)+strings.Index(diagnosticSettingId, substring):] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on reflection I feel like a less brittle way of doing this would be to compose our own resource ID of {targetResourceID}|{name}
since some of the Azure API's are case sensitive - I'm going to push a commit to fix this.
0b9a331
to
65e8b01
Compare
@janboll apologies this has sat for a little while - I hope you don't mind but I've pushed a commit to rebase this on top of master so we can proceed with this :) |
Add testCheckAzureRMMonitorDiagnosticsDestroy function
… etc Adding some TODO's around the Schema Ensuring fields are always set
Tests pass: ``` $ acctests azurerm TestAccDataSourceArmMonitorDiagnosticCategories_ === RUN TestAccDataSourceArmMonitorDiagnosticCategories_appService --- PASS: TestAccDataSourceArmMonitorDiagnosticCategories_appService (150.71s) === RUN TestAccDataSourceArmMonitorDiagnosticCategories_storageAccount --- PASS: TestAccDataSourceArmMonitorDiagnosticCategories_storageAccount (108.97s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 261.573s ```
6c0c2fa
to
83f9ff4
Compare
azurerm_monitor_diagnostic_setting
/ New Data Source: azurerm_monitor_diagnostic_categories
dismissing since changes have been pushed
``` $ acctests azurerm TestAccAzureRMMonitorDiagnosticSetting_ === RUN TestAccAzureRMMonitorDiagnosticSetting_eventhub === PAUSE TestAccAzureRMMonitorDiagnosticSetting_eventhub === RUN TestAccAzureRMMonitorDiagnosticSetting_logAnalyticsWorkspace === PAUSE TestAccAzureRMMonitorDiagnosticSetting_logAnalyticsWorkspace === RUN TestAccAzureRMMonitorDiagnosticSetting_storageAccount === PAUSE TestAccAzureRMMonitorDiagnosticSetting_storageAccount === CONT TestAccAzureRMMonitorDiagnosticSetting_eventhub --- PASS: TestAccAzureRMMonitorDiagnosticSetting_eventhub (282.77s) === CONT TestAccAzureRMMonitorDiagnosticSetting_storageAccount --- PASS: TestAccAzureRMMonitorDiagnosticSetting_storageAccount (219.99s) === CONT TestAccAzureRMMonitorDiagnosticSetting_logAnalyticsWorkspace --- PASS: TestAccAzureRMMonitorDiagnosticSetting_logAnalyticsWorkspace (215.82s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 719.066s ```
b344abf
to
c3d9d1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left some comments inline, most pretty innocuous. The one thing that stands out to me is what will happen if one or more of eventhub_authorization_rule_id
, log_analytics_workspace_id
or storage_account_id
is set?
correct log string
@janboll thanks for pushing those changes 👍 Apologies (as I'd meant to post this yesterday) / for the delayed re-review here - I hope you don't mind, but I pushed some commits to update this resource (and added a Data Source) to better match the representation in Azure so that we can get this merged :) Thanks! |
@tombuildsstuff Thanks, really appreciate help on this PR! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @tombuildsstuff 👍
The examples appear to be missing from the documentation. Has this been logged as an issue? |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Hi,
I implemented a new resource to be able to configure diagnostic settings on any given resource (fixes #657). I am opening this PR to request feedback as soon as possible.
There are still open points
Please have a look at the PR and check if I am steering into the right direction.
Thanks,
Jan