Azure / aks-baseline-automation

Repository for the AKS Landing Zone Accelerator program's Automation reference implementation
MIT License
78 stars 137 forks source link

Diagnostics - Retention policy causing resource creation failure #122

Open gstevens-kyriba opened 2 months ago

gstevens-kyriba commented 2 months ago

It seems many of the CARML modules enable Diagnostic Logging on the resources created. However, it seems this has changed and several resources won't create due to the retention policy setting. The error is:

Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Diagnostic settings does not support retention for new diagnostic settings."

I'm working around it by commenting out the retentionPolicy on various resources to get them to create.
I've commented out the retention policy on:

bicep\CARML\Microsoft.ContainerRegistry\registries\deploy.bicep bicep\CARML\Microsoft.Network\applicationGateways\deploy.bicep bicep\CARML\Microsoft.Network\azureFirewalls\deploy.bicep bicep\CARML\Microsoft.Network\bastionHosts\deploy.bicep bicep\CARML\Microsoft.Network\networkSecurityGroups\deploy.bicep bicep\CARML\Microsoft.Network\virtualNetworks\deploy.bicep

var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs'): { category: category enabled: true // retentionPolicy: { // enabled: true // days: diagnosticLogsRetentionInDays // } }]

var diagnosticsLogs = contains(diagnosticLogCategoriesToEnable, 'allLogs') ? [ { categoryGroup: 'allLogs' enabled: true // retentionPolicy: { // enabled: true // days: diagnosticLogsRetentionInDays // } } ] : diagnosticsLogsSpecified

var diagnosticsMetrics = [for metric in diagnosticMetricsToEnable: { category: metric timeGrain: null enabled: true // retentionPolicy: { // enabled: true // days: diagnosticLogsRetentionInDays // } }]

gstevens-kyriba commented 2 months ago

Looks like a similar issue here, resolved in a similar manner: https://github.com/hashicorp/terraform-provider-azurerm/issues/23051