Hey everyone, I am currently working on migrating a AWS MediaTailor provider to the new framework and I am getting an error when trying to set a value. I have an schema that looks (somewhat) like this:
type sourceLocationModel struct {
AccessConfiguration *resourceSourceLocationAccessConfigurationModel `tfsdk:"access_configuration"`
}
type resourceSourceLocationAccessConfigurationModel struct {
AccessType types.String `tfsdk:"access_type"`
}
Error: Incorrect attribute value type
│
│ on source_location.tf line 3, in resource "awsmt_source_location" "example_source_location":
│ 3: access_configuration = {
│ 4: access_type = "S3_SIGV4"
│ 5: }
│
│ Inappropriate value for attribute "access_configuration": element "access_type": object required.
Would anyone know why this error is occurring? or how to fix it? All other nested elements can be defined normally, except for this one.
I’m not that familiar with the framework, but I think I see what’s going on here…
You have defined a MapNestedAttribute. However, from the configuration you’ve written, it looks like you should have used a SingleNestedAttribute instead.
As long as you’re using a MapNestedAttribute, you’re telling Terraform to expect configuration like:
│ An unexpected error was encountered trying to convert tftypes.Value into awsmt.resourceSourceLocationAccessConfigurationModel. This is always an error in the provider. Please report the
│ following to the provider developer:
│
│ cannot reflect tftypes.Map[tftypes.Object["access_type":tftypes.String, "smatc":tftypes.Map[tftypes.Object["header_name":tftypes.String, "secret_arn":tftypes.String,
│ "secret_string_key":tftypes.String]]]] into a struct, must be an object
Terraform is informing you that the definition you have written of the schema, does not match the structure of the Go type you have defined to have easier access to the values.