Skip to content
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

Additional WAF tflint rules #71

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions waf/azurerm_app_service_plan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package waf

import "github.com/Azure/tflint-ruleset-avm/attrvalue"

func (wf WafRules) AzurermAppServicePlanZoneRedundant() *attrvalue.SimpleRule[bool] {
return attrvalue.NewSimpleRule[bool](
"azurerm_app_service_plan",
"zone_redundant",
[]bool{true},
"https://learn.microsoft.com/en-us/azure/reliability/reliability-app-service?tabs=cli#-asp-2--use-an-app-service-plan-that-supports-availability-zones",
false,
"",
)
}
12 changes: 12 additions & 0 deletions waf/azurerm_cosmosdb_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ func (wf WafRules) AzurermCosmosDbAccountBackupMode() *attrvalue.SimpleRule[stri
"",
)
}

func (wf WafRules) AzurermCosmosDbAccountFailoverEnabled() *attrvalue.SimpleRule[bool] {
return attrvalue.NewSimpleRule[bool](
"azurerm_cosmosdb_account",
"automatic_failover_enabled",
[]bool{true},
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/ContainerService/managedClusters/#enable-the-cluster-auto-scaler-on-an-existing-cluster",
false,
"",
)
}

32 changes: 32 additions & 0 deletions waf/azurerm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,35 @@ func (wf WafRules) AzurermKubernetesClusterZones() *attrvalue.SetRule[int] {
"",
)
}

func (wf WafRules) AzurermKubernetesClusterSkuTier() *attrvalue.SimpleRule[string] {
return attrvalue.NewSimpleRule[string](
"azurerm_kubernetes_cluster",
"sku_tier",
[]string{"Standard", "Premium"},
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/ContainerService/managedClusters/#update-aks-tier-to-standard",
false,
"",
)
}

func (wf WafRules) AzurermKubernetesClusterAutoScalingEnabled() *attrvalue.SimpleRule[bool] {
return attrvalue.NewSimpleRule[bool](
"azurerm_kubernetes_cluster",
"auto_scaling_enabled",
[]bool{true},
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/ContainerService/managedClusters/#enable-the-cluster-auto-scaler-on-an-existing-cluster",
false,
"",
)
}

func (wf WafRules) AzurermKubernetesClusterOMSAgentUnconfigured() *attrvalue.UnknownValueRule {
return attrvalue.NewUnknownValueNestedBlockRule(
"azurerm_kubernetes_cluster",
"oms_agent",
"log_analytics_workspace_id",
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#deploy-vms-across-availability-zones",
"",
)
}
4 changes: 4 additions & 0 deletions waf/azurerm_kubernetes_cluster_node_pool
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package waf

import "github.com/Azure/tflint-ruleset-avm/attrvalue"

21 changes: 21 additions & 0 deletions waf/azurerm_maintenance_assignment_virtual_machine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package waf

import "github.com/Azure/tflint-ruleset-avm/attrvalue"

func (wf WafRules) AzurermVirtualMachineUseMaintenanceConfiguration1() *attrvalue.UnknownValueRule {
return attrvalue.NewUnknownValueRule(
"azurerm_maintenance_assignment_virtual_machine",
"maintenance_configuration_id",
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#use-maintenance-configurations-for-the-vms",
"",
)
}

func (wf WafRules) AzurermVirtualMachineUseMaintenanceConfiguration2() *attrvalue.UnknownValueRule {
return attrvalue.NewUnknownValueRule(
"azurerm_maintenance_assignment_virtual_machine",
"virtual_machine_id",
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#use-maintenance-configurations-for-the-vms",
"",
)
}
16 changes: 16 additions & 0 deletions waf/azurerm_managed_disk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package waf

import (
"github.com/Azure/tflint-ruleset-avm/attrvalue"
)

func (wf WafRules) AzurermManagedDiskStorageAccountTypeIsZRS() *attrvalue.SimpleRule[string] {
return attrvalue.NewSimpleRule[string](
"azurerm_amanaged_disk",
"sku",
[]string{"StandardSSD_ZRS", "Premium_ZRS"},
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/welcome/",
false,
"",
)
}
15 changes: 15 additions & 0 deletions waf/azurerm_redis_cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package waf

import (
"github.com/Azure/tflint-ruleset-avm/attrvalue"
)

func (wf WafRules) AzurermRedisCacheZoneRedundancyEnabled() *attrvalue.SetRule[int] {
return attrvalue.NewSetRule(
"azurerm_redis_cache",
"zones",
[][]int{{1, 2, 3}},
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Cache/Redis/#enable-zone-redundancy-for-azure-cache-for-redis",
"",
)
}
4 changes: 2 additions & 2 deletions waf/azurerm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ func (wf WafRules) AzurermVirtualMachineZoneUnknown() *attrvalue.UnknownValueRul
return attrvalue.NewUnknownValueRule(
"azurerm_virtual_machine",
"zone",
"https://azure.github.io/Azure-Proactive-Resiliency-Library/services/compute/virtual-machines/#vm-2---deploy-vms-across-availability-zones",
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#deploy-vms-across-availability-zones",
"",
)
}
Expand All @@ -15,7 +15,7 @@ func (wf WafRules) AzurermVirtualMachineZonesUnknown() *attrvalue.UnknownValueRu
return attrvalue.NewUnknownValueRule(
"azurerm_virtual_machine",
"zones",
"https://azure.github.io/Azure-Proactive-Resiliency-Library/services/compute/virtual-machines/#vm-2---deploy-vms-across-availability-zones",
"https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#deploy-vms-across-availability-zones",
"",
)
}
Expand Down
Loading