terraform-provider-aws
terraform-provider-aws copied to clipboard
aws_msk_cluster provisioned_throughput block has multiple issues
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.1.4 on linux_amd64
- provider registry.terraform.io/hashicorp/aws v4.23.0
Affected Resource(s)
- aws_msk_cluster
Terraform Configuration Files
resource "aws_msk_cluster" "cluster" {
...
storage_info {
ebs_storage_info {
volume_size = var.ebs_volume_size
dynamic "provisioned_throughput" {
for_each = var.ebs_volume_throughput == "0" ? [] : ["enabled"]
content {
enabled = true
volume_throughput = var.ebs_volume_throughput
}
}
dynamic "provisioned_throughput" {
for_each = var.ebs_volume_throughput != "0" ? [] : ["disabled"]
content {
enabled = false
}
}
}
}
}
}
Actual Behavior
The existing behavior seems to only support two configurations.
- Not having throughput enabled in AWS and not having the provisioned_throughput block in code
- enabling/enabled throughput with provisioned_throughput block
Attempts to disable provisioned throughput require that the block no longer contain the volume_throughput field; thus the weird double dynamic blocks in example above.
Once disabled terraform plan constantly detects a chance in the plan as the p_t block doesnt appear to exist as part of the state. How simple removal of the block is not sufficient to disable p_t in the case that is already enabled on the cluster.
Steps to Reproduce
- Create MSK with provisioning enabled
- attempt to disable provisioning by simply setting enabled to false and leaving volume_throughput field as is. This fails as volume_throughput cannot be set when setting enabled to false. This is detected at apply time, not at plan time.
- Attempt to disable provisioning by removing the block entirely. Plan and apply "succeed" however no changes are actually made to the cluster. It is simply removed from state and subsequent plans continue to show a change is needed.
- Disable provisioning by setting enabled = false and no volume_throughput. This succeeds though subsequent terraform plans will show that the p_t block still needs to be added and set to enabled=false.