-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Mock provider errors on plan while testing write only attribute #36819
Copy link
Copy link
Closed
Labels
bugconfirmeda Terraform Core team member has reproduced this issuea Terraform Core team member has reproduced this issuenewnew issue not yet triagednew issue not yet triaged
Description
Terraform Version
Terraform v1.11.3
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v6.28.0Terraform Configuration Files
in main.tf
resource "google_secret_manager_secret" "this" {
secret_id = var.secret_id
replication {
auto {}
}
}
resource "google_secret_manager_secret_version" "this" {
count = var.secret_data_wo == null ? 0 : 1
secret = google_secret_manager_secret.this.id
secret_data_wo = var.secret_data_wo
}in main.tftest.hcl:
mock_provider "google" {
mock_resource "google_secret_manager_secret" {
defaults = {
project = "test-foo"
}
}
mock_resource "google_secret_manager_secret_version" {
defaults = {
project = "test-foo"
}
}
}
run "simple_example" {
variables {
secret_id = "foobar"
secret_data_wo = sensitive("hunter2")
}
}Debug Output
(let me know if you need this)
Expected Behavior
The test should pass
Actual Behavior
% tf test
main.tftest.hcl... in progress
run "simple_example"... fail
╷
│ Error: Provider produced invalid plan
│
│ Provider "provider[\"registry.terraform.io/hashicorp/google\"]" returned a value for
│ the write-only attribute "google_secret_manager_secret_version.this[0].secret_data_wo"
│ during planning. Write-only attributes cannot be read back from the provider. This is
│ a bug in the provider, which should be reported in the provider's own issue tracker.
╵
main.tftest.hcl... tearing down
main.tftest.hcl... fail
Steps to Reproduce
terraform initterraform test
Additional Context
I know the warning says to file a provider bug for this error, but I verified and pretty sure this is an issue with the mock provider. A plan-only test with the real provider works fine.
References
No response
Generative AI / LLM assisted development?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugconfirmeda Terraform Core team member has reproduced this issuea Terraform Core team member has reproduced this issuenewnew issue not yet triagednew issue not yet triaged