# OpenTofu State Encryption with OVHcloud KMS

DevFeed: [OpenTofu State Encryption with OVHcloud KMS](<https://devfeed.tech/articles/opentofu-state-encryption-with-ovhcloud-kms-101184.md>)

Original publisher: [Read original article](<https://blog.ovhcloud.com/en/posts/opentofu-state-encryption-kms/>)

Author: Elena Luoto

Published: 2026-10-26T06:00:00Z

Content type: tutorial

Language: en

Sources: [OVHcloud Blog](<https://devfeed.tech/sources/ovhcloud-blog.md>)

Topics: [opentofu](<https://devfeed.tech/topics/opentofu.md>)

Tags: [access-management](<https://devfeed.tech/tags/access-management.md>), [aes](<https://devfeed.tech/tags/aes.md>), [apply](<https://devfeed.tech/tags/apply.md>), [attacks](<https://devfeed.tech/tags/attacks.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [aws](<https://devfeed.tech/tags/aws.md>), [azure](<https://devfeed.tech/tags/azure.md>), [backend](<https://devfeed.tech/tags/backend.md>), [backup](<https://devfeed.tech/tags/backup.md>), [blog](<https://devfeed.tech/tags/blog.md>), [credentials](<https://devfeed.tech/tags/credentials.md>), [encryption](<https://devfeed.tech/tags/encryption.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [files](<https://devfeed.tech/tags/files.md>), [guide](<https://devfeed.tech/tags/guide.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kms](<https://devfeed.tech/tags/kms.md>), [opentofu](<https://devfeed.tech/tags/opentofu.md>), [ovhcloud](<https://devfeed.tech/tags/ovhcloud.md>), [plan](<https://devfeed.tech/tags/plan.md>), [state](<https://devfeed.tech/tags/state.md>)

## AI overview

OpenTofu can encrypt state and plan files at rest using OVHcloud KMS through OVHcloud's external key provider. The guide requires OpenTofu v1.13+, an OVHcloud account and OKMS domain, an AES service key with Wrap/Unwrap usage, an IAM local user, and the OVHcloud and OpenTofu CLIs. It demonstrates installing the provider, configuring OKMS and key details through environment variables, using a personal access token (with mTLS also supported), and selecting the provider with AES-GCM for both state and plan encryption. Each plan or apply generates a new ephemeral data key protected by the service key. Encryption helps limit unauthorized access to stored state, but does not replace backups, versioning, or state management, prevent data loss or all corruption and replay attacks, or stop tofu users from reading decrypted values. State and plan files are unrecoverable without the right encryption key.

## Source excerpt

Learn how to enable OpenTofu state encryption with OVHcloud KMS and protect your state and plan files at rest. Follow the step-by-step guide.