published on Sunday, May 10, 2026 by Pulumi
published on Sunday, May 10, 2026 by Pulumi
Provides a Ecs Disk Default Kms Key resource.
The encryption key used by default for cloud storage encryption.
For information about Ecs Disk Default Kms Key and how to use it, see What is Disk Default Kms Key.
NOTE: Available since v1.278.0.
NOTE: Destroying this resource will reset the default CMK to the account’s AliCloud-managed default CMK for Ecs.
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";
const _default = alicloud.kms.getKeys({
filters: "[{\"Key\":\"KeyState\",\"Values\":[\"Enabled\"]}]",
});
const defaultDiskDefaultKmsKey = new alicloud.ecs.DiskDefaultKmsKey("default", {kmsKeyId: _default.then(_default => _default.ids?.[0])});
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_keys(filters="[{\"Key\":\"KeyState\",\"Values\":[\"Enabled\"]}]")
default_disk_default_kms_key = alicloud.ecs.DiskDefaultKmsKey("default", kms_key_id=default.ids[0])
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
"github.com/pulumi/pulumi-alicloud/sdk/v3/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.GetKeys(ctx, &kms.GetKeysArgs{
Filters: pulumi.StringRef("[{\"Key\":\"KeyState\",\"Values\":[\"Enabled\"]}]"),
}, nil)
if err != nil {
return err
}
_, err = ecs.NewDiskDefaultKmsKey(ctx, "default", &ecs.DiskDefaultKmsKeyArgs{
KmsKeyId: pulumi.String(pulumi.String(_default.Ids[0])),
})
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.GetKeys.Invoke(new()
{
Filters = "[{\"Key\":\"KeyState\",\"Values\":[\"Enabled\"]}]",
});
var defaultDiskDefaultKmsKey = new AliCloud.Ecs.DiskDefaultKmsKey("default", new()
{
KmsKeyId = @default.Apply(@default => @default.Apply(getKeysResult => getKeysResult.Ids[0])),
});
});
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.GetKeysArgs;
import com.pulumi.alicloud.ecs.DiskDefaultKmsKey;
import com.pulumi.alicloud.ecs.DiskDefaultKmsKeyArgs;
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.getKeys(GetKeysArgs.builder()
.filters("[{\"Key\":\"KeyState\",\"Values\":[\"Enabled\"]}]")
.build());
var defaultDiskDefaultKmsKey = new DiskDefaultKmsKey("defaultDiskDefaultKmsKey", DiskDefaultKmsKeyArgs.builder()
.kmsKeyId(default_.ids()[0])
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
defaultDiskDefaultKmsKey:
type: alicloud:ecs:DiskDefaultKmsKey
name: default
properties:
kmsKeyId: ${default.ids[0]}
variables:
default:
fn::invoke:
function: alicloud:kms:getKeys
arguments:
filters: '[{"Key":"KeyState","Values":["Enabled"]}]'
Example coming soon!
📚 Need more examples? VIEW MORE EXAMPLES
Create DiskDefaultKmsKey Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DiskDefaultKmsKey(name: string, args: DiskDefaultKmsKeyArgs, opts?: CustomResourceOptions);@overload
def DiskDefaultKmsKey(resource_name: str,
args: DiskDefaultKmsKeyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DiskDefaultKmsKey(resource_name: str,
opts: Optional[ResourceOptions] = None,
kms_key_id: Optional[str] = None)func NewDiskDefaultKmsKey(ctx *Context, name string, args DiskDefaultKmsKeyArgs, opts ...ResourceOption) (*DiskDefaultKmsKey, error)public DiskDefaultKmsKey(string name, DiskDefaultKmsKeyArgs args, CustomResourceOptions? opts = null)
public DiskDefaultKmsKey(String name, DiskDefaultKmsKeyArgs args)
public DiskDefaultKmsKey(String name, DiskDefaultKmsKeyArgs args, CustomResourceOptions options)
type: alicloud:ecs:DiskDefaultKmsKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "alicloud_ecs_diskdefaultkmskey" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args DiskDefaultKmsKeyArgs
- 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 DiskDefaultKmsKeyArgs
- 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 DiskDefaultKmsKeyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DiskDefaultKmsKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DiskDefaultKmsKeyArgs
- 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 diskDefaultKmsKeyResource = new AliCloud.Ecs.DiskDefaultKmsKey("diskDefaultKmsKeyResource", new()
{
KmsKeyId = "string",
});
example, err := ecs.NewDiskDefaultKmsKey(ctx, "diskDefaultKmsKeyResource", &ecs.DiskDefaultKmsKeyArgs{
KmsKeyId: pulumi.String("string"),
})
resource "alicloud_ecs_diskdefaultkmskey" "diskDefaultKmsKeyResource" {
kms_key_id = "string"
}
var diskDefaultKmsKeyResource = new DiskDefaultKmsKey("diskDefaultKmsKeyResource", DiskDefaultKmsKeyArgs.builder()
.kmsKeyId("string")
.build());
disk_default_kms_key_resource = alicloud.ecs.DiskDefaultKmsKey("diskDefaultKmsKeyResource", kms_key_id="string")
const diskDefaultKmsKeyResource = new alicloud.ecs.DiskDefaultKmsKey("diskDefaultKmsKeyResource", {kmsKeyId: "string"});
type: alicloud:ecs:DiskDefaultKmsKey
properties:
kmsKeyId: string
DiskDefaultKmsKey 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 DiskDefaultKmsKey resource accepts the following input properties:
- Kms
Key stringId - The ID of the KMS key.
- Kms
Key stringId - The ID of the KMS key.
- kms_
key_ stringid - The ID of the KMS key.
- kms
Key StringId - The ID of the KMS key.
- kms
Key stringId - The ID of the KMS key.
- kms_
key_ strid - The ID of the KMS key.
- kms
Key StringId - The ID of the KMS key.
Outputs
All input properties are implicitly available as output properties. Additionally, the DiskDefaultKmsKey resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing DiskDefaultKmsKey Resource
Get an existing DiskDefaultKmsKey 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?: DiskDefaultKmsKeyState, opts?: CustomResourceOptions): DiskDefaultKmsKey@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
kms_key_id: Optional[str] = None) -> DiskDefaultKmsKeyfunc GetDiskDefaultKmsKey(ctx *Context, name string, id IDInput, state *DiskDefaultKmsKeyState, opts ...ResourceOption) (*DiskDefaultKmsKey, error)public static DiskDefaultKmsKey Get(string name, Input<string> id, DiskDefaultKmsKeyState? state, CustomResourceOptions? opts = null)public static DiskDefaultKmsKey get(String name, Output<String> id, DiskDefaultKmsKeyState state, CustomResourceOptions options)resources: _: type: alicloud:ecs:DiskDefaultKmsKey get: id: ${id}import {
to = alicloud_ecs_diskdefaultkmskey.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.
- Kms
Key stringId - The ID of the KMS key.
- Kms
Key stringId - The ID of the KMS key.
- kms_
key_ stringid - The ID of the KMS key.
- kms
Key StringId - The ID of the KMS key.
- kms
Key stringId - The ID of the KMS key.
- kms_
key_ strid - The ID of the KMS key.
- kms
Key StringId - The ID of the KMS key.
Import
Ecs Disk Default Kms Key can be imported using the id, e.g.
$ pulumi import alicloud:ecs/diskDefaultKmsKey:DiskDefaultKmsKey example <region_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
alicloudTerraform Provider.
published on Sunday, May 10, 2026 by Pulumi