Can we change the attributes type from boolean to List in terraform?

We had developed one terraform provider a year ago kept one field type boolean. We have created many resources with that and state of those resource are stored in the statefile. But, now API has changed the parameter type from boolean to List. So, to align with the api changes we want to change the type from bool to List in terraform-provider but after doing the change if we run terraform apply it gives the below error.
Error: Missing expected [

We are suspecting that this is because in current state file, the value of that particular field is bool but we want to change it to List. Can that be the cause? If so is there any way to handle this scenario?

Hey there @maulik.ramani :wave: , welcome to the Hashi discuss board!

So you’re right on track and what you’re describing is a state migration, which depending on the Plugin SDK you’re using will differ in implementation, but both have documentation and examples available:

An additional consideration is the types that you’re switching to, from Bool to List will be a change that could potentially affect practitioners configuration of the value (if this value is Required or Optional), and will definitely affect a practitioner using this value as an output (as they may be using it to configure other resources that previously were expecting a Bool). Depending on the provider and how much control you have over the configuration, you may consider deprecating this boolean attribute and introducing a new list attribute for a smoother transition.

Both Plugin SDKs have documentation and examples on how to deprecate attributes, which differ depending on if it’s Required, Computed, or Optional:

Hopefully these guides give you additional context to help move forward!