Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Importing aws_secretsmanager_secret_version causes recreation due to secret_id changing from arn to path #37937

Open
nitrocode opened this issue Jun 12, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. service/secretsmanager Issues and PRs that pertain to the secretsmanager service.

Comments

@nitrocode
Copy link
Contributor

nitrocode commented Jun 12, 2024

Terraform Core Version

1.8.1

AWS Provider Version

5.53.0

Affected Resource(s)

  • aws_secretsmanager_secret_version

Expected Behavior

Import without recreation on a subsequent plan/apply

Actual Behavior

Import

terraform import \
  'aws_secretsmanager_secret_version.default["test"]' \
  'arn:aws:secretsmanager:us-east-1:snip:secret:devops/test/oidc-H0eZ70|terraform-20240612163038549200000002'

Plan

  # aws_secretsmanager_secret_version.default["test"] must be replaced
-/+ resource "aws_secretsmanager_secret_version" "default" {
      ~ arn            = "arn:aws:secretsmanager:us-east-1:snip:secret:devops/test/oidc-H0eZ70" -> (known after apply)
      ~ id             = "arn:aws:secretsmanager:us-east-1:snip:secret:devops/test/oidc-H0eZ70|terraform-20240612163038549200000002" -> (known after apply)
      ~ secret_id      = "arn:aws:secretsmanager:us-east-1:snip:secret:devops/test/oidc-H0eZ70" -> "devops/test/oidc" # forces replacement
      ~ version_id     = "terraform-20240612163038549200000002" -> (known after apply)
      ~ version_stages = [
          - "AWSCURRENT",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

The secret_id wants to change from the full arn arn:aws:secretsmanager:us-east-1:snip:secret:devops/test/oidc-H0eZ70 to only the path devops/test/oidc.

I also tried modifying the secret_id by pulling the state, modifying, and pushing it back up. Same result.

I also tried deleting from the state and reimporting using only the path instead of the full arn and the import did not work.

Relevant Error/Panic Output Snippet

N/A

Terraform Configuration Files

resource "aws_secretsmanager_secret" "default" {
  for_each = okta_app_oauth.default

  name = "devops/${each.key}/oidc"

  force_overwrite_replica_secret = false
}

resource "aws_secretsmanager_secret_version" "default" {
  for_each = okta_app_oauth.default

  secret_id = aws_secretsmanager_secret.default[each.key].id
  secret_string = jsonencode({
    clientID     = each.value.client_id
    clientSecret = each.value.client_secret
  })
}

Steps to Reproduce

See above

Debug Output

N/A

Panic Output

N/A

Important Factoids

N/A

References

Would you like to implement a fix?

None

@nitrocode nitrocode added the bug Addresses a defect in current functionality. label Jun 12, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/secretsmanager Issues and PRs that pertain to the secretsmanager service. label Jun 12, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 12, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/secretsmanager Issues and PRs that pertain to the secretsmanager service.
Projects
None yet
Development

No branches or pull requests

2 participants