-
Notifications
You must be signed in to change notification settings - Fork 10.3k
'plan -out ...' fails with a brand new state file when dealing with some 'data' resources #32865
Copy link
Copy link
Closed
Description
Terraform Version
Terraform v1.4.1
on linux_amd64
+ provider registry.terraform.io/carlpett/sops v0.7.2
+ provider registry.terraform.io/gitlabhq/gitlab v15.9.0
+ provider registry.terraform.io/hashicorp/azuread v2.20.0
+ provider registry.terraform.io/hashicorp/azurerm v3.47.0
+ provider registry.terraform.io/hashicorp/google v4.9.0
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/random v3.1.3Terraform Configuration Files
# module.key_vaults.data.sops_file.secrets
data "sops_file" "secrets" {
source_file = "secrets.enc.yaml"
}
# module.storage_accounts.data.azurerm_resources.files_storage_account
data "azurerm_resources" "files_storage_account" {
resource_group_name = var.resource_group.name
type = "Microsoft.Storage/storageAccounts"
required_tags = {
type = "general-templates"
}
}Debug Output
Expected Behavior
terraform plan -out ... should have finished as it would normally in any other case.
Actual Behavior
$ terraform plan -var "admin_user_ssh_key_path=~/.ssh/id_rsa_.pub" -out plan.tfstate
data.azuread_group.admins: Reading...
data.azuread_group.admins: Read complete after 1s [id=...]
data.azurerm_subscription.primary: Reading...
data.azurerm_subscription.primary: Read complete after 0s [id=...]
╷
│ Error: Failed to write plan file
│
│ The plan file could not be written: failed to write state snapshot: 2 problems:
│
│ - Failed to serialize resource instance in state: Instance module.key_vaults.data.sops_file.secrets has status ObjectPlanned, which cannot be saved in state.
│ - Failed to serialize resource instance in state: Instance module.storage_accounts.data.azurerm_resources.files_storage_account has status ObjectPlanned, which cannot be saved in
│ state..Steps to Reproduce
Additional Context
This is something that started happening after upgrading to 1.4.0 from 1.3.9 and persists even in 1.4.1. Curiously, the same configuration passes terraform plan -out ... without issues if I'm working on an existing state, but if I am creating a new state file by way of terraform workspace new <name> and run terraform plan -out ..., then it crashes.
I am also using the following data resources, but those do not seem to be affected:
data "azurerm_subscription" "primary" {
}
data "azuread_group" "admins" {
display_name = "Admins"
}I'm using GCS as the back-end for my state files.
References
No response
Reactions are currently unavailable