-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52a2f44
commit 7f835a1
Showing
8 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
...tgresql/microsoft_db_for_postgresql_flexibleServers_backup_geo_redundant_backup.mock.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"mock": { | ||
"default": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.res", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "res", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"backup": { | ||
"geoRedundantBackup": "Enabled" | ||
} | ||
} | ||
}, | ||
"type": "Microsoft.DBforPostgreSQL/flexibleServers@2024-11-01-preview" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_geo_redundant_backup_disabled": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.res", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "res", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"backup": { | ||
"geoRedundantBackup": "Disabled" | ||
} | ||
} | ||
}, | ||
"type": "Microsoft.DBforPostgreSQL/flexibleServers@2024-11-01-preview" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_geo_redundant_backup_omitted": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.res", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "res", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"backup": {} | ||
} | ||
}, | ||
"type": "Microsoft.DBforPostgreSQL/flexibleServers@2024-11-01-preview" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...i/postgresql/microsoft_db_for_postgresql_flexibleServers_backup_geo_redundant_backup.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package Azure_Proactive_Resiliency_Library_v2 | ||
|
||
import rego.v1 | ||
|
||
valid_azapi_postgres_flexible_server_geo_redundant_backup_enabled(resource) if { | ||
resource.values.body.properties.backup.geoRedundantBackup == "Enabled" | ||
} | ||
|
||
deny_postgresql_flexible_server_geo_redundant_backup_enabled contains reason if { | ||
resource := data.utils.resource(input, "azapi_resource")[_] | ||
data.utils.is_azure_type(resource.values, "Microsoft.DBforPostgreSQL/flexibleServers") | ||
not valid_azapi_postgres_flexible_server_geo_redundant_backup_enabled(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2/postgresql_flexible_server_geo_redundant_backup_enabled: '%s' `azapi_resource` must have 'backup.geoRedundantBackup' set to '\"Enabled\"': https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/DBforMySQL/flexibleServers/#configure-geo-redundant-backup-storage", [resource.address]) | ||
} |
79 changes: 79 additions & 0 deletions
79
.../postgresql/microsoft_db_for_postgresql_flexibleServers_high_availabillity_mode.mock.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"mock": { | ||
"valid_zone_redundant": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.res", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "res", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"highAvailability": { | ||
"mode": "ZoneRedundant" | ||
} | ||
} | ||
}, | ||
"type": "Microsoft.DBforPostgreSQL/flexibleServers@2024-11-01-preview" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_same_zone": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.res", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "res", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"highAvailability": { | ||
"mode": "SameZone" | ||
} | ||
} | ||
}, | ||
"type": "Microsoft.DBforPostgreSQL/flexibleServers@2024-11-01-preview" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_no_high_availability": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.res", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "res", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"body": { | ||
"properties": { | ||
} | ||
}, | ||
"type": "Microsoft.DBforPostgreSQL/flexibleServers@2024-11-01-preview" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...azapi/postgresql/microsoft_db_for_postgresql_flexibleServers_high_availabillity_mode.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package Azure_Proactive_Resiliency_Library_v2 | ||
|
||
import rego.v1 | ||
|
||
valid_azapi_postgres_flexible_server_high_availability_zone_redundant(resource) if { | ||
resource.values.body.properties.highAvailability.mode == "ZoneRedundant" | ||
} | ||
|
||
deny_postgresql_flexible_server_high_availability_zone_redundant contains reason if { | ||
resource := data.utils.resource(input, "azapi_resource")[_] | ||
data.utils.is_azure_type(resource.values, "Microsoft.DBforPostgreSQL/flexibleServers") | ||
not valid_azapi_postgres_flexible_server_high_availability_zone_redundant(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2/postgresql_flexible_server_high_availability_zone_redundant: '%s' `azapi_resource` must have 'highAvailability.mode' set to 'ZoneRedundant': https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/DBforPostgreSQL/flexibleServers/#enable-ha-with-zone-redundancy", [resource.address]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...zurerm/postgres/azurerm_postgresql_flexible_server_geo_redundant_backup_enabled.mock.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"mock": { | ||
"default": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_postgresql_flexible_server.example", | ||
"mode": "managed", | ||
"type": "azurerm_postgresql_flexible_server", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"geo_redundant_backup_enabled": true | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_geo_redundant_backup_disabled": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_postgresql_flexible_server.example", | ||
"mode": "managed", | ||
"type": "azurerm_postgresql_flexible_server", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"geo_redundant_backup_enabled": false | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_geo_redundant_backup_omitted": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_postgresql_flexible_server.example", | ||
"mode": "managed", | ||
"type": "azurerm_postgresql_flexible_server", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": {} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...-v2/azurerm/postgres/azurerm_postgresql_flexible_server_geo_redundant_backup_enabled.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package Azure_Proactive_Resiliency_Library_v2 | ||
|
||
import rego.v1 | ||
|
||
valid_postgresql_flexible_server_geo_redundant_backup_enabled(resource) if { | ||
resource.values.geo_redundant_backup_enabled == true | ||
} | ||
|
||
deny_postgresql_flexible_server_geo_redundant_backup_enabled contains reason if { | ||
resource := data.utils.resource(input, "azurerm_postgresql_flexible_server")[_] | ||
not valid_postgresql_flexible_server_geo_redundant_backup_enabled(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2/postgresql_flexible_server_geo_redundant_backup_enabled: '%s' `azurerm_postgresql_flexible_server` must have 'geo_redundant_backup_enabled' set to 'true': https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/DBforPostgreSQL/flexibleServers/#configure-geo-redundant-backup-storage", [resource.address]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters