1. Packages
  2. Packages
  3. Azure Classic
  4. API Docs
  5. containerservice
  6. ClusterDeploymentSafeguard

We recommend using Azure Native.

Viewing docs for Azure v6.35.0
published on Tuesday, Apr 21, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v6.35.0
published on Tuesday, Apr 21, 2026 by Pulumi

    Manages a Deployment Safeguard for a Kubernetes Cluster.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const example = new azure.core.ResourceGroup("example", {
        name: "example-resources",
        location: "West Europe",
    });
    const exampleKubernetesCluster = new azure.containerservice.KubernetesCluster("example", {
        name: "example-aks",
        location: example.location,
        resourceGroupName: example.name,
        dnsPrefix: "exampleaks",
        defaultNodePool: {
            name: "default",
            nodeCount: 1,
            vmSize: "Standard_DS2_v2",
            upgradeSettings: {
                maxSurge: "10%",
            },
        },
        identity: {
            type: "SystemAssigned",
        },
        azurePolicyEnabled: true,
    });
    const exampleClusterDeploymentSafeguard = new azure.containerservice.ClusterDeploymentSafeguard("example", {
        kubernetesClusterId: exampleKubernetesCluster.id,
        level: "Enforce",
        excludedNamespaces: [
            "my-app-namespace",
            "legacy-app",
        ],
        podSecurityStandardsLevel: "Restricted",
    });
    
    import pulumi
    import pulumi_azure as azure
    
    example = azure.core.ResourceGroup("example",
        name="example-resources",
        location="West Europe")
    example_kubernetes_cluster = azure.containerservice.KubernetesCluster("example",
        name="example-aks",
        location=example.location,
        resource_group_name=example.name,
        dns_prefix="exampleaks",
        default_node_pool={
            "name": "default",
            "node_count": 1,
            "vm_size": "Standard_DS2_v2",
            "upgrade_settings": {
                "max_surge": "10%",
            },
        },
        identity={
            "type": "SystemAssigned",
        },
        azure_policy_enabled=True)
    example_cluster_deployment_safeguard = azure.containerservice.ClusterDeploymentSafeguard("example",
        kubernetes_cluster_id=example_kubernetes_cluster.id,
        level="Enforce",
        excluded_namespaces=[
            "my-app-namespace",
            "legacy-app",
        ],
        pod_security_standards_level="Restricted")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/containerservice"
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
    	"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("example-resources"),
    			Location: pulumi.String("West Europe"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleKubernetesCluster, err := containerservice.NewKubernetesCluster(ctx, "example", &containerservice.KubernetesClusterArgs{
    			Name:              pulumi.String("example-aks"),
    			Location:          example.Location,
    			ResourceGroupName: example.Name,
    			DnsPrefix:         pulumi.String("exampleaks"),
    			DefaultNodePool: &containerservice.KubernetesClusterDefaultNodePoolArgs{
    				Name:      pulumi.String("default"),
    				NodeCount: pulumi.Int(1),
    				VmSize:    pulumi.String("Standard_DS2_v2"),
    				UpgradeSettings: &containerservice.KubernetesClusterDefaultNodePoolUpgradeSettingsArgs{
    					MaxSurge: pulumi.String("10%"),
    				},
    			},
    			Identity: &containerservice.KubernetesClusterIdentityArgs{
    				Type: pulumi.String("SystemAssigned"),
    			},
    			AzurePolicyEnabled: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = containerservice.NewClusterDeploymentSafeguard(ctx, "example", &containerservice.ClusterDeploymentSafeguardArgs{
    			KubernetesClusterId: exampleKubernetesCluster.ID(),
    			Level:               pulumi.String("Enforce"),
    			ExcludedNamespaces: pulumi.StringArray{
    				pulumi.String("my-app-namespace"),
    				pulumi.String("legacy-app"),
    			},
    			PodSecurityStandardsLevel: pulumi.String("Restricted"),
    		})
    		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 = "example-resources",
            Location = "West Europe",
        });
    
        var exampleKubernetesCluster = new Azure.ContainerService.KubernetesCluster("example", new()
        {
            Name = "example-aks",
            Location = example.Location,
            ResourceGroupName = example.Name,
            DnsPrefix = "exampleaks",
            DefaultNodePool = new Azure.ContainerService.Inputs.KubernetesClusterDefaultNodePoolArgs
            {
                Name = "default",
                NodeCount = 1,
                VmSize = "Standard_DS2_v2",
                UpgradeSettings = new Azure.ContainerService.Inputs.KubernetesClusterDefaultNodePoolUpgradeSettingsArgs
                {
                    MaxSurge = "10%",
                },
            },
            Identity = new Azure.ContainerService.Inputs.KubernetesClusterIdentityArgs
            {
                Type = "SystemAssigned",
            },
            AzurePolicyEnabled = true,
        });
    
        var exampleClusterDeploymentSafeguard = new Azure.ContainerService.ClusterDeploymentSafeguard("example", new()
        {
            KubernetesClusterId = exampleKubernetesCluster.Id,
            Level = "Enforce",
            ExcludedNamespaces = new[]
            {
                "my-app-namespace",
                "legacy-app",
            },
            PodSecurityStandardsLevel = "Restricted",
        });
    
    });
    
    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.containerservice.KubernetesCluster;
    import com.pulumi.azure.containerservice.KubernetesClusterArgs;
    import com.pulumi.azure.containerservice.inputs.KubernetesClusterDefaultNodePoolArgs;
    import com.pulumi.azure.containerservice.inputs.KubernetesClusterDefaultNodePoolUpgradeSettingsArgs;
    import com.pulumi.azure.containerservice.inputs.KubernetesClusterIdentityArgs;
    import com.pulumi.azure.containerservice.ClusterDeploymentSafeguard;
    import com.pulumi.azure.containerservice.ClusterDeploymentSafeguardArgs;
    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("example-resources")
                .location("West Europe")
                .build());
    
            var exampleKubernetesCluster = new KubernetesCluster("exampleKubernetesCluster", KubernetesClusterArgs.builder()
                .name("example-aks")
                .location(example.location())
                .resourceGroupName(example.name())
                .dnsPrefix("exampleaks")
                .defaultNodePool(KubernetesClusterDefaultNodePoolArgs.builder()
                    .name("default")
                    .nodeCount(1)
                    .vmSize("Standard_DS2_v2")
                    .upgradeSettings(KubernetesClusterDefaultNodePoolUpgradeSettingsArgs.builder()
                        .maxSurge("10%")
                        .build())
                    .build())
                .identity(KubernetesClusterIdentityArgs.builder()
                    .type("SystemAssigned")
                    .build())
                .azurePolicyEnabled(true)
                .build());
    
            var exampleClusterDeploymentSafeguard = new ClusterDeploymentSafeguard("exampleClusterDeploymentSafeguard", ClusterDeploymentSafeguardArgs.builder()
                .kubernetesClusterId(exampleKubernetesCluster.id())
                .level("Enforce")
                .excludedNamespaces(            
                    "my-app-namespace",
                    "legacy-app")
                .podSecurityStandardsLevel("Restricted")
                .build());
    
        }
    }
    
    resources:
      example:
        type: azure:core:ResourceGroup
        properties:
          name: example-resources
          location: West Europe
      exampleKubernetesCluster:
        type: azure:containerservice:KubernetesCluster
        name: example
        properties:
          name: example-aks
          location: ${example.location}
          resourceGroupName: ${example.name}
          dnsPrefix: exampleaks
          defaultNodePool:
            name: default
            nodeCount: 1
            vmSize: Standard_DS2_v2
            upgradeSettings:
              maxSurge: 10%
          identity:
            type: SystemAssigned
          azurePolicyEnabled: true
      exampleClusterDeploymentSafeguard:
        type: azure:containerservice:ClusterDeploymentSafeguard
        name: example
        properties:
          kubernetesClusterId: ${exampleKubernetesCluster.id}
          level: Enforce
          excludedNamespaces:
            - my-app-namespace
            - legacy-app
          podSecurityStandardsLevel: Restricted
    

    API Providers

    This resource uses the following Azure API Providers:

    • Microsoft.ContainerService - 2025-07-01

    Create ClusterDeploymentSafeguard Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ClusterDeploymentSafeguard(name: string, args: ClusterDeploymentSafeguardArgs, opts?: CustomResourceOptions);
    @overload
    def ClusterDeploymentSafeguard(resource_name: str,
                                   args: ClusterDeploymentSafeguardArgs,
                                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def ClusterDeploymentSafeguard(resource_name: str,
                                   opts: Optional[ResourceOptions] = None,
                                   kubernetes_cluster_id: Optional[str] = None,
                                   level: Optional[str] = None,
                                   excluded_namespaces: Optional[Sequence[str]] = None,
                                   pod_security_standards_level: Optional[str] = None)
    func NewClusterDeploymentSafeguard(ctx *Context, name string, args ClusterDeploymentSafeguardArgs, opts ...ResourceOption) (*ClusterDeploymentSafeguard, error)
    public ClusterDeploymentSafeguard(string name, ClusterDeploymentSafeguardArgs args, CustomResourceOptions? opts = null)
    public ClusterDeploymentSafeguard(String name, ClusterDeploymentSafeguardArgs args)
    public ClusterDeploymentSafeguard(String name, ClusterDeploymentSafeguardArgs args, CustomResourceOptions options)
    
    type: azure:containerservice:ClusterDeploymentSafeguard
    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 ClusterDeploymentSafeguardArgs
    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 ClusterDeploymentSafeguardArgs
    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 ClusterDeploymentSafeguardArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ClusterDeploymentSafeguardArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ClusterDeploymentSafeguardArgs
    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 clusterDeploymentSafeguardResource = new Azure.ContainerService.ClusterDeploymentSafeguard("clusterDeploymentSafeguardResource", new()
    {
        KubernetesClusterId = "string",
        Level = "string",
        ExcludedNamespaces = new[]
        {
            "string",
        },
        PodSecurityStandardsLevel = "string",
    });
    
    example, err := containerservice.NewClusterDeploymentSafeguard(ctx, "clusterDeploymentSafeguardResource", &containerservice.ClusterDeploymentSafeguardArgs{
    	KubernetesClusterId: pulumi.String("string"),
    	Level:               pulumi.String("string"),
    	ExcludedNamespaces: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	PodSecurityStandardsLevel: pulumi.String("string"),
    })
    
    var clusterDeploymentSafeguardResource = new ClusterDeploymentSafeguard("clusterDeploymentSafeguardResource", ClusterDeploymentSafeguardArgs.builder()
        .kubernetesClusterId("string")
        .level("string")
        .excludedNamespaces("string")
        .podSecurityStandardsLevel("string")
        .build());
    
    cluster_deployment_safeguard_resource = azure.containerservice.ClusterDeploymentSafeguard("clusterDeploymentSafeguardResource",
        kubernetes_cluster_id="string",
        level="string",
        excluded_namespaces=["string"],
        pod_security_standards_level="string")
    
    const clusterDeploymentSafeguardResource = new azure.containerservice.ClusterDeploymentSafeguard("clusterDeploymentSafeguardResource", {
        kubernetesClusterId: "string",
        level: "string",
        excludedNamespaces: ["string"],
        podSecurityStandardsLevel: "string",
    });
    
    type: azure:containerservice:ClusterDeploymentSafeguard
    properties:
        excludedNamespaces:
            - string
        kubernetesClusterId: string
        level: string
        podSecurityStandardsLevel: string
    

    ClusterDeploymentSafeguard 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 ClusterDeploymentSafeguard resource accepts the following input properties:

    KubernetesClusterId string
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    Level string
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    ExcludedNamespaces List<string>
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    PodSecurityStandardsLevel string
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    KubernetesClusterId string
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    Level string
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    ExcludedNamespaces []string
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    PodSecurityStandardsLevel string
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    kubernetesClusterId String
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level String
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    excludedNamespaces List<String>
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    podSecurityStandardsLevel String
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    kubernetesClusterId string
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level string
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    excludedNamespaces string[]
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    podSecurityStandardsLevel string
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    kubernetes_cluster_id str
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level str
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    excluded_namespaces Sequence[str]
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    pod_security_standards_level str
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    kubernetesClusterId String
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level String
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    excludedNamespaces List<String>
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    podSecurityStandardsLevel String
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ClusterDeploymentSafeguard 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 ClusterDeploymentSafeguard Resource

    Get an existing ClusterDeploymentSafeguard 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?: ClusterDeploymentSafeguardState, opts?: CustomResourceOptions): ClusterDeploymentSafeguard
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            excluded_namespaces: Optional[Sequence[str]] = None,
            kubernetes_cluster_id: Optional[str] = None,
            level: Optional[str] = None,
            pod_security_standards_level: Optional[str] = None) -> ClusterDeploymentSafeguard
    func GetClusterDeploymentSafeguard(ctx *Context, name string, id IDInput, state *ClusterDeploymentSafeguardState, opts ...ResourceOption) (*ClusterDeploymentSafeguard, error)
    public static ClusterDeploymentSafeguard Get(string name, Input<string> id, ClusterDeploymentSafeguardState? state, CustomResourceOptions? opts = null)
    public static ClusterDeploymentSafeguard get(String name, Output<String> id, ClusterDeploymentSafeguardState state, CustomResourceOptions options)
    resources:  _:    type: azure:containerservice:ClusterDeploymentSafeguard    get:      id: ${id}
    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.
    The following state arguments are supported:
    ExcludedNamespaces List<string>
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    KubernetesClusterId string
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    Level string
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    PodSecurityStandardsLevel string
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    ExcludedNamespaces []string
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    KubernetesClusterId string
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    Level string
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    PodSecurityStandardsLevel string
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    excludedNamespaces List<String>
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    kubernetesClusterId String
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level String
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    podSecurityStandardsLevel String
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    excludedNamespaces string[]
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    kubernetesClusterId string
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level string
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    podSecurityStandardsLevel string
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    excluded_namespaces Sequence[str]
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    kubernetes_cluster_id str
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level str
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    pod_security_standards_level str
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.
    excludedNamespaces List<String>
    A list of Kubernetes namespace names that should be excluded from Deployment Safeguards enforcement. This allows certain namespaces to bypass the configured policies.
    kubernetesClusterId String
    Specifies the Kubernetes Cluster ID for which Deployment Safeguards should be configured. Changing this forces a new resource to be created.
    level String
    The level of Deployment Safeguards enforcement. Possible values are Warn and Enforce.
    podSecurityStandardsLevel String
    The Pod Security Standards level to enforce. Possible values are Baseline, Privileged, and Restricted. Defaults to Privileged.

    Import

    Deployment Safeguards can be imported using the resource id, e.g.

    $ pulumi import azure:containerservice/clusterDeploymentSafeguard:ClusterDeploymentSafeguard example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ContainerService/managedClusters/cluster1
    

    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.
    azure logo

    We recommend using Azure Native.

    Viewing docs for Azure v6.35.0
    published on Tuesday, Apr 21, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.