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]: aws_bedrock_guardrail plan shows diff even without any change when used jsondecode for passing the guardrail configuration #40041

Closed
anashakt opened this issue Nov 7, 2024 · 4 comments · Fixed by #40304
Labels
bug Addresses a defect in current functionality. service/bedrock Issues and PRs that pertain to the bedrock service.
Milestone

Comments

@anashakt
Copy link

anashakt commented Nov 7, 2024

Terraform Core Version

v1.9.8

AWS Provider Version

v5.74.0

Affected Resource(s)

  • aws_bedrock_guardrail

Expected Behavior

terraform plan shouldn't show any diff since nothing has been changed

Actual Behavior

terraform plan shows diff.

Relevant Error/Panic Output Snippet

# aws_bedrock_guardrail.platform_guardrail will be updated in-place
  ~ resource "aws_bedrock_guardrail" "platform_guardrail" {
        name                      = "test_guardrail"
        # (9 unchanged attributes hidden)

      ~ content_policy_config {
          ~ filters_config {
              ~ type            = "MISCONDUCT" -> "HATE"
                # (2 unchanged attributes hidden)
            }
          ~ filters_config {
              ~ type            = "HATE" -> "INSULTS"
                # (2 unchanged attributes hidden)
            }
          ~ filters_config {
              ~ type            = "SEXUAL" -> "MISCONDUCT"
                # (2 unchanged attributes hidden)
            }
          ~ filters_config {
              ~ type            = "INSULTS" -> "SEXUAL"
                # (2 unchanged attributes hidden)
            }
            # (2 unchanged blocks hidden)
        }
    }
Plan: 0 to add, 1 to change, 0 to destroy.

Terraform Configuration Files

locals {
  guardrail_config = jsondecode(file("${path.module}/guardrails.json"))

  # Generate a hash from the parsed JSON data to use as a version identifier
  guardrail_hash = sha256(jsonencode(local.guardrail_config))
}

resource "aws_bedrock_guardrail" "platform_guardrail" {
  name                      = local.guardrail_config.name
  description               = local.guardrail_config.description
  blocked_input_messaging   = local.guardrail_config.blockedInputMessaging
  blocked_outputs_messaging = local.guardrail_config.blockedOutputsMessaging

  content_policy_config {
    dynamic "filters_config" {
      for_each = local.guardrail_config.contentPolicyConfig.filtersConfig
      content {
        type            = filters_config.value.type
        input_strength  = filters_config.value.inputStrength
        output_strength = filters_config.value.outputStrength
      }
    }
  }

Steps to Reproduce

Steps to Reproduce

  1. Create a json file with guardrail content. A sample is attached
  2. Create the guardrail using the contents from the json file. Terraform configuration is provided above.
  3. Run tf apply to create the guardrail.
  4. Run tf plan which shouldn't any difference since nothing has been changed.
    guardrails.json

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@anashakt anashakt added the bug Addresses a defect in current functionality. label Nov 7, 2024
Copy link

github-actions bot commented Nov 7, 2024

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 service/bedrock Issues and PRs that pertain to the bedrock service. needs-triage Waiting for first response or review from a maintainer. labels Nov 7, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 8, 2024
@ivan-aws
Copy link

i'm able to reproduce this without the json. i get the same behavior when looping over a list in an object defined in locals

Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.78.0 milestone Nov 26, 2024
Copy link

This functionality has been released in v5.78.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!

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/bedrock Issues and PRs that pertain to the bedrock service.
Projects
None yet
3 participants