azurermManagementLock
Manages a Management Lock which is scoped to a Subscription, Resource Group or Resource.
Example Usage (Subscription Level Lock)
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const dataAzurermSubscriptionCurrent =
new azurerm.dataAzurermSubscription.DataAzurermSubscription(
this,
"current",
{}
);
new azurerm.managementLock.ManagementLock(this, "subscription-level", {
lock_level: "CanNotDelete",
name: "subscription-level",
notes: "Items can't be deleted in this subscription!",
scope: dataAzurermSubscriptionCurrent.id,
});
Example Usage (Resource Group Level Lock)
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
this,
"example",
{
location: "West Europe",
name: "locked-resource-group",
}
);
new azurerm.managementLock.ManagementLock(this, "resource-group-level", {
lock_level: "ReadOnly",
name: "resource-group-level",
notes: "This Resource Group is Read-Only",
scope: azurermResourceGroupExample.id,
});
Example Usage (Resource Level Lock)
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
this,
"example",
{
location: "West Europe",
name: "locked-resource-group",
}
);
const azurermPublicIpExample = new azurerm.publicIp.PublicIp(
this,
"example_1",
{
allocation_method: "Static",
idle_timeout_in_minutes: 30,
location: azurermResourceGroupExample.location,
name: "locked-publicip",
resource_group_name: azurermResourceGroupExample.name,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPublicIpExample.overrideLogicalId("example");
new azurerm.managementLock.ManagementLock(this, "public-ip", {
lock_level: "CanNotDelete",
name: "resource-ip",
notes: "Locked because it's needed by a third-party",
scope: azurermPublicIpExample.id,
});
Argument Reference
The following arguments are supported:
-
name
- (Required) Specifies the name of the Management Lock. Changing this forces a new resource to be created. -
scope
- (Required) Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created. -
lockLevel
- (Required) Specifies the Level to be used for this Lock. Possible values arecanNotDelete
andreadOnly
. Changing this forces a new resource to be created.
\~> Note: canNotDelete
means authorized users are able to read and modify the resources, but not delete. readOnly
means authorized users can only read from a resource, but they can't modify or delete it.
notes
- (Optional) Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
Attributes Reference
The following attributes are exported:
id
- The ID of the Management Lock
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the Management Lock.update
- (Defaults to 30 minutes) Used when updating the Management Lock.read
- (Defaults to 5 minutes) Used when retrieving the Management Lock.delete
- (Defaults to 30 minutes) Used when deleting the Management Lock.
Import
Management Locks can be imported using the resourceId
, e.g.