1. Packages
  2. AWS
  3. API Docs
  4. ebs
  5. DefaultKmsKey
AWS v6.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

aws.ebs.DefaultKmsKey

Explore with Pulumi AI

Provides a resource to manage the default customer master key (CMK) that your AWS account uses to encrypt EBS volumes.

Your AWS account has an AWS-managed default CMK that is used for encrypting an EBS volume when no CMK is specified in the API call that creates the volume. By using the aws.ebs.DefaultKmsKey resource, you can specify a customer-managed CMK to use in place of the AWS-managed default CMK.

NOTE: Creating an aws.ebs.DefaultKmsKey resource does not enable default EBS encryption. Use the aws.ebs.EncryptionByDefault to enable default EBS encryption.

NOTE: Destroying this resource will reset the default CMK to the account’s AWS-managed default CMK for EBS.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.ebs.DefaultKmsKey("example", {keyArn: exampleAwsKmsKey.arn});
Copy
import pulumi
import pulumi_aws as aws

example = aws.ebs.DefaultKmsKey("example", key_arn=example_aws_kms_key["arn"])
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ebs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ebs.NewDefaultKmsKey(ctx, "example", &ebs.DefaultKmsKeyArgs{
			KeyArn: pulumi.Any(exampleAwsKmsKey.Arn),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.Ebs.DefaultKmsKey("example", new()
    {
        KeyArn = exampleAwsKmsKey.Arn,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ebs.DefaultKmsKey;
import com.pulumi.aws.ebs.DefaultKmsKeyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new DefaultKmsKey("example", DefaultKmsKeyArgs.builder()
            .keyArn(exampleAwsKmsKey.arn())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:ebs:DefaultKmsKey
    properties:
      keyArn: ${exampleAwsKmsKey.arn}
Copy

Create DefaultKmsKey Resource

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

Constructor syntax

new DefaultKmsKey(name: string, args: DefaultKmsKeyArgs, opts?: CustomResourceOptions);
@overload
def DefaultKmsKey(resource_name: str,
                  args: DefaultKmsKeyArgs,
                  opts: Optional[ResourceOptions] = None)

@overload
def DefaultKmsKey(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  key_arn: Optional[str] = None)
func NewDefaultKmsKey(ctx *Context, name string, args DefaultKmsKeyArgs, opts ...ResourceOption) (*DefaultKmsKey, error)
public DefaultKmsKey(string name, DefaultKmsKeyArgs args, CustomResourceOptions? opts = null)
public DefaultKmsKey(String name, DefaultKmsKeyArgs args)
public DefaultKmsKey(String name, DefaultKmsKeyArgs args, CustomResourceOptions options)
type: aws:ebs:DefaultKmsKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DefaultKmsKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DefaultKmsKeyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DefaultKmsKeyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DefaultKmsKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DefaultKmsKeyArgs
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 defaultKmsKeyResource = new Aws.Ebs.DefaultKmsKey("defaultKmsKeyResource", new()
{
    KeyArn = "string",
});
Copy
example, err := ebs.NewDefaultKmsKey(ctx, "defaultKmsKeyResource", &ebs.DefaultKmsKeyArgs{
	KeyArn: pulumi.String("string"),
})
Copy
var defaultKmsKeyResource = new DefaultKmsKey("defaultKmsKeyResource", DefaultKmsKeyArgs.builder()
    .keyArn("string")
    .build());
Copy
default_kms_key_resource = aws.ebs.DefaultKmsKey("defaultKmsKeyResource", key_arn="string")
Copy
const defaultKmsKeyResource = new aws.ebs.DefaultKmsKey("defaultKmsKeyResource", {keyArn: "string"});
Copy
type: aws:ebs:DefaultKmsKey
properties:
    keyArn: string
Copy

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

KeyArn
This property is required.
Changes to this property will trigger replacement.
string
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
KeyArn
This property is required.
Changes to this property will trigger replacement.
string
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
keyArn
This property is required.
Changes to this property will trigger replacement.
String
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
keyArn
This property is required.
Changes to this property will trigger replacement.
string
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
key_arn
This property is required.
Changes to this property will trigger replacement.
str
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
keyArn
This property is required.
Changes to this property will trigger replacement.
String
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing DefaultKmsKey Resource

Get an existing DefaultKmsKey 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?: DefaultKmsKeyState, opts?: CustomResourceOptions): DefaultKmsKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        key_arn: Optional[str] = None) -> DefaultKmsKey
func GetDefaultKmsKey(ctx *Context, name string, id IDInput, state *DefaultKmsKeyState, opts ...ResourceOption) (*DefaultKmsKey, error)
public static DefaultKmsKey Get(string name, Input<string> id, DefaultKmsKeyState? state, CustomResourceOptions? opts = null)
public static DefaultKmsKey get(String name, Output<String> id, DefaultKmsKeyState state, CustomResourceOptions options)
resources:  _:    type: aws:ebs:DefaultKmsKey    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
KeyArn Changes to this property will trigger replacement. string
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
KeyArn Changes to this property will trigger replacement. string
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
keyArn Changes to this property will trigger replacement. String
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
keyArn Changes to this property will trigger replacement. string
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
key_arn Changes to this property will trigger replacement. str
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.
keyArn Changes to this property will trigger replacement. String
The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume.

Import

Using pulumi import, import the EBS default KMS CMK using the KMS key ARN. For example:

$ pulumi import aws:ebs/defaultKmsKey:DefaultKmsKey example arn:aws:kms:us-east-1:123456789012:key/abcd-1234
Copy

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

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.