-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(grafana): add dialogporten test #1192
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces new Terraform configuration changes for Azure infrastructure, specifically in the Changes
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
infrastructure/adminservices-test/altinn-monitor-test-rg/data.tf
(1 hunks)infrastructure/adminservices-test/altinn-monitor-test-rg/grafana.tf
(2 hunks)
🧰 Additional context used
📓 Learnings (1)
infrastructure/adminservices-test/altinn-monitor-test-rg/data.tf (1)
Learnt from: monteiro-renato
PR: Altinn/altinn-platform#1138
File: infrastructure/adminservices-test/altinn-monitor-test-rg/lasttest.tf:1-10
Timestamp: 2024-11-27T09:21:33.566Z
Learning: In the `infrastructure/adminservices-test/altinn-monitor-test-rg` Terraform configuration, it's acceptable to add resources like `azurerm_resource_group` and `azurerm_monitor_workspace` without including additional variables, outputs, provider, or backend configurations.
🔇 Additional comments (4)
infrastructure/adminservices-test/altinn-monitor-test-rg/data.tf (2)
4-7
: LGTM: Resource group data source configuration is correct.
The resource group data source is properly configured with:
- Consistent naming convention (dp-be-test-rg)
- Appropriate location (norwayeast)
9-12
: LGTM: Log Analytics workspace data source is properly configured.
The configuration correctly references the resource group name using the data source dependency.
infrastructure/adminservices-test/altinn-monitor-test-rg/grafana.tf (2)
44-50
: LGTM: Monitoring Reader role assignment for Dialogporten test resource group.
The role assignment is properly configured with:
- Correct scope using the data source
- Appropriate role definition ID
- System-assigned identity from Grafana
Line range hint 44-110
: Verify the role assignments in Azure Portal.
Please ensure that:
- The Grafana managed identity has the correct permissions
- The role assignments are properly scoped
- The Log Analytics workspace is accessible from Grafana
resource "azurerm_role_assignment" "log_analytics_reader" { | ||
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id | ||
scope = data.azurerm_log_analytics_workspace.dp_law_test.id | ||
role_definition_name = "Log Analytics Reader" | ||
skip_service_principal_aad_check = true | ||
} |
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.
Resource naming conflict: Duplicate resource name 'log_analytics_reader'.
There's already an existing resource named log_analytics_reader
(line ~100). Terraform requires unique resource names within the same configuration.
Rename the resource to avoid the conflict:
-resource "azurerm_role_assignment" "log_analytics_reader" {
+resource "azurerm_role_assignment" "log_analytics_reader_dp" {
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id
scope = data.azurerm_log_analytics_workspace.dp_law_test.id
role_definition_name = "Log Analytics Reader"
skip_service_principal_aad_check = true
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
resource "azurerm_role_assignment" "log_analytics_reader" { | |
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id | |
scope = data.azurerm_log_analytics_workspace.dp_law_test.id | |
role_definition_name = "Log Analytics Reader" | |
skip_service_principal_aad_check = true | |
} | |
resource "azurerm_role_assignment" "log_analytics_reader_dp" { | |
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id | |
scope = data.azurerm_log_analytics_workspace.dp_law_test.id | |
role_definition_name = "Log Analytics Reader" | |
skip_service_principal_aad_check = true | |
} |
resource "azurerm_role_assignment" "grafana_identity_reader_rg_dp_test" { | ||
scope = "/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4" | ||
role_definition_name = "Monitoring Reader" | ||
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id | ||
skip_service_principal_aad_check = true | ||
} |
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.
🛠️ Refactor suggestion
Replace hardcoded subscription ID with a variable or data source.
The subscription ID is hardcoded in the scope. This makes the configuration less maintainable and portable across environments.
Consider using the existing data source:
- scope = "/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4"
+ scope = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
resource "azurerm_role_assignment" "grafana_identity_reader_rg_dp_test" { | |
scope = "/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4" | |
role_definition_name = "Monitoring Reader" | |
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id | |
skip_service_principal_aad_check = true | |
} | |
resource "azurerm_role_assignment" "grafana_identity_reader_rg_dp_test" { | |
scope = "/subscriptions/${data.azurerm_client_config.current.subscription_id}" | |
role_definition_name = "Monitoring Reader" | |
principal_id = azurerm_dashboard_grafana.grafana.identity[0].principal_id | |
skip_service_principal_aad_check = true | |
} |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
infrastructure/adminservices-test/altinn-monitor-test-rg/providers.tf (1)
24-24
: Add documentation for the Dialogporten providerConsider adding a more detailed comment explaining the purpose of this provider and its relationship with the monitoring infrastructure. This will help future maintainers understand the separation of concerns between the two subscriptions.
-# Dialogporten +# Dialogporten provider configuration +# This provider is used to access monitoring resources in the Dialogporten subscription +# for integration with the main monitoring infrastructure
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
infrastructure/adminservices-test/altinn-monitor-test-rg/data.tf
(1 hunks)infrastructure/adminservices-test/altinn-monitor-test-rg/providers.tf
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- infrastructure/adminservices-test/altinn-monitor-test-rg/data.tf
🔇 Additional comments (1)
infrastructure/adminservices-test/altinn-monitor-test-rg/providers.tf (1)
25-30
: Verify pre-registered providers in the Dialogporten subscription
The configuration looks correct, but since skip_provider_registration = true
is set, please ensure that all necessary Azure resource providers are pre-registered in the Dialogporten subscription (8a353de8-d81d-468d-a40d-f3574b6bb3f4).
Terraform environment testFormat and Style 🖌
|
Context | Values |
---|---|
Pusher | @sduranc |
Action | push |
Working Directory | ./infrastructure/adminservices-test/altinn-monitor-test-rg |
State File | github.com/altinn/altinn-platform/environments/test/altinn-monitor-test-rg.tfstate |
Plan File | github.com_altinn_altinn-platform_environments_test_altinn-monitor-test-rg.tfstate.tfplan |
Description
Related Issue(s)
Verification
Documentation
Summary by CodeRabbit
New Features
Bug Fixes