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

policy = null does not remove existing resource policy #21611

Closed
tekumara opened this issue Nov 3, 2021 · 3 comments · Fixed by #22217
Closed

policy = null does not remove existing resource policy #21611

tekumara opened this issue Nov 3, 2021 · 3 comments · Fixed by #22217
Assignees
Labels
bug Addresses a defect in current functionality. service/secretsmanager Issues and PRs that pertain to the secretsmanager service.
Milestone

Comments

@tekumara
Copy link

tekumara commented Nov 3, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v1.0.10
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v3.63.0

Affected Resource(s)

  • aws_secretsmanager_secret

Terraform Configuration Files

terraform {
  required_providers {
    aws = {}
  }
}

Debug Output

Panic Output

Expected Behavior

When policy = null any existing resource policy should be removed.

Actual Behavior

The existing resource policy remained.

Steps to Reproduce

  1. Apply the following
resource "aws_secretsmanager_secret" "password" {
  name        = "alice"

  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Sid    = "SecretReader"
        Effect = "Allow"
        Principal = {
          AWS = "*"
        }
        Action = [
          "secretsmanager:GetSecretValue"
        ]
        Resource = "*"
      }
    ] }
  )

  // force delete, so we can recreate the secret immediately if needed
  recovery_window_in_days = 0
}

The above will correctly apply the resource policy.

  1. Change to policy = null

  2. Reapply.

The existing policy is not removed.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/secretsmanager Issues and PRs that pertain to the secretsmanager service. labels Nov 3, 2021
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 3, 2021
@YakDriver YakDriver self-assigned this Dec 14, 2021
@YakDriver
Copy link
Member

YakDriver commented Dec 15, 2021

The behavior you are seeing is as designed when an argument is computed. Blanking it out is basically seen as "I don't want to fill this out, read the value from AWS." Because of aws_secretsmanager_secret_policy, this must be computed or anyone using that resource and this one would get perpetual diffs.

However, #22217 allows you to clear the policy by setting it to "{}" (i.e., policy = "{}").

@github-actions github-actions bot added this to the v3.70.0 milestone Dec 16, 2021
@github-actions
Copy link

This functionality has been released in v3.70.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/secretsmanager Issues and PRs that pertain to the secretsmanager service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants