1. Registry
  2. Packages
  3. Alibaba Cloud Provider
  4. API Docs
  5. kms
  6. Secret
Viewing docs for Alibaba Cloud v4.0.1
published on Tuesday, Oct 27, 2026 by Pulumi
alicloud logo alicloud logo
Viewing docs for Alibaba Cloud v4.0.1
published on Tuesday, Oct 27, 2026 by Pulumi

    Provides a KMS Secret resource.

    For information about KMS Secret and how to use it, see What is Secret.

    NOTE: Available since v1.76.0.

    NOTE: Starting from KMS 3.0, secrets are created inside a dedicated KMS instance. When you create a secret in KMS 3.0, you must specify dkmsInstanceId and encryptionKeyId. The examples below show how to provide them. If your account still uses the legacy shared KMS and does not require a dedicated instance, these two parameters can be omitted, but this legacy behavior is no longer recommended.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    // Replace the IDs with your own dedicated KMS instance and key.
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const defaultSecret = new alicloud.kms.Secret("default", {
        secretName: name,
        secretData: "Secret data",
        versionId: "v1",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    # Replace the IDs with your own dedicated KMS instance and key.
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    default_secret = alicloud.kms.Secret("default",
        secret_name=name,
        secret_data="Secret data",
        version_id="v1",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		// Replace the IDs with your own dedicated KMS instance and key.
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = kms.NewSecret(ctx, "default", &kms.SecretArgs{
    			SecretName:                 pulumi.String(name),
    			SecretData:                 pulumi.String("Secret data"),
    			VersionId:                  pulumi.String("v1"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        // Replace the IDs with your own dedicated KMS instance and key.
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var defaultSecret = new AliCloud.Kms.Secret("default", new()
        {
            SecretName = name,
            SecretData = "Secret data",
            VersionId = "v1",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            // Replace the IDs with your own dedicated KMS instance and key.
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var defaultSecret = new Secret("defaultSecret", SecretArgs.builder()
                .secretName(name)
                .secretData("Secret data")
                .versionId("v1")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      defaultSecret:
        type: alicloud:kms:Secret
        name: default
        properties:
          secretName: ${name}
          secretData: Secret data
          versionId: v1
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          forceDeleteWithoutRecovery: true
    variables:
      # Replace the IDs with your own dedicated KMS instance and key.
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "default" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name                   = var.name
      secret_data                   = "Secret data"
      version_id                    = "v1"
      dkms_instance_id              = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id             = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    # Replace the IDs with your own dedicated KMS instance and key.
    

    Create a generic secret

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const generic = new alicloud.kms.Secret("generic", {
        secretName: name,
        secretType: "Generic",
        secretData: "Secret data",
        versionId: "v1",
        secretDataType: "text",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    generic = alicloud.kms.Secret("generic",
        secret_name=name,
        secret_type="Generic",
        secret_data="Secret data",
        version_id="v1",
        secret_data_type="text",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = kms.NewSecret(ctx, "generic", &kms.SecretArgs{
    			SecretName:                 pulumi.String(name),
    			SecretType:                 pulumi.String("Generic"),
    			SecretData:                 pulumi.String("Secret data"),
    			VersionId:                  pulumi.String("v1"),
    			SecretDataType:             pulumi.String("text"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var generic = new AliCloud.Kms.Secret("generic", new()
        {
            SecretName = name,
            SecretType = "Generic",
            SecretData = "Secret data",
            VersionId = "v1",
            SecretDataType = "text",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var generic = new Secret("generic", SecretArgs.builder()
                .secretName(name)
                .secretType("Generic")
                .secretData("Secret data")
                .versionId("v1")
                .secretDataType("text")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      generic:
        type: alicloud:kms:Secret
        properties:
          secretName: ${name}
          secretType: Generic
          secretData: Secret data
          versionId: v1
          secretDataType: text
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          forceDeleteWithoutRecovery: true
    variables:
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "generic" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name                   = var.name
      secret_type                   = "Generic"
      secret_data                   = "Secret data"
      version_id                    = "v1"
      secret_data_type              = "text"
      dkms_instance_id              = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id             = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    

    Create an RDS secret

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const rds = new alicloud.kms.Secret("rds", {
        secretName: name,
        secretType: "Rds",
        secretData: JSON.stringify({
            Accounts: [{
                AccountName: "rds_user",
                AccountPassword: "YourPassword12345!",
            }],
        }),
        versionId: "v1",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        extendedConfig: JSON.stringify({
            SecretSubType: "SingleUser",
            DBInstanceId: "rm-bp1b3dd3a506e****",
        }),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import json
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    rds = alicloud.kms.Secret("rds",
        secret_name=name,
        secret_type="Rds",
        secret_data=json.dumps({
            "Accounts": [{
                "AccountName": "rds_user",
                "AccountPassword": "YourPassword12345!",
            }],
        }),
        version_id="v1",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        extended_config=json.dumps({
            "SecretSubType": "SingleUser",
            "DBInstanceId": "rm-bp1b3dd3a506e****",
        }),
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string][]map[string]string{
    			"Accounts": []map[string]string{
    				{
    					"AccountName":     "rds_user",
    					"AccountPassword": "YourPassword12345!",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		tmpJSON1, err := json.Marshal(map[string]string{
    			"SecretSubType": "SingleUser",
    			"DBInstanceId":  "rm-bp1b3dd3a506e****",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		_, err = kms.NewSecret(ctx, "rds", &kms.SecretArgs{
    			SecretName:                 pulumi.String(name),
    			SecretType:                 pulumi.String("Rds"),
    			SecretData:                 pulumi.String(json0),
    			VersionId:                  pulumi.String("v1"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ExtendedConfig:             pulumi.String(json1),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var rds = new AliCloud.Kms.Secret("rds", new()
        {
            SecretName = name,
            SecretType = "Rds",
            SecretData = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Accounts"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["AccountName"] = "rds_user",
                        ["AccountPassword"] = "YourPassword12345!",
                    },
                },
            }),
            VersionId = "v1",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ExtendedConfig = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["SecretSubType"] = "SingleUser",
                ["DBInstanceId"] = "rm-bp1b3dd3a506e****",
            }),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var rds = new Secret("rds", SecretArgs.builder()
                .secretName(name)
                .secretType("Rds")
                .secretData(serializeJson(
                    jsonObject(
                        jsonProperty("Accounts", jsonArray(jsonObject(
                            jsonProperty("AccountName", "rds_user"),
                            jsonProperty("AccountPassword", "YourPassword12345!")
                        )))
                    )))
                .versionId("v1")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .extendedConfig(serializeJson(
                    jsonObject(
                        jsonProperty("SecretSubType", "SingleUser"),
                        jsonProperty("DBInstanceId", "rm-bp1b3dd3a506e****")
                    )))
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      rds:
        type: alicloud:kms:Secret
        properties:
          secretName: ${name}
          secretType: Rds
          secretData:
            fn::toJSON:
              Accounts:
                - AccountName: rds_user
                  AccountPassword: YourPassword12345!
          versionId: v1
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          extendedConfig:
            fn::toJSON:
              SecretSubType: SingleUser
              DBInstanceId: rm-bp1b3dd3a506e****
          forceDeleteWithoutRecovery: true
    variables:
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "rds" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name = var.name
      secret_type = "Rds"
      secret_data = jsonencode({
        "Accounts" = [{
          "AccountName"     = "rds_user"
          "AccountPassword" = "YourPassword12345!"
        }]
      })
      version_id        = "v1"
      dkms_instance_id  = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      extended_config = jsonencode({
        "SecretSubType" = "SingleUser"
        "DBInstanceId"  = "rm-bp1b3dd3a506e****"
      })
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    

    Create a Redis/Tair secret

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const redis = new alicloud.kms.Secret("redis", {
        secretName: name,
        secretType: "Redis",
        secretData: "$Auto",
        versionId: "v1",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        extendedConfig: JSON.stringify({
            SecretSubType: "DoubleUsers",
            AccountName: "redis_user",
            CloneAccountName: "redis_user_clone",
            AccountPrivilege: "ROLE_READ_ONLY",
            InstanceId: "r-bp1b3dd3a506e****",
            RegionId: "cn-hangzhou",
        }),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import json
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    redis = alicloud.kms.Secret("redis",
        secret_name=name,
        secret_type="Redis",
        secret_data="$Auto",
        version_id="v1",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        extended_config=json.dumps({
            "SecretSubType": "DoubleUsers",
            "AccountName": "redis_user",
            "CloneAccountName": "redis_user_clone",
            "AccountPrivilege": "ROLE_READ_ONLY",
            "InstanceId": "r-bp1b3dd3a506e****",
            "RegionId": "cn-hangzhou",
        }),
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]string{
    			"SecretSubType":    "DoubleUsers",
    			"AccountName":      "redis_user",
    			"CloneAccountName": "redis_user_clone",
    			"AccountPrivilege": "ROLE_READ_ONLY",
    			"InstanceId":       "r-bp1b3dd3a506e****",
    			"RegionId":         "cn-hangzhou",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = kms.NewSecret(ctx, "redis", &kms.SecretArgs{
    			SecretName:                 pulumi.String(name),
    			SecretType:                 pulumi.String("Redis"),
    			SecretData:                 pulumi.String("$Auto"),
    			VersionId:                  pulumi.String("v1"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ExtendedConfig:             pulumi.String(json0),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var redis = new AliCloud.Kms.Secret("redis", new()
        {
            SecretName = name,
            SecretType = "Redis",
            SecretData = "$Auto",
            VersionId = "v1",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ExtendedConfig = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["SecretSubType"] = "DoubleUsers",
                ["AccountName"] = "redis_user",
                ["CloneAccountName"] = "redis_user_clone",
                ["AccountPrivilege"] = "ROLE_READ_ONLY",
                ["InstanceId"] = "r-bp1b3dd3a506e****",
                ["RegionId"] = "cn-hangzhou",
            }),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var redis = new Secret("redis", SecretArgs.builder()
                .secretName(name)
                .secretType("Redis")
                .secretData("$Auto")
                .versionId("v1")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .extendedConfig(serializeJson(
                    jsonObject(
                        jsonProperty("SecretSubType", "DoubleUsers"),
                        jsonProperty("AccountName", "redis_user"),
                        jsonProperty("CloneAccountName", "redis_user_clone"),
                        jsonProperty("AccountPrivilege", "ROLE_READ_ONLY"),
                        jsonProperty("InstanceId", "r-bp1b3dd3a506e****"),
                        jsonProperty("RegionId", "cn-hangzhou")
                    )))
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      redis:
        type: alicloud:kms:Secret
        properties:
          secretName: ${name}
          secretType: Redis
          secretData: $Auto
          versionId: v1
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          extendedConfig:
            fn::toJSON:
              SecretSubType: DoubleUsers
              AccountName: redis_user
              CloneAccountName: redis_user_clone
              AccountPrivilege: ROLE_READ_ONLY
              InstanceId: r-bp1b3dd3a506e****
              RegionId: cn-hangzhou
          forceDeleteWithoutRecovery: true
    variables:
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "redis" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name       = var.name
      secret_type       = "Redis"
      secret_data       = "$Auto"
      version_id        = "v1"
      dkms_instance_id  = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      extended_config = jsonencode({
        "SecretSubType"    = "DoubleUsers"
        "AccountName"      = "redis_user"
        "CloneAccountName" = "redis_user_clone"
        "AccountPrivilege" = "ROLE_READ_ONLY"
        "InstanceId"       = "r-bp1b3dd3a506e****"
        "RegionId"         = "cn-hangzhou"
      })
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    

    Create a RAM credentials secret

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const ram = new alicloud.kms.Secret("ram", {
        secretName: "$Auto",
        secretType: "RAMCredentials",
        secretData: JSON.stringify({
            AccessKeys: [{
                AccessKeyId: "LTAI********************",
                AccessKeySecret: "YourAccessKeySecret",
            }],
        }),
        versionId: "v1",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        extendedConfig: JSON.stringify({
            SecretSubType: "RamUserAccessKey",
            UserName: "ram_user",
        }),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import json
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    ram = alicloud.kms.Secret("ram",
        secret_name="$Auto",
        secret_type="RAMCredentials",
        secret_data=json.dumps({
            "AccessKeys": [{
                "AccessKeyId": "LTAI********************",
                "AccessKeySecret": "YourAccessKeySecret",
            }],
        }),
        version_id="v1",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        extended_config=json.dumps({
            "SecretSubType": "RamUserAccessKey",
            "UserName": "ram_user",
        }),
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string][]map[string]string{
    			"AccessKeys": []map[string]string{
    				{
    					"AccessKeyId":     "LTAI********************",
    					"AccessKeySecret": "YourAccessKeySecret",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		tmpJSON1, err := json.Marshal(map[string]string{
    			"SecretSubType": "RamUserAccessKey",
    			"UserName":      "ram_user",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		_, err = kms.NewSecret(ctx, "ram", &kms.SecretArgs{
    			SecretName:                 pulumi.String("$Auto"),
    			SecretType:                 pulumi.String("RAMCredentials"),
    			SecretData:                 pulumi.String(json0),
    			VersionId:                  pulumi.String("v1"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ExtendedConfig:             pulumi.String(json1),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var ram = new AliCloud.Kms.Secret("ram", new()
        {
            SecretName = "$Auto",
            SecretType = "RAMCredentials",
            SecretData = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["AccessKeys"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["AccessKeyId"] = "LTAI********************",
                        ["AccessKeySecret"] = "YourAccessKeySecret",
                    },
                },
            }),
            VersionId = "v1",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ExtendedConfig = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["SecretSubType"] = "RamUserAccessKey",
                ["UserName"] = "ram_user",
            }),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var ram = new Secret("ram", SecretArgs.builder()
                .secretName("$Auto")
                .secretType("RAMCredentials")
                .secretData(serializeJson(
                    jsonObject(
                        jsonProperty("AccessKeys", jsonArray(jsonObject(
                            jsonProperty("AccessKeyId", "LTAI********************"),
                            jsonProperty("AccessKeySecret", "YourAccessKeySecret")
                        )))
                    )))
                .versionId("v1")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .extendedConfig(serializeJson(
                    jsonObject(
                        jsonProperty("SecretSubType", "RamUserAccessKey"),
                        jsonProperty("UserName", "ram_user")
                    )))
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      ram:
        type: alicloud:kms:Secret
        properties:
          secretName: $Auto
          secretType: RAMCredentials
          secretData:
            fn::toJSON:
              AccessKeys:
                - AccessKeyId: LTAI********************
                  AccessKeySecret: YourAccessKeySecret
          versionId: v1
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          extendedConfig:
            fn::toJSON:
              SecretSubType: RamUserAccessKey
              UserName: ram_user
          forceDeleteWithoutRecovery: true
    variables:
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "ram" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name = "$Auto"
      secret_type = "RAMCredentials"
      secret_data = jsonencode({
        "AccessKeys" = [{
          "AccessKeyId"     = "LTAI********************"
          "AccessKeySecret" = "YourAccessKeySecret"
        }]
      })
      version_id        = "v1"
      dkms_instance_id  = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      extended_config = jsonencode({
        "SecretSubType" = "RamUserAccessKey"
        "UserName"      = "ram_user"
      })
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    

    Create an ECS secret

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const ecs = new alicloud.kms.Secret("ecs", {
        secretName: `acs/ecs/${name}`,
        secretType: "ECS",
        secretData: JSON.stringify({
            UserName: "root",
            Password: "YourPassword12345!",
        }),
        versionId: "v1",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        extendedConfig: JSON.stringify({
            SecretSubType: "Password",
            RegionId: "cn-hangzhou",
            InstanceId: "i-bp1b3dd3a506e****",
        }),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import json
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    ecs = alicloud.kms.Secret("ecs",
        secret_name=f"acs/ecs/{name}",
        secret_type="ECS",
        secret_data=json.dumps({
            "UserName": "root",
            "Password": "YourPassword12345!",
        }),
        version_id="v1",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        extended_config=json.dumps({
            "SecretSubType": "Password",
            "RegionId": "cn-hangzhou",
            "InstanceId": "i-bp1b3dd3a506e****",
        }),
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]string{
    			"UserName": "root",
    			"Password": "YourPassword12345!",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		tmpJSON1, err := json.Marshal(map[string]string{
    			"SecretSubType": "Password",
    			"RegionId":      "cn-hangzhou",
    			"InstanceId":    "i-bp1b3dd3a506e****",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		_, err = kms.NewSecret(ctx, "ecs", &kms.SecretArgs{
    			SecretName:                 pulumi.Sprintf("acs/ecs/%v", name),
    			SecretType:                 pulumi.String("ECS"),
    			SecretData:                 pulumi.String(json0),
    			VersionId:                  pulumi.String("v1"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ExtendedConfig:             pulumi.String(json1),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var ecs = new AliCloud.Kms.Secret("ecs", new()
        {
            SecretName = $"acs/ecs/{name}",
            SecretType = "ECS",
            SecretData = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["UserName"] = "root",
                ["Password"] = "YourPassword12345!",
            }),
            VersionId = "v1",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ExtendedConfig = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["SecretSubType"] = "Password",
                ["RegionId"] = "cn-hangzhou",
                ["InstanceId"] = "i-bp1b3dd3a506e****",
            }),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var ecs = new Secret("ecs", SecretArgs.builder()
                .secretName(String.format("acs/ecs/%s", name))
                .secretType("ECS")
                .secretData(serializeJson(
                    jsonObject(
                        jsonProperty("UserName", "root"),
                        jsonProperty("Password", "YourPassword12345!")
                    )))
                .versionId("v1")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .extendedConfig(serializeJson(
                    jsonObject(
                        jsonProperty("SecretSubType", "Password"),
                        jsonProperty("RegionId", "cn-hangzhou"),
                        jsonProperty("InstanceId", "i-bp1b3dd3a506e****")
                    )))
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      ecs:
        type: alicloud:kms:Secret
        properties:
          secretName: acs/ecs/${name}
          secretType: ECS
          secretData:
            fn::toJSON:
              UserName: root
              Password: YourPassword12345!
          versionId: v1
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          extendedConfig:
            fn::toJSON:
              SecretSubType: Password
              RegionId: cn-hangzhou
              InstanceId: i-bp1b3dd3a506e****
          forceDeleteWithoutRecovery: true
    variables:
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "ecs" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name ="acs/ecs/${var.name}"
      secret_type = "ECS"
      secret_data = jsonencode({
        "UserName" = "root"
        "Password" = "YourPassword12345!"
      })
      version_id        = "v1"
      dkms_instance_id  = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      extended_config = jsonencode({
        "SecretSubType" = "Password"
        "RegionId"      = "cn-hangzhou"
        "InstanceId"    = "i-bp1b3dd3a506e****"
      })
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    

    Create a PolarDB secret

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.kms.getInstances({
        ids: ["kst-bjj62d8f5e0sgtx8h****"],
    });
    const defaultGetKeys = alicloud.kms.getKeys({
        ids: ["key-gzz63ff0db5hg3qje****"],
    });
    const polardb = new alicloud.kms.Secret("polardb", {
        secretName: name,
        secretType: "PolarDB",
        secretData: "$Auto",
        versionId: "v1",
        dkmsInstanceId: _default.then(_default => _default.instances?.[0]?.instanceId),
        encryptionKeyId: defaultGetKeys.then(defaultGetKeys => defaultGetKeys.keys?.[0]?.id),
        extendedConfig: JSON.stringify({
            SecretSubType: "DoubleUsers",
            RegionId: "cn-hangzhou",
            DBClusterId: "pc-bp1b3dd3a506e****",
            DBType: "MySQL",
            AccountName: "polardb_user",
            CloneAccountName: "polardb_user_clone",
            AccountType: "Normal",
            AccountPrivilege: "ReadOnly",
            DBName: "testdb",
        }),
        forceDeleteWithoutRecovery: true,
    });
    
    import pulumi
    import json
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.kms.get_instances(ids=["kst-bjj62d8f5e0sgtx8h****"])
    default_get_keys = alicloud.kms.get_keys(ids=["key-gzz63ff0db5hg3qje****"])
    polardb = alicloud.kms.Secret("polardb",
        secret_name=name,
        secret_type="PolarDB",
        secret_data="$Auto",
        version_id="v1",
        dkms_instance_id=default.instances[0].instance_id,
        encryption_key_id=default_get_keys.keys[0].id,
        extended_config=json.dumps({
            "SecretSubType": "DoubleUsers",
            "RegionId": "cn-hangzhou",
            "DBClusterId": "pc-bp1b3dd3a506e****",
            "DBType": "MySQL",
            "AccountName": "polardb_user",
            "CloneAccountName": "polardb_user_clone",
            "AccountType": "Normal",
            "AccountPrivilege": "ReadOnly",
            "DBName": "testdb",
        }),
        force_delete_without_recovery=True)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v4/go/alicloud/kms"
    	"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
    		}
    		_default, err := kms.GetInstances(ctx, &kms.GetInstancesArgs{
    			Ids: []string{
    				"kst-bjj62d8f5e0sgtx8h****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetKeys, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
    			Ids: []string{
    				"key-gzz63ff0db5hg3qje****",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]string{
    			"SecretSubType":    "DoubleUsers",
    			"RegionId":         "cn-hangzhou",
    			"DBClusterId":      "pc-bp1b3dd3a506e****",
    			"DBType":           "MySQL",
    			"AccountName":      "polardb_user",
    			"CloneAccountName": "polardb_user_clone",
    			"AccountType":      "Normal",
    			"AccountPrivilege": "ReadOnly",
    			"DBName":           "testdb",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = kms.NewSecret(ctx, "polardb", &kms.SecretArgs{
    			SecretName:                 pulumi.String(name),
    			SecretType:                 pulumi.String("PolarDB"),
    			SecretData:                 pulumi.String("$Auto"),
    			VersionId:                  pulumi.String("v1"),
    			DkmsInstanceId:             pulumi.String(_default.Instances[0].InstanceId),
    			EncryptionKeyId:            pulumi.String(defaultGetKeys.Keys[0].Id),
    			ExtendedConfig:             pulumi.String(json0),
    			ForceDeleteWithoutRecovery: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Kms.GetInstances.Invoke(new()
        {
            Ids = new[]
            {
                "kst-bjj62d8f5e0sgtx8h****",
            },
        });
    
        var defaultGetKeys = AliCloud.Kms.GetKeys.Invoke(new()
        {
            Ids = new[]
            {
                "key-gzz63ff0db5hg3qje****",
            },
        });
    
        var polardb = new AliCloud.Kms.Secret("polardb", new()
        {
            SecretName = name,
            SecretType = "PolarDB",
            SecretData = "$Auto",
            VersionId = "v1",
            DkmsInstanceId = @default.Apply(@default => @default.Apply(getInstancesResult => getInstancesResult.Instances[0]?.InstanceId)),
            EncryptionKeyId = defaultGetKeys.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
            ExtendedConfig = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["SecretSubType"] = "DoubleUsers",
                ["RegionId"] = "cn-hangzhou",
                ["DBClusterId"] = "pc-bp1b3dd3a506e****",
                ["DBType"] = "MySQL",
                ["AccountName"] = "polardb_user",
                ["CloneAccountName"] = "polardb_user_clone",
                ["AccountType"] = "Normal",
                ["AccountPrivilege"] = "ReadOnly",
                ["DBName"] = "testdb",
            }),
            ForceDeleteWithoutRecovery = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.kms.KmsFunctions;
    import com.pulumi.alicloud.kms.inputs.GetInstancesArgs;
    import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
    import com.pulumi.alicloud.kms.Secret;
    import com.pulumi.alicloud.kms.SecretArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    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");
            final var default = KmsFunctions.getInstances(GetInstancesArgs.builder()
                .ids("kst-bjj62d8f5e0sgtx8h****")
                .build());
    
            final var defaultGetKeys = KmsFunctions.getKeys(GetKeysArgs.builder()
                .ids("key-gzz63ff0db5hg3qje****")
                .build());
    
            var polardb = new Secret("polardb", SecretArgs.builder()
                .secretName(name)
                .secretType("PolarDB")
                .secretData("$Auto")
                .versionId("v1")
                .dkmsInstanceId(default_.instances()[0].instanceId())
                .encryptionKeyId(defaultGetKeys.keys()[0].id())
                .extendedConfig(serializeJson(
                    jsonObject(
                        jsonProperty("SecretSubType", "DoubleUsers"),
                        jsonProperty("RegionId", "cn-hangzhou"),
                        jsonProperty("DBClusterId", "pc-bp1b3dd3a506e****"),
                        jsonProperty("DBType", "MySQL"),
                        jsonProperty("AccountName", "polardb_user"),
                        jsonProperty("CloneAccountName", "polardb_user_clone"),
                        jsonProperty("AccountType", "Normal"),
                        jsonProperty("AccountPrivilege", "ReadOnly"),
                        jsonProperty("DBName", "testdb")
                    )))
                .forceDeleteWithoutRecovery(true)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      polardb:
        type: alicloud:kms:Secret
        properties:
          secretName: ${name}
          secretType: PolarDB
          secretData: $Auto
          versionId: v1
          dkmsInstanceId: ${default.instances[0].instanceId}
          encryptionKeyId: ${defaultGetKeys.keys[0].id}
          extendedConfig:
            fn::toJSON:
              SecretSubType: DoubleUsers
              RegionId: cn-hangzhou
              DBClusterId: pc-bp1b3dd3a506e****
              DBType: MySQL
              AccountName: polardb_user
              CloneAccountName: polardb_user_clone
              AccountType: Normal
              AccountPrivilege: ReadOnly
              DBName: testdb
          forceDeleteWithoutRecovery: true
    variables:
      default:
        fn::invoke:
          function: alicloud:kms:getInstances
          arguments:
            ids:
              - kst-bjj62d8f5e0sgtx8h****
      defaultGetKeys:
        fn::invoke:
          function: alicloud:kms:getKeys
          arguments:
            ids:
              - key-gzz63ff0db5hg3qje****
    
    terraform {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_kms_instances" "default" {
      ids = ["kst-bjj62d8f5e0sgtx8h****"]
    }
    data "alicloud_kms_keys" "defaultGetKeys" {
      ids = ["key-gzz63ff0db5hg3qje****"]
    }
    
    resource "alicloud_kms_secret" "polardb" {
      lifecycle {
        create_before_destroy = true
      }
      secret_name       = var.name
      secret_type       = "PolarDB"
      secret_data       = "$Auto"
      version_id        = "v1"
      dkms_instance_id  = data.alicloud_kms_instances.default.instances[0].instance_id
      encryption_key_id = data.alicloud_kms_keys.defaultGetKeys.keys[0].id
      extended_config = jsonencode({
        "SecretSubType"    = "DoubleUsers"
        "RegionId"         = "cn-hangzhou"
        "DBClusterId"      = "pc-bp1b3dd3a506e****"
        "DBType"           = "MySQL"
        "AccountName"      = "polardb_user"
        "CloneAccountName" = "polardb_user_clone"
        "AccountType"      = "Normal"
        "AccountPrivilege" = "ReadOnly"
        "DBName"           = "testdb"
      })
      force_delete_without_recovery = true
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    

    📚 Need more examples? VIEW MORE EXAMPLES

    Create Secret Resource

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

    Constructor syntax

    new Secret(name: string, args: SecretArgs, opts?: CustomResourceOptions);
    @overload
    def Secret(resource_name: str,
               args: SecretArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Secret(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               secret_data: Optional[str] = None,
               version_id: Optional[str] = None,
               secret_name: Optional[str] = None,
               rotation_interval: Optional[str] = None,
               extended_config: Optional[str] = None,
               force_delete_without_recovery: Optional[bool] = None,
               policy: Optional[str] = None,
               recovery_window_in_days: Optional[int] = None,
               description: Optional[str] = None,
               encryption_key_id: Optional[str] = None,
               secret_data_type: Optional[str] = None,
               enable_automatic_rotation: Optional[bool] = None,
               secret_type: Optional[str] = None,
               tags: Optional[Mapping[str, str]] = None,
               dkms_instance_id: Optional[str] = None,
               version_stages: Optional[Sequence[str]] = None)
    func NewSecret(ctx *Context, name string, args SecretArgs, opts ...ResourceOption) (*Secret, error)
    public Secret(string name, SecretArgs args, CustomResourceOptions? opts = null)
    public Secret(String name, SecretArgs args)
    public Secret(String name, SecretArgs args, CustomResourceOptions options)
    
    type: alicloud:kms:Secret
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "alicloud_kms_secret" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args SecretArgs
    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 SecretArgs
    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 SecretArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecretArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecretArgs
    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 alicloudSecretResource = new AliCloud.Kms.Secret("alicloudSecretResource", new()
    {
        SecretData = "string",
        VersionId = "string",
        SecretName = "string",
        RotationInterval = "string",
        ExtendedConfig = "string",
        ForceDeleteWithoutRecovery = false,
        Policy = "string",
        RecoveryWindowInDays = 0,
        Description = "string",
        EncryptionKeyId = "string",
        SecretDataType = "string",
        EnableAutomaticRotation = false,
        SecretType = "string",
        Tags = 
        {
            { "string", "string" },
        },
        DkmsInstanceId = "string",
        VersionStages = new[]
        {
            "string",
        },
    });
    
    example, err := kms.NewSecret(ctx, "alicloudSecretResource", &kms.SecretArgs{
    	SecretData:                 pulumi.String("string"),
    	VersionId:                  pulumi.String("string"),
    	SecretName:                 pulumi.String("string"),
    	RotationInterval:           pulumi.String("string"),
    	ExtendedConfig:             pulumi.String("string"),
    	ForceDeleteWithoutRecovery: pulumi.Bool(false),
    	Policy:                     pulumi.String("string"),
    	RecoveryWindowInDays:       pulumi.Int(0),
    	Description:                pulumi.String("string"),
    	EncryptionKeyId:            pulumi.String("string"),
    	SecretDataType:             pulumi.String("string"),
    	EnableAutomaticRotation:    pulumi.Bool(false),
    	SecretType:                 pulumi.String("string"),
    	Tags: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	DkmsInstanceId: pulumi.String("string"),
    	VersionStages: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    resource "alicloud_kms_secret" "alicloudSecretResource" {
      lifecycle {
        create_before_destroy = true
      }
      secret_data                   = "string"
      version_id                    = "string"
      secret_name                   = "string"
      rotation_interval             = "string"
      extended_config               = "string"
      force_delete_without_recovery = false
      policy                        = "string"
      recovery_window_in_days       = 0
      description                   = "string"
      encryption_key_id             = "string"
      secret_data_type              = "string"
      enable_automatic_rotation     = false
      secret_type                   = "string"
      tags = {
        "string" = "string"
      }
      dkms_instance_id = "string"
      version_stages   = ["string"]
    }
    
    var alicloudSecretResource = new com.pulumi.alicloud.kms.Secret("alicloudSecretResource", com.pulumi.alicloud.kms.SecretArgs.builder()
        .secretData("string")
        .versionId("string")
        .secretName("string")
        .rotationInterval("string")
        .extendedConfig("string")
        .forceDeleteWithoutRecovery(false)
        .policy("string")
        .recoveryWindowInDays(0)
        .description("string")
        .encryptionKeyId("string")
        .secretDataType("string")
        .enableAutomaticRotation(false)
        .secretType("string")
        .tags(Map.of("string", "string"))
        .dkmsInstanceId("string")
        .versionStages("string")
        .build());
    
    alicloud_secret_resource = alicloud.kms.Secret("alicloudSecretResource",
        secret_data="string",
        version_id="string",
        secret_name="string",
        rotation_interval="string",
        extended_config="string",
        force_delete_without_recovery=False,
        policy="string",
        recovery_window_in_days=0,
        description="string",
        encryption_key_id="string",
        secret_data_type="string",
        enable_automatic_rotation=False,
        secret_type="string",
        tags={
            "string": "string",
        },
        dkms_instance_id="string",
        version_stages=["string"])
    
    const alicloudSecretResource = new alicloud.kms.Secret("alicloudSecretResource", {
        secretData: "string",
        versionId: "string",
        secretName: "string",
        rotationInterval: "string",
        extendedConfig: "string",
        forceDeleteWithoutRecovery: false,
        policy: "string",
        recoveryWindowInDays: 0,
        description: "string",
        encryptionKeyId: "string",
        secretDataType: "string",
        enableAutomaticRotation: false,
        secretType: "string",
        tags: {
            string: "string",
        },
        dkmsInstanceId: "string",
        versionStages: ["string"],
    });
    
    type: alicloud:kms:Secret
    properties:
        description: string
        dkmsInstanceId: string
        enableAutomaticRotation: false
        encryptionKeyId: string
        extendedConfig: string
        forceDeleteWithoutRecovery: false
        policy: string
        recoveryWindowInDays: 0
        rotationInterval: string
        secretData: string
        secretDataType: string
        secretName: string
        secretType: string
        tags:
            string: string
        versionId: string
        versionStages:
            - string
    

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

    SecretData string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    SecretName string
    The name of the secret. For more information, see How to use it.
    VersionId string
    The version number of the initial version.
    Description string
    The description of the secret.
    DkmsInstanceId string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    EnableAutomaticRotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    EncryptionKeyId string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    ExtendedConfig string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    ForceDeleteWithoutRecovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    Policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    RecoveryWindowInDays int
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    RotationInterval string
    The interval for automatic rotation. For more information, see How to use it.
    SecretDataType string
    The type of the secret value. Default value: text. Valid values: text, binary.
    SecretType string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    VersionStages List<string>
    The stage label that is used to mark the new version.
    SecretData string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    SecretName string
    The name of the secret. For more information, see How to use it.
    VersionId string
    The version number of the initial version.
    Description string
    The description of the secret.
    DkmsInstanceId string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    EnableAutomaticRotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    EncryptionKeyId string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    ExtendedConfig string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    ForceDeleteWithoutRecovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    Policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    RecoveryWindowInDays int
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    RotationInterval string
    The interval for automatic rotation. For more information, see How to use it.
    SecretDataType string
    The type of the secret value. Default value: text. Valid values: text, binary.
    SecretType string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    VersionStages []string
    The stage label that is used to mark the new version.
    secret_data string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secret_name string
    The name of the secret. For more information, see How to use it.
    version_id string
    The version number of the initial version.
    description string
    The description of the secret.
    dkms_instance_id string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enable_automatic_rotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryption_key_id string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extended_config string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    force_delete_without_recovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recovery_window_in_days number
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotation_interval string
    The interval for automatic rotation. For more information, see How to use it.
    secret_data_type string
    The type of the secret value. Default value: text. Valid values: text, binary.
    secret_type string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags map(string)
    A mapping of tags to assign to the resource.
    version_stages list(string)
    The stage label that is used to mark the new version.
    secretData String
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secretName String
    The name of the secret. For more information, see How to use it.
    versionId String
    The version number of the initial version.
    description String
    The description of the secret.
    dkmsInstanceId String
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enableAutomaticRotation Boolean
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryptionKeyId String
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extendedConfig String
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    forceDeleteWithoutRecovery Boolean
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    policy String
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recoveryWindowInDays Integer
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotationInterval String
    The interval for automatic rotation. For more information, see How to use it.
    secretDataType String
    The type of the secret value. Default value: text. Valid values: text, binary.
    secretType String
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    versionStages List<String>
    The stage label that is used to mark the new version.
    secretData string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secretName string
    The name of the secret. For more information, see How to use it.
    versionId string
    The version number of the initial version.
    description string
    The description of the secret.
    dkmsInstanceId string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enableAutomaticRotation boolean
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryptionKeyId string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extendedConfig string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    forceDeleteWithoutRecovery boolean
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recoveryWindowInDays number
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotationInterval string
    The interval for automatic rotation. For more information, see How to use it.
    secretDataType string
    The type of the secret value. Default value: text. Valid values: text, binary.
    secretType string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    versionStages string[]
    The stage label that is used to mark the new version.
    secret_data str
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secret_name str
    The name of the secret. For more information, see How to use it.
    version_id str
    The version number of the initial version.
    description str
    The description of the secret.
    dkms_instance_id str
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enable_automatic_rotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryption_key_id str
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extended_config str
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    force_delete_without_recovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    policy str
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recovery_window_in_days int
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotation_interval str
    The interval for automatic rotation. For more information, see How to use it.
    secret_data_type str
    The type of the secret value. Default value: text. Valid values: text, binary.
    secret_type str
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    version_stages Sequence[str]
    The stage label that is used to mark the new version.
    secretData String
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secretName String
    The name of the secret. For more information, see How to use it.
    versionId String
    The version number of the initial version.
    description String
    The description of the secret.
    dkmsInstanceId String
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enableAutomaticRotation Boolean
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryptionKeyId String
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extendedConfig String
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    forceDeleteWithoutRecovery Boolean
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    policy String
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recoveryWindowInDays Number
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotationInterval String
    The interval for automatic rotation. For more information, see How to use it.
    secretDataType String
    The type of the secret value. Default value: text. Valid values: text, binary.
    secretType String
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags Map<String>
    A mapping of tags to assign to the resource.
    versionStages List<String>
    The stage label that is used to mark the new version.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Secret resource produces the following output properties:

    Arn string
    The ARN of the secret.
    CreateTime string
    (Available since v1.224.0) The time when the secret is created.
    Id string
    The provider-assigned unique ID for this managed resource.
    PlannedDeleteTime string
    The time when the secret is scheduled to be deleted.
    Arn string
    The ARN of the secret.
    CreateTime string
    (Available since v1.224.0) The time when the secret is created.
    Id string
    The provider-assigned unique ID for this managed resource.
    PlannedDeleteTime string
    The time when the secret is scheduled to be deleted.
    arn string
    The ARN of the secret.
    create_time string
    (Available since v1.224.0) The time when the secret is created.
    id string
    The provider-assigned unique ID for this managed resource.
    planned_delete_time string
    The time when the secret is scheduled to be deleted.
    arn String
    The ARN of the secret.
    createTime String
    (Available since v1.224.0) The time when the secret is created.
    id String
    The provider-assigned unique ID for this managed resource.
    plannedDeleteTime String
    The time when the secret is scheduled to be deleted.
    arn string
    The ARN of the secret.
    createTime string
    (Available since v1.224.0) The time when the secret is created.
    id string
    The provider-assigned unique ID for this managed resource.
    plannedDeleteTime string
    The time when the secret is scheduled to be deleted.
    arn str
    The ARN of the secret.
    create_time str
    (Available since v1.224.0) The time when the secret is created.
    id str
    The provider-assigned unique ID for this managed resource.
    planned_delete_time str
    The time when the secret is scheduled to be deleted.
    arn String
    The ARN of the secret.
    createTime String
    (Available since v1.224.0) The time when the secret is created.
    id String
    The provider-assigned unique ID for this managed resource.
    plannedDeleteTime String
    The time when the secret is scheduled to be deleted.

    Look up Existing Secret Resource

    Get an existing Secret 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?: SecretState, opts?: CustomResourceOptions): Secret
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            arn: Optional[str] = None,
            create_time: Optional[str] = None,
            description: Optional[str] = None,
            dkms_instance_id: Optional[str] = None,
            enable_automatic_rotation: Optional[bool] = None,
            encryption_key_id: Optional[str] = None,
            extended_config: Optional[str] = None,
            force_delete_without_recovery: Optional[bool] = None,
            planned_delete_time: Optional[str] = None,
            policy: Optional[str] = None,
            recovery_window_in_days: Optional[int] = None,
            rotation_interval: Optional[str] = None,
            secret_data: Optional[str] = None,
            secret_data_type: Optional[str] = None,
            secret_name: Optional[str] = None,
            secret_type: Optional[str] = None,
            tags: Optional[Mapping[str, str]] = None,
            version_id: Optional[str] = None,
            version_stages: Optional[Sequence[str]] = None) -> Secret
    func GetSecret(ctx *Context, name string, id IDInput, state *SecretState, opts ...ResourceOption) (*Secret, error)
    public static Secret Get(string name, Input<string> id, SecretState? state, CustomResourceOptions? opts = null)
    public static Secret get(String name, Output<String> id, SecretState state, CustomResourceOptions options)
    resources:  _:    type: alicloud:kms:Secret    get:      id: ${id}
    import {
      to = alicloud_kms_secret.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.
    The following state arguments are supported:
    Arn string
    The ARN of the secret.
    CreateTime string
    (Available since v1.224.0) The time when the secret is created.
    Description string
    The description of the secret.
    DkmsInstanceId string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    EnableAutomaticRotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    EncryptionKeyId string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    ExtendedConfig string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    ForceDeleteWithoutRecovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    PlannedDeleteTime string
    The time when the secret is scheduled to be deleted.
    Policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    RecoveryWindowInDays int
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    RotationInterval string
    The interval for automatic rotation. For more information, see How to use it.
    SecretData string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    SecretDataType string
    The type of the secret value. Default value: text. Valid values: text, binary.
    SecretName string
    The name of the secret. For more information, see How to use it.
    SecretType string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    VersionId string
    The version number of the initial version.
    VersionStages List<string>
    The stage label that is used to mark the new version.
    Arn string
    The ARN of the secret.
    CreateTime string
    (Available since v1.224.0) The time when the secret is created.
    Description string
    The description of the secret.
    DkmsInstanceId string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    EnableAutomaticRotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    EncryptionKeyId string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    ExtendedConfig string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    ForceDeleteWithoutRecovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    PlannedDeleteTime string
    The time when the secret is scheduled to be deleted.
    Policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    RecoveryWindowInDays int
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    RotationInterval string
    The interval for automatic rotation. For more information, see How to use it.
    SecretData string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    SecretDataType string
    The type of the secret value. Default value: text. Valid values: text, binary.
    SecretName string
    The name of the secret. For more information, see How to use it.
    SecretType string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    VersionId string
    The version number of the initial version.
    VersionStages []string
    The stage label that is used to mark the new version.
    arn string
    The ARN of the secret.
    create_time string
    (Available since v1.224.0) The time when the secret is created.
    description string
    The description of the secret.
    dkms_instance_id string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enable_automatic_rotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryption_key_id string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extended_config string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    force_delete_without_recovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    planned_delete_time string
    The time when the secret is scheduled to be deleted.
    policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recovery_window_in_days number
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotation_interval string
    The interval for automatic rotation. For more information, see How to use it.
    secret_data string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secret_data_type string
    The type of the secret value. Default value: text. Valid values: text, binary.
    secret_name string
    The name of the secret. For more information, see How to use it.
    secret_type string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags map(string)
    A mapping of tags to assign to the resource.
    version_id string
    The version number of the initial version.
    version_stages list(string)
    The stage label that is used to mark the new version.
    arn String
    The ARN of the secret.
    createTime String
    (Available since v1.224.0) The time when the secret is created.
    description String
    The description of the secret.
    dkmsInstanceId String
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enableAutomaticRotation Boolean
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryptionKeyId String
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extendedConfig String
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    forceDeleteWithoutRecovery Boolean
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    plannedDeleteTime String
    The time when the secret is scheduled to be deleted.
    policy String
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recoveryWindowInDays Integer
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotationInterval String
    The interval for automatic rotation. For more information, see How to use it.
    secretData String
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secretDataType String
    The type of the secret value. Default value: text. Valid values: text, binary.
    secretName String
    The name of the secret. For more information, see How to use it.
    secretType String
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    versionId String
    The version number of the initial version.
    versionStages List<String>
    The stage label that is used to mark the new version.
    arn string
    The ARN of the secret.
    createTime string
    (Available since v1.224.0) The time when the secret is created.
    description string
    The description of the secret.
    dkmsInstanceId string
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enableAutomaticRotation boolean
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryptionKeyId string
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extendedConfig string
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    forceDeleteWithoutRecovery boolean
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    plannedDeleteTime string
    The time when the secret is scheduled to be deleted.
    policy string
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recoveryWindowInDays number
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotationInterval string
    The interval for automatic rotation. For more information, see How to use it.
    secretData string
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secretDataType string
    The type of the secret value. Default value: text. Valid values: text, binary.
    secretName string
    The name of the secret. For more information, see How to use it.
    secretType string
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    versionId string
    The version number of the initial version.
    versionStages string[]
    The stage label that is used to mark the new version.
    arn str
    The ARN of the secret.
    create_time str
    (Available since v1.224.0) The time when the secret is created.
    description str
    The description of the secret.
    dkms_instance_id str
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enable_automatic_rotation bool
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryption_key_id str
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extended_config str
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    force_delete_without_recovery bool
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    planned_delete_time str
    The time when the secret is scheduled to be deleted.
    policy str
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recovery_window_in_days int
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotation_interval str
    The interval for automatic rotation. For more information, see How to use it.
    secret_data str
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secret_data_type str
    The type of the secret value. Default value: text. Valid values: text, binary.
    secret_name str
    The name of the secret. For more information, see How to use it.
    secret_type str
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    version_id str
    The version number of the initial version.
    version_stages Sequence[str]
    The stage label that is used to mark the new version.
    arn String
    The ARN of the secret.
    createTime String
    (Available since v1.224.0) The time when the secret is created.
    description String
    The description of the secret.
    dkmsInstanceId String
    The ID of the KMS instance. NOTE: In KMS 3.0, this parameter is required.
    enableAutomaticRotation Boolean
    Specifies whether to enable automatic rotation. Default value: false. Valid values: true, false.
    encryptionKeyId String
    The ID of the KMS key used to encrypt the secret value. The key and the secret must belong to the same KMS instance, and the key must be a symmetric key. NOTE: In KMS 3.0, this parameter is required.
    extendedConfig String
    The extended configuration of the secret. This parameter is required when secretType is Rds, Redis, RAMCredentials, ECS or PolarDB. The value is a JSON string. For more information, see How to use it.
    forceDeleteWithoutRecovery Boolean
    Specifies whether to immediately delete a secret. Default value: false. Valid values: true, false.
    plannedDeleteTime String
    The time when the secret is scheduled to be deleted.
    policy String
    The content of the secret policy. The value is in the JSON format. The value can be up to 32,768 bytes in length. For more information, see How to use it.
    recoveryWindowInDays Number
    Specifies the recovery period of the secret if you do not forcibly delete it. Unit: Days. Default value: 30. Valid values: 7 to 30. NOTE: If forceDeleteWithoutRecovery is set to true, recoveryWindowInDays will be ignored.
    rotationInterval String
    The interval for automatic rotation. For more information, see How to use it.
    secretData String
    The data of the secret. NOTE: From version 1.204.1, secretData updating diff will be ignored when secretType is not Generic. The expected format of secretData depends on secretType:

    • Generic: any custom string.
    • Rds: a JSON string in the form {"Accounts":[{"AccountName":"<rds-account-name>","AccountPassword":"<rds-account-password>"}]}.
    • RAMCredentials: a JSON string in the form {"AccessKeys":[{"AccessKeyId":"<access-key-id>","AccessKeySecret":"<access-key-secret>"}]}.
    • ECS: a JSON string. When extended_config.SecretSubType is Password, use {"UserName":"<user-name>","Password":"<password>"}. When SecretSubType is SSHKey, use {"UserName":"<user-name>","PublicKey":"<public-key>","PrivateKey":"<private-key>"}.
    • Redis and PolarDB: use the literal string $Auto.
    secretDataType String
    The type of the secret value. Default value: text. Valid values: text, binary.
    secretName String
    The name of the secret. For more information, see How to use it.
    secretType String
    The type of the secret. Valid values:

    • Generic: Generic secret.
    • Rds: ApsaraDB RDS secret.
    • Redis: (Available since v1.253.0) ApsaraDB for Redis secret.
    • RAMCredentials: RAM secret.
    • ECS: ECS secret.
    • PolarDB: (Available since v1.253.0) PolarDB secret.
    tags Map<String>
    A mapping of tags to assign to the resource.
    versionId String
    The version number of the initial version.
    versionStages List<String>
    The stage label that is used to mark the new version.

    Import

    KMS Secret can be imported using the id, e.g.

    $ pulumi import alicloud:kms/secret:Secret example <id>
    

    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 alicloud logo
    Viewing docs for Alibaba Cloud v4.0.1
    published on Tuesday, Oct 27, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial