# Automatic TDE Encryption Key Rotation Using HashiCorp Vault as the Key Management System

**URL:** <https://forums.percona.com/t/automatic-tde-encryption-key-rotation-using-hashicorp-vault-as-the-key-management-system/15825>\
**Category:** Percona XtraDB Cluster\
**Created:** [May 25, 2022, 7:56pm UTC](https://forums.percona.com/t/automatic-tde-encryption-key-rotation-using-hashicorp-vault-as-the-key-management-system/15825 "2022-05-25T19:56:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LukeYangJMA](https://avatars.discourse-cdn.com/v4/letter/l/0ea827/32.png) [@LukeYangJMA](https://forums.percona.com/u/LukeYangJMA)\
**Post date:** [May 25, 2022, 7:56pm UTC](https://forums.percona.com/t/automatic-tde-encryption-key-rotation-using-hashicorp-vault-as-the-key-management-system/15825/1 "2022-05-25T19:56:19Z")

</div>

How can one do **automatic** key rotation in Percona for TDE using HashiCorp Vault as the Key Management System? We are intending to use a primary-secondary pair of Percona servers and a community edition HA cluster of HashiCorp Vault.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 25, 2022, 8:31pm UTC](https://forums.percona.com/t/automatic-tde-encryption-key-rotation-using-hashicorp-vault-as-the-key-management-system/15825/2 "2022-05-25T20:31:16Z")

</div>

As far as I can tell, there is no such feature. You’d have to schedule a cron-job to run rotate the master key in MySQL, which will tell Vault to store the updated key.

[https://www.percona.com/doc/percona-server/LATEST/security/rotating-master-key.html#rotating-master-key](https://www.percona.com/doc/percona-server/LATEST/security/rotating-master-key.html#rotating-master-key)

---

<div class="post-metadata">

**Author:** ![LukeYangJMA](https://avatars.discourse-cdn.com/v4/letter/l/0ea827/32.png) [@LukeYangJMA](https://forums.percona.com/u/LukeYangJMA)\
**Post date:** [June 1, 2022, 11:51am UTC](https://forums.percona.com/t/automatic-tde-encryption-key-rotation-using-hashicorp-vault-as-the-key-management-system/15825/3 "2022-06-01T11:51:00Z")

</div>

Thanks for your response,

I ended up using the event\_scheduler built into the Percona MySQL server which seems to work:

```auto
mysql> SHOW PROCESSLIST;
mysql> SET GLOBAL event_scheduler = ON;
mysql> CREATE EVENT key_rotation ON SCHEDULE EVERY 3600 SECOND DO ALTER INSTANCE ROTATE INNODB MASTER KEY;

```

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [June 1, 2022, 2:40pm UTC](https://forums.percona.com/t/automatic-tde-encryption-key-rotation-using-hashicorp-vault-as-the-key-management-system/15825/4 "2022-06-01T14:40:10Z")

</div>

Awesome solution! I’m not a fan of the event scheduler but that’s a great way to do it!
