Dynamic Type field

Hello I’m building a provider and I’m currently working on creating the resource for an API that has dynamic json fields, for example there is a field that sometimes expects a string value and in other cases an object depending on values specified on other fields. Based on the documentation for the available types I reviewed https://www.terraform.io/docs/extend/schemas/schema-types.html there doesn’t seem to be something available for this scenario. Is there a workaround/solution in this situation?

Hi @luisescobar89 ,

what you can do is simply manage the field as a string. JSON support is pretty strong in terraform.

That’s what is done in the Pagerduty provider for extension config which have “elastic” schema depending on the type of integration, see https://github.com/PagerDuty/terraform-provider-pagerduty/pull/84/files#diff-fd0b2486c47bb4711b78796ca275bc61c20cb497474c05682974c7f63521fd9bR50-R55 for an example.

1 Like

With the introduction of terraform-plugin-go, DynamicPseudoType is now an option, as well.