1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. dcdn
  5. Kv
Alibaba Cloud v3.55.0 published on Tuesday, Apr 30, 2024 by Pulumi

alicloud.dcdn.Kv

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.55.0 published on Tuesday, Apr 30, 2024 by Pulumi

    Provides a Dcdn Kv resource.

    For information about Dcdn Kv and how to use it, see What is Kv.

    NOTE: Available since v1.198.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    import * as random from "@pulumi/random";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = new random.index.Integer("default", {
        min: 10000,
        max: 99999,
    });
    const defaultKvNamespace = new alicloud.dcdn.KvNamespace("default", {
        description: name,
        namespace: `${name}-${_default.result}`,
    });
    const defaultKv = new alicloud.dcdn.Kv("default", {
        value: "example-value",
        key: `${name}-${_default.result}`,
        namespace: defaultKvNamespace.namespace,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    import pulumi_random as random
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = random.index.Integer("default",
        min=10000,
        max=99999)
    default_kv_namespace = alicloud.dcdn.KvNamespace("default",
        description=name,
        namespace=f"{name}-{default['result']}")
    default_kv = alicloud.dcdn.Kv("default",
        value="example-value",
        key=f"{name}-{default['result']}",
        namespace=default_kv_namespace.namespace)
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/dcdn"
    	"github.com/pulumi/pulumi-random/sdk/v4/go/random"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
    			Min: 10000,
    			Max: 99999,
    		})
    		if err != nil {
    			return err
    		}
    		defaultKvNamespace, err := dcdn.NewKvNamespace(ctx, "default", &dcdn.KvNamespaceArgs{
    			Description: pulumi.String(name),
    			Namespace:   pulumi.String(fmt.Sprintf("%v-%v", name, _default.Result)),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = dcdn.NewKv(ctx, "default", &dcdn.KvArgs{
    			Value:     pulumi.String("example-value"),
    			Key:       pulumi.String(fmt.Sprintf("%v-%v", name, _default.Result)),
    			Namespace: defaultKvNamespace.Namespace,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    using Random = Pulumi.Random;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = new Random.Index.Integer("default", new()
        {
            Min = 10000,
            Max = 99999,
        });
    
        var defaultKvNamespace = new AliCloud.Dcdn.KvNamespace("default", new()
        {
            Description = name,
            Namespace = $"{name}-{@default.Result}",
        });
    
        var defaultKv = new AliCloud.Dcdn.Kv("default", new()
        {
            Value = "example-value",
            Key = $"{name}-{@default.Result}",
            Namespace = defaultKvNamespace.Namespace,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.random.integer;
    import com.pulumi.random.IntegerArgs;
    import com.pulumi.alicloud.dcdn.KvNamespace;
    import com.pulumi.alicloud.dcdn.KvNamespaceArgs;
    import com.pulumi.alicloud.dcdn.Kv;
    import com.pulumi.alicloud.dcdn.KvArgs;
    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 config = ctx.config();
            final var name = config.get("name").orElse("terraform-example");
            var default_ = new Integer("default", IntegerArgs.builder()        
                .min(10000)
                .max(99999)
                .build());
    
            var defaultKvNamespace = new KvNamespace("defaultKvNamespace", KvNamespaceArgs.builder()        
                .description(name)
                .namespace(String.format("%s-%s", name,default_.result()))
                .build());
    
            var defaultKv = new Kv("defaultKv", KvArgs.builder()        
                .value("example-value")
                .key(String.format("%s-%s", name,default_.result()))
                .namespace(defaultKvNamespace.namespace())
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      default:
        type: random:integer
        properties:
          min: 10000
          max: 99999
      defaultKvNamespace:
        type: alicloud:dcdn:KvNamespace
        name: default
        properties:
          description: ${name}
          namespace: ${name}-${default.result}
      defaultKv:
        type: alicloud:dcdn:Kv
        name: default
        properties:
          value: example-value
          key: ${name}-${default.result}
          namespace: ${defaultKvNamespace.namespace}
    

    Create Kv Resource

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

    Constructor syntax

    new Kv(name: string, args: KvArgs, opts?: CustomResourceOptions);
    @overload
    def Kv(resource_name: str,
           args: KvArgs,
           opts: Optional[ResourceOptions] = None)
    
    @overload
    def Kv(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           key: Optional[str] = None,
           namespace: Optional[str] = None,
           value: Optional[str] = None)
    func NewKv(ctx *Context, name string, args KvArgs, opts ...ResourceOption) (*Kv, error)
    public Kv(string name, KvArgs args, CustomResourceOptions? opts = null)
    public Kv(String name, KvArgs args)
    public Kv(String name, KvArgs args, CustomResourceOptions options)
    
    type: alicloud:dcdn:Kv
    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 KvArgs
    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 KvArgs
    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 KvArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args KvArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args KvArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var kvResource = new AliCloud.Dcdn.Kv("kvResource", new()
    {
        Key = "string",
        Namespace = "string",
        Value = "string",
    });
    
    example, err := dcdn.NewKv(ctx, "kvResource", &dcdn.KvArgs{
    	Key:       pulumi.String("string"),
    	Namespace: pulumi.String("string"),
    	Value:     pulumi.String("string"),
    })
    
    var kvResource = new Kv("kvResource", KvArgs.builder()        
        .key("string")
        .namespace("string")
        .value("string")
        .build());
    
    kv_resource = alicloud.dcdn.Kv("kvResource",
        key="string",
        namespace="string",
        value="string")
    
    const kvResource = new alicloud.dcdn.Kv("kvResource", {
        key: "string",
        namespace: "string",
        value: "string",
    });
    
    type: alicloud:dcdn:Kv
    properties:
        key: string
        namespace: string
        value: string
    

    Kv Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The Kv resource accepts the following input properties:

    Key string
    The name of the key to Put, the longest 512, cannot contain spaces.
    Namespace string
    The name specified when the customer calls PutDcdnKvNamespace.
    Value string
    The content of key, up to 2M(210001000).
    Key string
    The name of the key to Put, the longest 512, cannot contain spaces.
    Namespace string
    The name specified when the customer calls PutDcdnKvNamespace.
    Value string
    The content of key, up to 2M(210001000).
    key String
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace String
    The name specified when the customer calls PutDcdnKvNamespace.
    value String
    The content of key, up to 2M(210001000).
    key string
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace string
    The name specified when the customer calls PutDcdnKvNamespace.
    value string
    The content of key, up to 2M(210001000).
    key str
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace str
    The name specified when the customer calls PutDcdnKvNamespace.
    value str
    The content of key, up to 2M(210001000).
    key String
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace String
    The name specified when the customer calls PutDcdnKvNamespace.
    value String
    The content of key, up to 2M(210001000).

    Outputs

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

    Get an existing Kv 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?: KvState, opts?: CustomResourceOptions): Kv
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            key: Optional[str] = None,
            namespace: Optional[str] = None,
            value: Optional[str] = None) -> Kv
    func GetKv(ctx *Context, name string, id IDInput, state *KvState, opts ...ResourceOption) (*Kv, error)
    public static Kv Get(string name, Input<string> id, KvState? state, CustomResourceOptions? opts = null)
    public static Kv get(String name, Output<String> id, KvState 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.
    The following state arguments are supported:
    Key string
    The name of the key to Put, the longest 512, cannot contain spaces.
    Namespace string
    The name specified when the customer calls PutDcdnKvNamespace.
    Value string
    The content of key, up to 2M(210001000).
    Key string
    The name of the key to Put, the longest 512, cannot contain spaces.
    Namespace string
    The name specified when the customer calls PutDcdnKvNamespace.
    Value string
    The content of key, up to 2M(210001000).
    key String
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace String
    The name specified when the customer calls PutDcdnKvNamespace.
    value String
    The content of key, up to 2M(210001000).
    key string
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace string
    The name specified when the customer calls PutDcdnKvNamespace.
    value string
    The content of key, up to 2M(210001000).
    key str
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace str
    The name specified when the customer calls PutDcdnKvNamespace.
    value str
    The content of key, up to 2M(210001000).
    key String
    The name of the key to Put, the longest 512, cannot contain spaces.
    namespace String
    The name specified when the customer calls PutDcdnKvNamespace.
    value String
    The content of key, up to 2M(210001000).

    Import

    Dcdn Kv can be imported using the id, e.g.

    $ pulumi import alicloud:dcdn/kv:Kv example <namespace>:<key>
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.55.0 published on Tuesday, Apr 30, 2024 by Pulumi