Skip to content

Utilities for building terraform plugins based on Terraform Plugin Framework

License

Notifications You must be signed in to change notification settings

gilfthde/terraform-plugin-framework-utils

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Plugin Framework Utilities

Modifiers

Assuming that we have a field of a certain type (int, boolean, string etc..), that field can either be nullable or not and also can have various defaults. We need our modifiers to work with all these scenarios.

nullable null default empty default1 known default random default
no X2 DefaultType DefaultType UseStateForUnknown
yes NullableType DefaultType3 DefaultType3 UseStateForUnknown3

We also have more modifiers that helps with ergonomics.

DefaultType

Use the appropriate function for type whose name starts with Default.

modifiers.DefaultBool(true)

modifiers.DefaultString("")

modifiers.DefaultFloat(3)

NullableType

Use the appropriate function for type whose name starts with Nullable.

modifiers.NullableBool()

modifiers.NullableString()

modifiers.NullableFloat()

UseStateForUnknown

Use UseStateForUnknown from Terraform plugin framework.

UseStateForUnknown()

NOTE: Make sure that you omit this property when sending payloads during both creation and updation.

UnknownAttributesOnUnknown

Use this when you have a nested block of SingleNestedAttributes and the block is fully optional.

modifiers.UnknownAttributesOnUnknown()

Footnotes

  1. empty default means that the default value of the field on the server is the empty value for that type in golang. e.g. boolean false, string "", int 0 etc..

  2. This scenairo is impossible.

  3. End users will not be able to set the value of the field as null in the server. This is a limitation on terraform itself. 2 3

About

Utilities for building terraform plugins based on Terraform Plugin Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 76.0%
  • JavaScript 22.4%
  • Other 1.6%