Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Last active April 4, 2024 13:42
Show Gist options
  • Save dotemacs/af3b35f134e2ba54f915ebb7e1c1e074 to your computer and use it in GitHub Desktop.
Save dotemacs/af3b35f134e2ba54f915ebb7e1c1e074 to your computer and use it in GitHub Desktop.
terraform {
backend "local" {}
encryption {
key_provider "pbkdf2" "my_passphrase" {
passphrase = "something very secret and over 16 chars long"
}
method "aes_gcm" "my_method" {
keys = key_provider.pbkdf2.my_passphrase
}
state {
method = method.aes_gcm.my_method
fallback{} # Remove after the migration is complete.
}
}
}
$ ./tofu apply -auto-approve
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
OpenTofu will perform the following actions:
# local_file.hello_local_file will be created
+ resource "local_file" "hello_local_file" {
+ content = "Hello terraform local!"
+ content_base64sha256 = (known after apply)
+ content_base64sha512 = (known after apply)
+ content_md5 = (known after apply)
+ content_sha1 = (known after apply)
+ content_sha256 = (known after apply)
+ content_sha512 = (known after apply)
+ directory_permission = "0777"
+ file_permission = "0777"
+ filename = "./hello_local_file.txt"
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
local_file.hello_local_file: Creating...
local_file.hello_local_file: Creation complete after 0s [id=87854c876545c68a54349a141d2a023ef503e9b3]
│ Error: Failed to save state
│ Error saving state: encryption of "state" is enforced, and therefore requires a method to be provided
│ Error: Failed to create local state file
│ Error creating local state file for recovery: encryption of "state" is enforced, and therefore requires a method to be provided
│ Error: Failed to serialize state
│ Failed to save state after apply.
│ Error serializing state: encryption of "state" is enforced, and therefore requires a method to be provided
│ A catastrophic error has prevented OpenTofu from persisting the state file or creating a backup. Unfortunately this means that the record of any resources created during this
│ apply has been lost, and such resources may exist outside of OpenTofu's management.
│ For resources that support import, it is possible to recover by manually importing each resource using its id from the target system.
│ This is a serious bug in OpenTofu and should be reported.
│ Error: Failed to persist state to backend
│ The errors shown above prevented OpenTofu from writing the updated state to
│ the configured backend and from creating a local backup file. As a fallback,
│ the raw state data is printed above as a JSON object.
│ To retry writing this state, copy the state data (from the first { to the last } inclusive) and save it into a local file called errored.tfstate, then run the following
│ command:
│ tofu state push errored.tfstate
resource "local_file""hello_local_file" {
content = "Hello terraform local!"
filename = "${path.module}/hello_local_file.txt"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment