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

Added management lock support #2079

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .github/workflows/standalone-scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"maintenance_configuration/200-maintenance-configuration-assignment-vm-windows",
"maintenance_configuration/201-maintenance-configuration-assignment-vm-linux",
"managed_service_identity/100-msi-levels",
"management_lock/100-basic-lock",
"maps/101-azure-maps-account",
"messaging/eventgrid/100-simple-eventgrid-topic",
"messaging/eventgrid/101-simple-eventgrid-topic-private-endpoint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ azuread_applications = {
admin_consent_description = "Allow to administer app2."
admin_consent_display_name = "Administer app2"
enabled = true
type = "Admin"
value = "app2"
type = "Admin"
value = "app2"
}
]
}
Expand Down
40 changes: 40 additions & 0 deletions examples/management_lock/100-basic-lock/configuration.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
global_settings = {
default_region = "region1"
regions = {
region1 = "francecentral"
}
}

resource_groups = {
rg1 = {
name = "rg1"
region = "region1"
}
}

storage_accounts = {
sa1 = {
name = "5116e929eed5"
resource_group_key = "rg1"
account_kind = "BlobStorage"
account_tier = "Standard"
account_replication_type = "LRS"
}
}

management_locks = {
resource_groups = {
rg1 = {
name = "rg-lock"
key = "rg1"
level = "ReadOnly"
}
}
storage_accounts = {
sa1 = {
name = "sa-lock"
key = "sa1"
level = "CanNotDelete"
}
}
}
9 changes: 9 additions & 0 deletions modules/management_lock/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "azurerm_management_lock" "lock" {
name = var.name
scope = coalesce(
var.resource_id,
var.remote_objects[var.resource_type][var.resource_lz_key][var.resource_key].id
)
lock_level = var.lock_level
notes = var.notes
}
3 changes: 3 additions & 0 deletions modules/management_lock/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = azurerm_management_lock.lock.id
}
29 changes: 29 additions & 0 deletions modules/management_lock/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "global_settings" {
description = "Global settings object (see module README.md)"
}

variable "client_config" {
description = "Client configuration object."
default = {}
}

variable "remote_objects" {
default = {}
}
variable "name" {}
variable "resource_type" {
default = ""
}
variable "resource_lz_key" {
default = ""
}
variable "resource_key" {
default = ""
}
variable "resource_id" {
default = ""
}
variable "lock_level" {}
variable "notes" {
default = null
}
3 changes: 3 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,6 @@
default = {}
}

variable "management_locks" {

Check warning on line 453 in variables.tf

View workflow job for this annotation

GitHub Actions / Format and Lint Checks

[tflint] reported by reviewdog 🐶 variable "management_locks" is declared but not used Raw Output: variables.tf:453:1: warning: variable "management_locks" is declared but not used (terraform_unused_declarations)
default = {}
}