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]: Unable to update MSK cluster policy after creation #33107

Closed
vishwa-trulioo opened this issue Aug 19, 2023 · 5 comments · Fixed by #33118
Closed

[Bug]: Unable to update MSK cluster policy after creation #33107

vishwa-trulioo opened this issue Aug 19, 2023 · 5 comments · Fixed by #33118
Labels
bug Addresses a defect in current functionality. service/kafka Issues and PRs that pertain to the kafka service.
Milestone

Comments

@vishwa-trulioo
Copy link

Terraform Core Version

1.5.0

AWS Provider Version

5.13.1

Affected Resource(s)

aws_msk_cluster_policy

Expected Behavior

After you create a MSK cluster policy using aws_msk_cluster_policy as per the example. The exact same policy. Then if you make a small update to the policy, e.g. adding another account to the principals list. Expected the cluster policy update to go through without issues.

Actual Behavior

After you create a MSK cluster policy using aws_msk_cluster_policy as per the example. The exact same policy. Then if you make a small update to the policy, e.g. adding another account to the principals list. Terraform fails with the following error.

module.msk.aws_msk_cluster_policy.default[0]: Modifying... [id=arn:aws:kafka:us-west-2:123456789357:cluster/mymsk/fflskjfgs-8vkd-s03d-4vjs-fggg5526db37-8]

Error: setting MSK Cluster Policy (arn:aws:kafka:us-west-2:123456789357:cluster/mymsk/fflskjfgs-8vkd-s03d-4vjs-fggg5526db37-8): operation error Kafka: PutClusterPolicy, https response error StatusCode: 400, RequestID: a7c8c74c-3a98-4d15-b7d5-6e0bde5feb7b, BadRequestException: Current cluster policy version needed for Update

  with module.msk.aws_msk_cluster_policy.default[0],
  on ../main.tf line 248, in resource "aws_msk_cluster_policy" "default":
 248: resource "aws_msk_cluster_policy" "default" {

Relevant Error/Panic Output Snippet

Basically, The newly created resource `aws_msk_cluster_policy` is not pulling the current policy version prior to being updated.

Terraform Configuration Files

resource "aws_msk_cluster_policy" "example" {
  cluster_arn = var.msk_cluster_arn

  policy = jsonencode({
    Version = "2012-10-17",
    Statement = [{
      Sid    = "ExampleMskClusterPolicy"
      Effect = "Allow"
      Principal = {
        "AWS" = "arn"aws:iam::[account_id]:root"
      }
      Action = [
        "kafka:Describe*",
        "kafka:Get*",
        "kafka:CreateVpcConnection",
        "kafka:GetBootstrapBrokers",
      ]
      Resource = var.msk_cluster_arn
    }]
  })
}

Steps to Reproduce

Create an MSK cluster with Cluster policy enabled. And then try updating the policy.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

@ewbankkit I found a small bug in the newly implemented aws_msk_cluster_policy resource.
This is related to this github issue.
#32848

Would you like to implement a fix?

None

@vishwa-trulioo vishwa-trulioo added the bug Addresses a defect in current functionality. label Aug 19, 2023
@github-actions
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/kafka Issues and PRs that pertain to the kafka service. label Aug 19, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 19, 2023
@vishwa-trulioo
Copy link
Author

Here is the Debug log if it helps.

tf_trace.log

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Aug 21, 2023
@ewbankkit
Copy link
Contributor

@vishwa-trulioo Thanks for raising this issue 👏.
I see that we did not have an acceptance test for updating a cluster policy 😞 -- I'll add one and fix the bug.

@github-actions
Copy link

This functionality has been released in v5.14.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 Sep 24, 2023
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/kafka Issues and PRs that pertain to the kafka service.
Projects
None yet
2 participants