published on Saturday, Aug 15, 2026 by Pulumi
published on Saturday, Aug 15, 2026 by Pulumi
Rotates a key in the Vault Key Management secrets engine. This resource creates a new version of an existing key, which is useful for implementing key rotation policies and maintaining security best practices.
Key rotation creates a new cryptographic key version while keeping the old versions available for decryption of data encrypted with previous versions.
Important All data provided in the resource configuration will be written in cleartext to state and plan files generated by Terraform, and will appear in the console output when Terraform runs. Protect these artifacts accordingly. See the main provider documentation for more details.
For more information on key rotation in Vault, please refer to the Vault documentation.
Note this feature is available only with Vault Enterprise.
Example Usage
Basic Key Rotation
import * as pulumi from "@pulumi/pulumi";
import * as vault from "@pulumi/vault";
const keymgmt = new vault.Mount("keymgmt", {
path: "keymgmt",
type: "keymgmt",
});
const encryptionKey = new vault.keymgmt.Key("encryption_key", {
mount: keymgmt.path,
name: "rotation-example",
type: "aes256-gcm96",
});
const rotate = new vault.keymgmt.KeyRotate("rotate", {
mount: keymgmt.path,
name: encryptionKey.name,
});
import pulumi
import pulumi_vault as vault
keymgmt = vault.Mount("keymgmt",
path="keymgmt",
type="keymgmt")
encryption_key = vault.keymgmt.Key("encryption_key",
mount=keymgmt.path,
name="rotation-example",
type="aes256-gcm96")
rotate = vault.keymgmt.KeyRotate("rotate",
mount=keymgmt.path,
name=encryption_key.name)
package main
import (
"github.com/pulumi/pulumi-vault/sdk/v7/go/vault"
"github.com/pulumi/pulumi-vault/sdk/v7/go/vault/keymgmt"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
keymgmt2, err := vault.NewMount(ctx, "keymgmt", &vault.MountArgs{
Path: pulumi.String("keymgmt"),
Type: pulumi.String("keymgmt"),
})
if err != nil {
return err
}
encryptionKey, err := keymgmt.NewKey(ctx, "encryption_key", &keymgmt.KeyArgs{
Mount: keymgmt2.Path,
Name: pulumi.String("rotation-example"),
Type: pulumi.String("aes256-gcm96"),
})
if err != nil {
return err
}
_, err = keymgmt.NewKeyRotate(ctx, "rotate", &keymgmt.KeyRotateArgs{
Mount: keymgmt2.Path,
Name: encryptionKey.Name,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vault = Pulumi.Vault;
return await Deployment.RunAsync(() =>
{
var keymgmt = new Vault.Mount("keymgmt", new()
{
Path = "keymgmt",
Type = "keymgmt",
});
var encryptionKey = new Vault.KeyMgmt.Key("encryption_key", new()
{
Mount = keymgmt.Path,
Name = "rotation-example",
Type = "aes256-gcm96",
});
var rotate = new Vault.KeyMgmt.KeyRotate("rotate", new()
{
Mount = keymgmt.Path,
Name = encryptionKey.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vault.Mount;
import com.pulumi.vault.MountArgs;
import com.pulumi.vault.keymgmt.Key;
import com.pulumi.vault.keymgmt.KeyArgs;
import com.pulumi.vault.keymgmt.KeyRotate;
import com.pulumi.vault.keymgmt.KeyRotateArgs;
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) {
var keymgmt = new Mount("keymgmt", MountArgs.builder()
.path("keymgmt")
.type("keymgmt")
.build());
var encryptionKey = new Key("encryptionKey", KeyArgs.builder()
.mount(keymgmt.path())
.name("rotation-example")
.type("aes256-gcm96")
.build());
var rotate = new KeyRotate("rotate", KeyRotateArgs.builder()
.mount(keymgmt.path())
.name(encryptionKey.name())
.build());
}
}
resources:
keymgmt:
type: vault:Mount
properties:
path: keymgmt
type: keymgmt
encryptionKey:
type: vault:keymgmt:Key
name: encryption_key
properties:
mount: ${keymgmt.path}
name: rotation-example
type: aes256-gcm96
rotate:
type: vault:keymgmt:KeyRotate
properties:
mount: ${keymgmt.path}
name: ${encryptionKey.name}
pulumi {
required_providers {
vault = {
source = "pulumi/vault"
}
}
}
resource "vault_mount" "keymgmt" {
path = "keymgmt"
type = "keymgmt"
}
resource "vault_keymgmt_key" "encryption_key" {
mount = vault_mount.keymgmt.path
name = "rotation-example"
type = "aes256-gcm96"
}
resource "vault_keymgmt_keyrotate" "rotate" {
mount = vault_mount.keymgmt.path
name = vault_keymgmt_key.encryption_key.name
}
Create KeyRotate Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new KeyRotate(name: string, args: KeyRotateArgs, opts?: CustomResourceOptions);@overload
def KeyRotate(resource_name: str,
args: KeyRotateArgs,
opts: Optional[ResourceOptions] = None)
@overload
def KeyRotate(resource_name: str,
opts: Optional[ResourceOptions] = None,
mount: Optional[str] = None,
name: Optional[str] = None,
namespace: Optional[str] = None)func NewKeyRotate(ctx *Context, name string, args KeyRotateArgs, opts ...ResourceOption) (*KeyRotate, error)public KeyRotate(string name, KeyRotateArgs args, CustomResourceOptions? opts = null)
public KeyRotate(String name, KeyRotateArgs args)
public KeyRotate(String name, KeyRotateArgs args, CustomResourceOptions options)
type: vault:keymgmt:KeyRotate
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "vault_keymgmt_key_rotate" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args KeyRotateArgs
- 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 KeyRotateArgs
- 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 KeyRotateArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args KeyRotateArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args KeyRotateArgs
- 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 keyRotateResource = new Vault.KeyMgmt.KeyRotate("keyRotateResource", new()
{
Mount = "string",
Name = "string",
Namespace = "string",
});
example, err := keymgmt.NewKeyRotate(ctx, "keyRotateResource", &keymgmt.KeyRotateArgs{
Mount: pulumi.String("string"),
Name: pulumi.String("string"),
Namespace: pulumi.String("string"),
})
resource "vault_keymgmt_key_rotate" "keyRotateResource" {
lifecycle {
create_before_destroy = true
}
mount = "string"
name = "string"
namespace = "string"
}
var keyRotateResource = new KeyRotate("keyRotateResource", KeyRotateArgs.builder()
.mount("string")
.name("string")
.namespace("string")
.build());
key_rotate_resource = vault.keymgmt.KeyRotate("keyRotateResource",
mount="string",
name="string",
namespace="string")
const keyRotateResource = new vault.keymgmt.KeyRotate("keyRotateResource", {
mount: "string",
name: "string",
namespace: "string",
});
type: vault:keymgmt:KeyRotate
properties:
mount: string
name: string
namespace: string
KeyRotate 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 KeyRotate resource accepts the following input properties:
- Mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - Name string
- Specifies the name of the key to rotate.
- Namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- Mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - Name string
- Specifies the name of the key to rotate.
- Namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name string
- Specifies the name of the key to rotate.
- namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- mount String
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name String
- Specifies the name of the key to rotate.
- namespace String
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name string
- Specifies the name of the key to rotate.
- namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- mount str
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name str
- Specifies the name of the key to rotate.
- namespace str
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- mount String
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name String
- Specifies the name of the key to rotate.
- namespace String
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
Outputs
All input properties are implicitly available as output properties. Additionally, the KeyRotate resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Latest
Version int - Specifies the latest version of the key.
- Id string
- The provider-assigned unique ID for this managed resource.
- Latest
Version int - Specifies the latest version of the key.
- id string
- The provider-assigned unique ID for this managed resource.
- latest_
version number - Specifies the latest version of the key.
- id String
- The provider-assigned unique ID for this managed resource.
- latest
Version Integer - Specifies the latest version of the key.
- id string
- The provider-assigned unique ID for this managed resource.
- latest
Version number - Specifies the latest version of the key.
- id str
- The provider-assigned unique ID for this managed resource.
- latest_
version int - Specifies the latest version of the key.
- id String
- The provider-assigned unique ID for this managed resource.
- latest
Version Number - Specifies the latest version of the key.
Look up Existing KeyRotate Resource
Get an existing KeyRotate 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?: KeyRotateState, opts?: CustomResourceOptions): KeyRotate@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
latest_version: Optional[int] = None,
mount: Optional[str] = None,
name: Optional[str] = None,
namespace: Optional[str] = None) -> KeyRotatefunc GetKeyRotate(ctx *Context, name string, id IDInput, state *KeyRotateState, opts ...ResourceOption) (*KeyRotate, error)public static KeyRotate Get(string name, Input<string> id, KeyRotateState? state, CustomResourceOptions? opts = null)public static KeyRotate get(String name, Output<String> id, KeyRotateState state, CustomResourceOptions options)resources: _: type: vault:keymgmt:KeyRotate get: id: ${id}import {
to = vault_keymgmt_key_rotate.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.
- Latest
Version int - Specifies the latest version of the key.
- Mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - Name string
- Specifies the name of the key to rotate.
- Namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- Latest
Version int - Specifies the latest version of the key.
- Mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - Name string
- Specifies the name of the key to rotate.
- Namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- latest_
version number - Specifies the latest version of the key.
- mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name string
- Specifies the name of the key to rotate.
- namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- latest
Version Integer - Specifies the latest version of the key.
- mount String
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name String
- Specifies the name of the key to rotate.
- namespace String
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- latest
Version number - Specifies the latest version of the key.
- mount string
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name string
- Specifies the name of the key to rotate.
- namespace string
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- latest_
version int - Specifies the latest version of the key.
- mount str
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name str
- Specifies the name of the key to rotate.
- namespace str
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
- latest
Version Number - Specifies the latest version of the key.
- mount String
- Path of the Key Management secrets engine mount. Must match the
pathof avault.Mountresource withtype = "keymgmt". Usevault_mount.keymgmt.pathhere. - name String
- Specifies the name of the key to rotate.
- namespace String
- The namespace of the target resource.
The value should not contain leading or trailing forward slashes.
The
namespaceis always relative to the provider's configured namespace. Available only for Vault Enterprise.
Import
Key rotation resources can be imported using the format {path}/key/{name}/rotate, e.g.
$ pulumi import vault:keymgmt/keyRotate:KeyRotate rotate keymgmt/key/rotation-example/rotate
Note: This resource rotates the key once when created. Subsequent
pulumi upoperations will not trigger additional rotations unless the resource is destroyed and recreated.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Vault pulumi/pulumi-vault
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
vaultTerraform Provider.
published on Saturday, Aug 15, 2026 by Pulumi