We recommend using Azure Native.
azure.management.Lock
Explore with Pulumi AI
Manages a Management Lock which is scoped to a Subscription, Resource Group or Resource.
Example Usage
Subscription Level Lock)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const current = azure.core.getSubscription({});
const subscription_level = new azure.management.Lock("subscription-level", {
name: "subscription-level",
scope: current.then(current => current.id),
lockLevel: "CanNotDelete",
notes: "Items can't be deleted in this subscription!",
});
import pulumi
import pulumi_azure as azure
current = azure.core.get_subscription()
subscription_level = azure.management.Lock("subscription-level",
name="subscription-level",
scope=current.id,
lock_level="CanNotDelete",
notes="Items can't be deleted in this subscription!")
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/management"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
current, err := core.LookupSubscription(ctx, &core.LookupSubscriptionArgs{}, nil)
if err != nil {
return err
}
_, err = management.NewLock(ctx, "subscription-level", &management.LockArgs{
Name: pulumi.String("subscription-level"),
Scope: pulumi.String(current.Id),
LockLevel: pulumi.String("CanNotDelete"),
Notes: pulumi.String("Items can't be deleted in this subscription!"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var current = Azure.Core.GetSubscription.Invoke();
var subscription_level = new Azure.Management.Lock("subscription-level", new()
{
Name = "subscription-level",
Scope = current.Apply(getSubscriptionResult => getSubscriptionResult.Id),
LockLevel = "CanNotDelete",
Notes = "Items can't be deleted in this subscription!",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.CoreFunctions;
import com.pulumi.azure.core.inputs.GetSubscriptionArgs;
import com.pulumi.azure.management.Lock;
import com.pulumi.azure.management.LockArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var current = CoreFunctions.getSubscription();
var subscription_level = new Lock("subscription-level", LockArgs.builder()
.name("subscription-level")
.scope(current.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
.lockLevel("CanNotDelete")
.notes("Items can't be deleted in this subscription!")
.build());
}
}
resources:
subscription-level:
type: azure:management:Lock
properties:
name: subscription-level
scope: ${current.id}
lockLevel: CanNotDelete
notes: Items can't be deleted in this subscription!
variables:
current:
fn::invoke:
Function: azure:core:getSubscription
Arguments: {}
Resource Group Level Lock)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "locked-resource-group",
location: "West Europe",
});
const resource_group_level = new azure.management.Lock("resource-group-level", {
name: "resource-group-level",
scope: example.id,
lockLevel: "ReadOnly",
notes: "This Resource Group is Read-Only",
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="locked-resource-group",
location="West Europe")
resource_group_level = azure.management.Lock("resource-group-level",
name="resource-group-level",
scope=example.id,
lock_level="ReadOnly",
notes="This Resource Group is Read-Only")
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/management"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("locked-resource-group"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
_, err = management.NewLock(ctx, "resource-group-level", &management.LockArgs{
Name: pulumi.String("resource-group-level"),
Scope: example.ID(),
LockLevel: pulumi.String("ReadOnly"),
Notes: pulumi.String("This Resource Group is Read-Only"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "locked-resource-group",
Location = "West Europe",
});
var resource_group_level = new Azure.Management.Lock("resource-group-level", new()
{
Name = "resource-group-level",
Scope = example.Id,
LockLevel = "ReadOnly",
Notes = "This Resource Group is Read-Only",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.management.Lock;
import com.pulumi.azure.management.LockArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("locked-resource-group")
.location("West Europe")
.build());
var resource_group_level = new Lock("resource-group-level", LockArgs.builder()
.name("resource-group-level")
.scope(example.id())
.lockLevel("ReadOnly")
.notes("This Resource Group is Read-Only")
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: locked-resource-group
location: West Europe
resource-group-level:
type: azure:management:Lock
properties:
name: resource-group-level
scope: ${example.id}
lockLevel: ReadOnly
notes: This Resource Group is Read-Only
Resource Level Lock)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "locked-resource-group",
location: "West Europe",
});
const examplePublicIp = new azure.network.PublicIp("example", {
name: "locked-publicip",
location: example.location,
resourceGroupName: example.name,
allocationMethod: "Static",
idleTimeoutInMinutes: 30,
});
const public_ip = new azure.management.Lock("public-ip", {
name: "resource-ip",
scope: examplePublicIp.id,
lockLevel: "CanNotDelete",
notes: "Locked because it's needed by a third-party",
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="locked-resource-group",
location="West Europe")
example_public_ip = azure.network.PublicIp("example",
name="locked-publicip",
location=example.location,
resource_group_name=example.name,
allocation_method="Static",
idle_timeout_in_minutes=30)
public_ip = azure.management.Lock("public-ip",
name="resource-ip",
scope=example_public_ip.id,
lock_level="CanNotDelete",
notes="Locked because it's needed by a third-party")
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/management"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("locked-resource-group"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
examplePublicIp, err := network.NewPublicIp(ctx, "example", &network.PublicIpArgs{
Name: pulumi.String("locked-publicip"),
Location: example.Location,
ResourceGroupName: example.Name,
AllocationMethod: pulumi.String("Static"),
IdleTimeoutInMinutes: pulumi.Int(30),
})
if err != nil {
return err
}
_, err = management.NewLock(ctx, "public-ip", &management.LockArgs{
Name: pulumi.String("resource-ip"),
Scope: examplePublicIp.ID(),
LockLevel: pulumi.String("CanNotDelete"),
Notes: pulumi.String("Locked because it's needed by a third-party"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "locked-resource-group",
Location = "West Europe",
});
var examplePublicIp = new Azure.Network.PublicIp("example", new()
{
Name = "locked-publicip",
Location = example.Location,
ResourceGroupName = example.Name,
AllocationMethod = "Static",
IdleTimeoutInMinutes = 30,
});
var public_ip = new Azure.Management.Lock("public-ip", new()
{
Name = "resource-ip",
Scope = examplePublicIp.Id,
LockLevel = "CanNotDelete",
Notes = "Locked because it's needed by a third-party",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.PublicIp;
import com.pulumi.azure.network.PublicIpArgs;
import com.pulumi.azure.management.Lock;
import com.pulumi.azure.management.LockArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("locked-resource-group")
.location("West Europe")
.build());
var examplePublicIp = new PublicIp("examplePublicIp", PublicIpArgs.builder()
.name("locked-publicip")
.location(example.location())
.resourceGroupName(example.name())
.allocationMethod("Static")
.idleTimeoutInMinutes(30)
.build());
var public_ip = new Lock("public-ip", LockArgs.builder()
.name("resource-ip")
.scope(examplePublicIp.id())
.lockLevel("CanNotDelete")
.notes("Locked because it's needed by a third-party")
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: locked-resource-group
location: West Europe
examplePublicIp:
type: azure:network:PublicIp
name: example
properties:
name: locked-publicip
location: ${example.location}
resourceGroupName: ${example.name}
allocationMethod: Static
idleTimeoutInMinutes: 30
public-ip:
type: azure:management:Lock
properties:
name: resource-ip
scope: ${examplePublicIp.id}
lockLevel: CanNotDelete
notes: Locked because it's needed by a third-party
Create Lock Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Lock(name: string, args: LockArgs, opts?: CustomResourceOptions);
@overload
def Lock(resource_name: str,
args: LockArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Lock(resource_name: str,
opts: Optional[ResourceOptions] = None,
lock_level: Optional[str] = None,
scope: Optional[str] = None,
name: Optional[str] = None,
notes: Optional[str] = None)
func NewLock(ctx *Context, name string, args LockArgs, opts ...ResourceOption) (*Lock, error)
public Lock(string name, LockArgs args, CustomResourceOptions? opts = null)
type: azure:management:Lock
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args LockArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args LockArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args LockArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args LockArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args LockArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var lockResource = new Azure.Management.Lock("lockResource", new()
{
LockLevel = "string",
Scope = "string",
Name = "string",
Notes = "string",
});
example, err := management.NewLock(ctx, "lockResource", &management.LockArgs{
LockLevel: pulumi.String("string"),
Scope: pulumi.String("string"),
Name: pulumi.String("string"),
Notes: pulumi.String("string"),
})
var lockResource = new Lock("lockResource", LockArgs.builder()
.lockLevel("string")
.scope("string")
.name("string")
.notes("string")
.build());
lock_resource = azure.management.Lock("lockResource",
lock_level="string",
scope="string",
name="string",
notes="string")
const lockResource = new azure.management.Lock("lockResource", {
lockLevel: "string",
scope: "string",
name: "string",
notes: "string",
});
type: azure:management:Lock
properties:
lockLevel: string
name: string
notes: string
scope: string
Lock Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Lock resource accepts the following input properties:
- Lock
Level string Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- Scope string
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- Name string
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- Notes string
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- Lock
Level string Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- Scope string
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- Name string
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- Notes string
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- lock
Level String Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- scope String
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- name String
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes String
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- lock
Level string Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- scope string
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- name string
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes string
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- lock_
level str Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- scope str
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- name str
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes str
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- lock
Level String Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- scope String
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- name String
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes String
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
Outputs
All input properties are implicitly available as output properties. Additionally, the Lock resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Lock Resource
Get an existing Lock resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: LockState, opts?: CustomResourceOptions): Lock
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
lock_level: Optional[str] = None,
name: Optional[str] = None,
notes: Optional[str] = None,
scope: Optional[str] = None) -> Lock
func GetLock(ctx *Context, name string, id IDInput, state *LockState, opts ...ResourceOption) (*Lock, error)
public static Lock Get(string name, Input<string> id, LockState? state, CustomResourceOptions? opts = null)
public static Lock get(String name, Output<String> id, LockState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Lock
Level string Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- Name string
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- Notes string
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- Scope string
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- Lock
Level string Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- Name string
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- Notes string
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- Scope string
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- lock
Level String Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- name String
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes String
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- scope String
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- lock
Level string Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- name string
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes string
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- scope string
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- lock_
level str Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- name str
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes str
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- scope str
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
- lock
Level String Specifies the Level to be used for this Lock. Possible values are
CanNotDelete
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.- name String
- Specifies the name of the Management Lock. Changing this forces a new resource to be created.
- notes String
- Specifies some notes about the lock. Maximum of 512 characters. Changing this forces a new resource to be created.
- scope String
- Specifies the scope at which the Management Lock should be created. Changing this forces a new resource to be created.
Import
Management Locks can be imported using the resource id
, e.g.
$ pulumi import azure:management/lock:Lock lock1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Authorization/locks/lock1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.