published on Thursday, Jun 25, 2026 by vk-cs
published on Thursday, Jun 25, 2026 by vk-cs
Provides a Kubernetes cluster security policy resource. This can be used to create, modify, and delete Kubernetes cluster security policy.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as vkcs from "@pulumi/vkcs";
const policySettings = {
ranges: [{
min_replicas: 1,
max_replicas: 2,
}],
};
const replicalimits = new vkcs.KubernetesSecurityPolicyV2("replicalimits", {
clusterId: k8sCluster.id,
enabled: true,
namespace: "*",
policySettings: JSON.stringify(policySettings),
securityPolicyTemplateId: replicalimitsVkcsKubernetesSecurityPolicyTemplateV2.id,
});
import pulumi
import json
import pulumi_vkcs as vkcs
policy_settings = {
"ranges": [{
"min_replicas": 1,
"max_replicas": 2,
}],
}
replicalimits = vkcs.KubernetesSecurityPolicyV2("replicalimits",
cluster_id=k8s_cluster["id"],
enabled=True,
namespace="*",
policy_settings=json.dumps(policy_settings),
security_policy_template_id=replicalimits_vkcs_kubernetes_security_policy_template_v2["id"])
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/vkcs/vkcs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
policySettings := map[string]interface{}{
"ranges": []map[string]interface{}{
map[string]interface{}{
"min_replicas": 1,
"max_replicas": 2,
},
},
}
tmpJSON0, err := json.Marshal(policySettings)
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = vkcs.NewKubernetesSecurityPolicyV2(ctx, "replicalimits", &vkcs.KubernetesSecurityPolicyV2Args{
ClusterId: pulumi.Any(k8sCluster.Id),
Enabled: pulumi.Bool(true),
Namespace: pulumi.String("*"),
PolicySettings: pulumi.String(json0),
SecurityPolicyTemplateId: pulumi.Any(replicalimitsVkcsKubernetesSecurityPolicyTemplateV2.Id),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Vkcs = Pulumi.Vkcs;
return await Deployment.RunAsync(() =>
{
var policySettings =
{
{ "ranges", new[]
{
{
{ "min_replicas", 1 },
{ "max_replicas", 2 },
},
} },
};
var replicalimits = new Vkcs.KubernetesSecurityPolicyV2("replicalimits", new()
{
ClusterId = k8sCluster.Id,
Enabled = true,
Namespace = "*",
PolicySettings = JsonSerializer.Serialize(policySettings),
SecurityPolicyTemplateId = replicalimitsVkcsKubernetesSecurityPolicyTemplateV2.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vkcs.KubernetesSecurityPolicyV2;
import com.pulumi.vkcs.KubernetesSecurityPolicyV2Args;
import static com.pulumi.codegen.internal.Serialization.*;
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 policySettings = Map.of("ranges", List.of(Map.ofEntries(
Map.entry("min_replicas", 1),
Map.entry("max_replicas", 2)
)));
var replicalimits = new KubernetesSecurityPolicyV2("replicalimits", KubernetesSecurityPolicyV2Args.builder()
.clusterId(k8sCluster.id())
.enabled(true)
.namespace("*")
.policySettings(serializeJson(
policySettings))
.securityPolicyTemplateId(replicalimitsVkcsKubernetesSecurityPolicyTemplateV2.id())
.build());
}
}
resources:
replicalimits:
type: vkcs:KubernetesSecurityPolicyV2
properties:
clusterId: ${k8sCluster.id}
enabled: true
namespace: '*'
policySettings:
fn::toJSON: ${policySettings}
securityPolicyTemplateId: ${replicalimitsVkcsKubernetesSecurityPolicyTemplateV2.id}
variables:
policySettings:
ranges:
- min_replicas: 1
max_replicas: 2
Example coming soon!
Create KubernetesSecurityPolicyV2 Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new KubernetesSecurityPolicyV2(name: string, args: KubernetesSecurityPolicyV2Args, opts?: CustomResourceOptions);@overload
def KubernetesSecurityPolicyV2(resource_name: str,
args: KubernetesSecurityPolicyV2Args,
opts: Optional[ResourceOptions] = None)
@overload
def KubernetesSecurityPolicyV2(resource_name: str,
opts: Optional[ResourceOptions] = None,
cluster_id: Optional[str] = None,
namespace: Optional[str] = None,
policy_settings: Optional[str] = None,
security_policy_template_id: Optional[str] = None,
enabled: Optional[bool] = None,
region: Optional[str] = None)func NewKubernetesSecurityPolicyV2(ctx *Context, name string, args KubernetesSecurityPolicyV2Args, opts ...ResourceOption) (*KubernetesSecurityPolicyV2, error)public KubernetesSecurityPolicyV2(string name, KubernetesSecurityPolicyV2Args args, CustomResourceOptions? opts = null)
public KubernetesSecurityPolicyV2(String name, KubernetesSecurityPolicyV2Args args)
public KubernetesSecurityPolicyV2(String name, KubernetesSecurityPolicyV2Args args, CustomResourceOptions options)
type: vkcs:KubernetesSecurityPolicyV2
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "vkcs_kubernetessecuritypolicyv2" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args KubernetesSecurityPolicyV2Args
- 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 KubernetesSecurityPolicyV2Args
- 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 KubernetesSecurityPolicyV2Args
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args KubernetesSecurityPolicyV2Args
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args KubernetesSecurityPolicyV2Args
- 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 kubernetesSecurityPolicyV2Resource = new Vkcs.KubernetesSecurityPolicyV2("kubernetesSecurityPolicyV2Resource", new()
{
ClusterId = "string",
Namespace = "string",
PolicySettings = "string",
SecurityPolicyTemplateId = "string",
Enabled = false,
Region = "string",
});
example, err := vkcs.NewKubernetesSecurityPolicyV2(ctx, "kubernetesSecurityPolicyV2Resource", &vkcs.KubernetesSecurityPolicyV2Args{
ClusterId: pulumi.String("string"),
Namespace: pulumi.String("string"),
PolicySettings: pulumi.String("string"),
SecurityPolicyTemplateId: pulumi.String("string"),
Enabled: pulumi.Bool(false),
Region: pulumi.String("string"),
})
resource "vkcs_kubernetessecuritypolicyv2" "kubernetesSecurityPolicyV2Resource" {
cluster_id = "string"
namespace = "string"
policy_settings = "string"
security_policy_template_id = "string"
enabled = false
region = "string"
}
var kubernetesSecurityPolicyV2Resource = new KubernetesSecurityPolicyV2("kubernetesSecurityPolicyV2Resource", KubernetesSecurityPolicyV2Args.builder()
.clusterId("string")
.namespace("string")
.policySettings("string")
.securityPolicyTemplateId("string")
.enabled(false)
.region("string")
.build());
kubernetes_security_policy_v2_resource = vkcs.KubernetesSecurityPolicyV2("kubernetesSecurityPolicyV2Resource",
cluster_id="string",
namespace="string",
policy_settings="string",
security_policy_template_id="string",
enabled=False,
region="string")
const kubernetesSecurityPolicyV2Resource = new vkcs.KubernetesSecurityPolicyV2("kubernetesSecurityPolicyV2Resource", {
clusterId: "string",
namespace: "string",
policySettings: "string",
securityPolicyTemplateId: "string",
enabled: false,
region: "string",
});
type: vkcs:KubernetesSecurityPolicyV2
properties:
clusterId: string
enabled: false
namespace: string
policySettings: string
region: string
securityPolicyTemplateId: string
KubernetesSecurityPolicyV2 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 KubernetesSecurityPolicyV2 resource accepts the following input properties:
- Cluster
Id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- Namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- Policy
Settings string - required string → Policy settings. Changing this updates the security policy.
- Security
Policy stringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- Enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - Region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
- Cluster
Id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- Namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- Policy
Settings string - required string → Policy settings. Changing this updates the security policy.
- Security
Policy stringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- Enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - Region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
- cluster_
id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy_
settings string - required string → Policy settings. Changing this updates the security policy.
- security_
policy_ stringtemplate_ id - required string → The ID of the security policy template. Forces replacement on change.
- enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
- cluster
Id String - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- namespace String
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy
Settings String - required string → Policy settings. Changing this updates the security policy.
- security
Policy StringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- enabled Boolean
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - region String
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
- cluster
Id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy
Settings string - required string → Policy settings. Changing this updates the security policy.
- security
Policy stringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- enabled boolean
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
- cluster_
id str - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- namespace str
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy_
settings str - required string → Policy settings. Changing this updates the security policy.
- security_
policy_ strtemplate_ id - required string → The ID of the security policy template. Forces replacement on change.
- enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - region str
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
- cluster
Id String - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- namespace String
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy
Settings String - required string → Policy settings. Changing this updates the security policy.
- security
Policy StringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- enabled Boolean
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - region String
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change.
Outputs
All input properties are implicitly available as output properties. Additionally, the KubernetesSecurityPolicyV2 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 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 KubernetesSecurityPolicyV2 Resource
Get an existing KubernetesSecurityPolicyV2 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?: KubernetesSecurityPolicyV2State, opts?: CustomResourceOptions): KubernetesSecurityPolicyV2@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cluster_id: Optional[str] = None,
enabled: Optional[bool] = None,
namespace: Optional[str] = None,
policy_settings: Optional[str] = None,
region: Optional[str] = None,
security_policy_template_id: Optional[str] = None) -> KubernetesSecurityPolicyV2func GetKubernetesSecurityPolicyV2(ctx *Context, name string, id IDInput, state *KubernetesSecurityPolicyV2State, opts ...ResourceOption) (*KubernetesSecurityPolicyV2, error)public static KubernetesSecurityPolicyV2 Get(string name, Input<string> id, KubernetesSecurityPolicyV2State? state, CustomResourceOptions? opts = null)public static KubernetesSecurityPolicyV2 get(String name, Output<String> id, KubernetesSecurityPolicyV2State state, CustomResourceOptions options)resources: _: type: vkcs:KubernetesSecurityPolicyV2 get: id: ${id}import {
to = vkcs_kubernetessecuritypolicyv2.example
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.
- Cluster
Id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- Enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - Namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- Policy
Settings string - required string → Policy settings. Changing this updates the security policy.
- Region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - Security
Policy stringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- Cluster
Id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- Enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - Namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- Policy
Settings string - required string → Policy settings. Changing this updates the security policy.
- Region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - Security
Policy stringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- cluster_
id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy_
settings string - required string → Policy settings. Changing this updates the security policy.
- region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - security_
policy_ stringtemplate_ id - required string → The ID of the security policy template. Forces replacement on change.
- cluster
Id String - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- enabled Boolean
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - namespace String
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy
Settings String - required string → Policy settings. Changing this updates the security policy.
- region String
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - security
Policy StringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- cluster
Id string - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- enabled boolean
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - namespace string
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy
Settings string - required string → Policy settings. Changing this updates the security policy.
- region string
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - security
Policy stringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
- cluster_
id str - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- enabled bool
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - namespace str
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy_
settings str - required string → Policy settings. Changing this updates the security policy.
- region str
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - security_
policy_ strtemplate_ id - required string → The ID of the security policy template. Forces replacement on change.
- cluster
Id String - required string → The ID of the Kubernetes cluster. Forces replacement on change.
- enabled Boolean
- optional boolean → Controls whether the security policy is enabled. Default is
true. Changing this updates the security policy. - namespace String
- required string → Namespace to apply security policy to. Changing this updates the security policy.
- policy
Settings String - required string → Policy settings. Changing this updates the security policy.
- region String
- optional string → The region in which to create the Kubernetes security policy. If omitted, the provider's
regionis used. Forces replacement on change. - security
Policy StringTemplate Id - required string → The ID of the security policy template. Forces replacement on change.
Import
Security policies can be imported using the id, e.g.
$ pulumi import vkcs:index/kubernetesSecurityPolicyV2:KubernetesSecurityPolicyV2 replicalimits 3DGdkgFCVhIRjYUgHCKQfU4bO6J
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- vkcs vk-cs/terraform-provider-vkcs
- License
- Notes
- This Pulumi package is based on the
vkcsTerraform Provider.
published on Thursday, Jun 25, 2026 by vk-cs