Skip to content

asm secret version "secret_string_wo_version" rejects ephemeral values #44590

Description

@rjhornsby

Terraform and AWS Provider Version

╰─± terraform version
Terraform v1.13.3
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v6.14.1
+ provider registry.terraform.io/hashicorp/vault v5.3.0

Affected Resource(s) or Data Source(s)

  • aws_secretsmanager_secret_version

Expected Behavior

The property secret_string_wo_version should accept ephemeral values, ie ephemeral.vault_kv_secret_v2.some_secret.version

Actual Behavior

Attempting to do so results in a TF error telling us that we can't write an ephemeral value to the secret_string_wo_version property. The error message suggests a conflict with the wo portion of the property name.

│ Error: Invalid use of ephemeral value
│
│   with aws_secretsmanager_secret_version.some_secret,
│   on account_default_config.tf line 45, in resource "aws_secretsmanager_secret_version" "some_secret":
│   45:   secret_string_wo_version = ephemeral.vault_kv_secret_v2.some_secret.version
│
│ Ephemeral values are not valid for "secret_string_wo_version", because it is not a write-only attribute and must be persisted to state

I've also tried unsuccessfully to "cheat" and sha256() the vault secret version, but the provider/resource still rejects it for the same reason.

The only other solution I can come up with to comply with the documentation for the property

Used together with secret_string_wo to trigger an update. Increment this value when an update to secret_string_wo is required.

is to hardcode a version value into the TF and change it in the TF code every time the vault secret changes -- but that's an extremely poor solution, if it can even be called that. Open to other suggestions, but it seems like the secret_string_wo_version property behavior is broken.

Relevant Error/Panic Output

│ Error: Invalid use of ephemeral value

│   with aws_secretsmanager_secret_version.some_secret,
│   on account_default_config.tf line 45, in resource "aws_secretsmanager_secret_version" "some_secret":
│   45:   secret_string_wo_version = ephemeral.vault_kv_secret_v2.some_secret.version

│ Ephemeral values are not valid for "secret_string_wo_version", because it is not a write-only attribute and must be persisted to state

Sample Terraform Configuration

Click to expand configuration
ephemeral "vault_kv_secret_v2" "some_secret" {
  mount = "a/secret/vault"
  name  = "key/to/a/great/secret"
}

resource "aws_secretsmanager_secret" "some_secret" {
  name                           = "some_secret"
  description                    = "secret to everlasting life"
  recovery_window_in_days        = 7
  force_overwrite_replica_secret = true
}

resource "aws_secretsmanager_secret_version" "some_secret" {
  secret_id        = aws_secretsmanager_secret.some_secret.id
  secret_string_wo = ephemeral.vault_kv_secret_v2.some_secret.data["cheat_code"]
  secret_string_wo_version = ephemeral.vault_kv_secret_v2.some_secret.version
}

Steps to Reproduce

  1. Plan the configuration
  2. See error message

Debug Logging

Click to expand log output

GenAI / LLM Assisted Development

n/a

Important Facts and References

This may be related to #42383 or #41635.

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/secretsmanagerIssues and PRs that pertain to the secretsmanager service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions