The terraform must be able to destroy a cluster in "FAILED" state.
Actual Behavior
The plan/apply/destroy returns an error and does not proceed with the rest of the code, which makes the terraform unusable until you delete the MSK instance manually in the AWS console.
Relevant Error/Panic Output Snippet
Error: reading MSK Cluster (arn:aws:kafka:<region>:<accountId>:cluster/msk-kafka-cluster/<GUID>) bootstrap brokers:
operation error Kafka: GetBootstrapBrokers, https response error StatusCode: 400,
BadRequestException: You can't get bootstrap broker nodes for a cluster in FAILED state.
│
│ with aws_msk_cluster.this[0],
│ on main.tf line 5, in resource "aws_msk_cluster" "this":
│ 5: resource "aws_msk_cluster" "this" {
│
1 - Force the MSK cluster to fail on the first run. For example, run the terraform with a s3 bucket that does not exist. If you do this, the state of the cluster will be FAILED with the following error:
Error: waiting for MSK Cluster create: unexpected state 'FAILED', wanted target 'ACTIVE'. last error: InvalidInput.ResourceNotFound: The resource issue-github doesn't exist. Specify an existing destination for broker logs, and then try the operation again.
2 - Correct the name of the s3 bucket with an existing bucket and run terraform apply again and the error will appear. The same happens if you try to run terraform destroy.
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.
Terraform Core Version
1.8.3
AWS Provider Version
5.41.0,5.49.0
Affected Resource(s)
aws_msk_cluster
Expected Behavior
The terraform must be able to destroy a cluster in "FAILED" state.
Actual Behavior
The plan/apply/destroy returns an error and does not proceed with the rest of the code, which makes the terraform unusable until you delete the MSK instance manually in the AWS console.
Relevant Error/Panic Output Snippet
Terraform Configuration Files
Steps to Reproduce
1 - Force the MSK cluster to fail on the first run. For example, run the terraform with a s3 bucket that does not exist. If you do this, the state of the cluster will be FAILED with the following error:
Error: waiting for MSK Cluster create: unexpected state 'FAILED', wanted target 'ACTIVE'. last error: InvalidInput.ResourceNotFound: The resource issue-github doesn't exist. Specify an existing destination for broker logs, and then try the operation again.
2 - Correct the name of the s3 bucket with an existing bucket and run
terraform apply
again and the error will appear. The same happens if you try to runterraform destroy
.Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
No