RFC 3339 timestamp string type and value implementations for terraform-plugin-framework. These types automatically include syntax validation and support Go standard library time.Time
conversion.
Experimental: This project is not officially maintained by HashiCorp.
This Go module tracks recent versions of terraform-plugin-framework
for Go version and interface compatibility.
Replace usage of types.StringType
in schema definitions with timetypes.RFC3339Type{}
.
Given the previous schema attribute:
tfsdk.Attribute{
Required: true,
Type: types.StringType,
// Potentially previous Validators
}
The updated schema attribute:
tfsdk.Attribute{
Required: true,
Type: timetypes.RFC3339Type{},
}
Replace usage of string
, *string
, or types.String
in schema data models with timetypes.RFC3339
.
Given the previous schema data model:
type ThingResourceModel struct {
// ...
Example types.String `tfsdk:"example"`
}
The updated schema data model:
type ThingResourceModel struct {
// ...
Example timetypes.RFC3339 `tfsdk:"example"`
}
Similar to other value types, use the IsNull()
and IsUnknown()
methods to check whether the value is null or unknown. Use the Time()
method to extract a known time.Time
value.
Create a timetypes.RFC3339
by calling one of these functions:
RFC3339Null() RFC3339
: creates a null
value.RFC3339String(string, path.Path) (Value, diag.Diagnostics)
: creates a known value using the given string
or returns validation errors if string
is not in the expected RFC 3339 format.RFC3339Time(time.Time) Value
creates a known value using the given time.Time
.RFC3339Unknown() Value
: creates an unknown value.All functionality is located in the github.com/bflad/terraform-plugin-framework-type-time/timetypes
package. Add this to relevant Go file import
statements.
Run these Go module commands to fetch the latest version and ensure all module files are up to date.
go get github.com/bflad/terraform-plugin-framework-type-time@latest
go mod tidy