Skip to content

aws_secretsmanager_secret_version performs lookup when using write-only arguments #42383

Open
@gr-georgeshort

Description

@gr-georgeshort

Terraform and AWS Provider Version

1.11.4

Affected Resource(s) or Data Source(s)

aws_secretsmanager_secret_version

Expected Behavior

It may be my misunderstanding of the expected behaviour so apologies in advance if so but when using write-only arguments I believe that the resource shouldn't attempt to read the secret value when performing a plan.

Actual Behavior

The provider attempts to perform secretsmanager:GetSecretValue on the resource during plan.

Relevant Error/Panic Output

Error: reading Secrets Manager Secret Version (arn:aws:secretsmanager:eu-west-1:123456789999:secret:example-password|*): operation error Secrets Manager: GetSecretValue, https response error StatusCode: 400, RequestID: e0821cc1-dd6f-4a28-b138-a5e38749743c, api error AccessDeniedException: User: arn:aws:sts::123456789999:assumed-role/my-read-only-role is not authorized to perform: secretsmanager:GetSecretValue on resource: arn:aws:secretsmanager:eu-west-1:123456789999:secret:example-password because no identity-based policy allows the secretsmanager:GetSecretValue action

Sample Terraform Configuration

Click to expand configuration
ephemeral "random_password" "example_password" {
  length           = 16
  override_special = "!#$%&*()-_=+[]{}<>:?"
}

resource "aws_secretsmanager_secret" "example_password" {
  name = "example-password"
}

resource "aws_secretsmanager_secret_version" "example_password" {
  secret_id                = aws_secretsmanager_secret.example_password.id
  secret_string_wo         = ephemeral.random_password.example_password.result
  secret_string_wo_version = 1
}

Steps to Reproduce

  1. Run plan and apply to create initial secret version
  2. Run plan again for provider to attempt to perform secretsmanager:GetSecretValue action

Debug Logging

Click to expand log output

GenAI / LLM Assisted Development

n/a

Important Facts and References

We are using dynamic provider credentials within Terraform Enterprise and are splitting plan / apply roles into read-only and read-write respectively. This functionality as a result is causing a problem for us as the read-only role used for plans does not have secretsmanager:GetSecretValue permission available.

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.needs-triageWaiting for first response or review from a maintainer.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