Skip to content

Commit edf58a1

Browse files
committed
d/aws_bedrock_foundation_models: Use 'DataSourceComputedListOfObjectAttribute'.
1 parent 18e8fa1 commit edf58a1

File tree

2 files changed

+23
-39
lines changed

2 files changed

+23
-39
lines changed

internal/service/bedrock/foundation_model_data_source.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func (d *foundationModelDataSource) Schema(ctx context.Context, request datasour
5050
Computed: true,
5151
},
5252
"model_arn": schema.StringAttribute{
53-
Computed: true,
53+
CustomType: fwtypes.ARNType,
54+
Computed: true,
5455
},
5556
"model_id": schema.StringAttribute{
5657
Required: true,
@@ -105,14 +106,14 @@ func (d *foundationModelDataSource) Read(ctx context.Context, request datasource
105106
}
106107

107108
type foundationModelDataSourceModel struct {
108-
CustomizationsSupported fwtypes.SetValueOf[types.String] `tfsdk:"customizations_supported"`
109-
ID types.String `tfsdk:"id"`
110-
InferenceTypesSupported fwtypes.SetValueOf[types.String] `tfsdk:"inference_types_supported"`
111-
InputModalities fwtypes.SetValueOf[types.String] `tfsdk:"input_modalities"`
112-
ModelARN types.String `tfsdk:"model_arn"`
113-
ModelID types.String `tfsdk:"model_id"`
114-
ModelName types.String `tfsdk:"model_name"`
115-
OutputModalities fwtypes.SetValueOf[types.String] `tfsdk:"output_modalities"`
116-
ProviderName types.String `tfsdk:"provider_name"`
117-
ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"`
109+
CustomizationsSupported fwtypes.SetOfString `tfsdk:"customizations_supported"`
110+
ID types.String `tfsdk:"id"`
111+
InferenceTypesSupported fwtypes.SetOfString `tfsdk:"inference_types_supported"`
112+
InputModalities fwtypes.SetOfString `tfsdk:"input_modalities"`
113+
ModelARN fwtypes.ARN `tfsdk:"model_arn"`
114+
ModelID types.String `tfsdk:"model_id"`
115+
ModelName types.String `tfsdk:"model_name"`
116+
OutputModalities fwtypes.SetOfString `tfsdk:"output_modalities"`
117+
ProviderName types.String `tfsdk:"provider_name"`
118+
ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"`
118119
}

internal/service/bedrock/foundation_models_data_source.go

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/aws/aws-sdk-go-v2/service/bedrock"
1111
awstypes "github.com/aws/aws-sdk-go-v2/service/bedrock/types"
1212
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
13-
"github.com/hashicorp/terraform-plugin-framework/attr"
1413
"github.com/hashicorp/terraform-plugin-framework/datasource"
1514
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1615
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
@@ -55,24 +54,8 @@ func (d *foundationModelsDataSource) Schema(ctx context.Context, request datasou
5554
stringvalidator.RegexMatches(regexache.MustCompile(`^[A-Za-z0-9- ]{1,63}$`), ""),
5655
},
5756
},
58-
names.AttrID: framework.IDAttribute(),
59-
"model_summaries": schema.ListAttribute{
60-
CustomType: fwtypes.NewListNestedObjectTypeOf[foundationModelSummaryModel](ctx),
61-
Computed: true,
62-
ElementType: types.ObjectType{
63-
AttrTypes: map[string]attr.Type{
64-
"customizations_supported": types.SetType{ElemType: types.StringType},
65-
"inference_types_supported": types.SetType{ElemType: types.StringType},
66-
"input_modalities": types.SetType{ElemType: types.StringType},
67-
"model_arn": types.StringType,
68-
"model_id": types.StringType,
69-
"model_name": types.StringType,
70-
"output_modalities": types.SetType{ElemType: types.StringType},
71-
names.AttrProviderName: types.StringType,
72-
"response_streaming_supported": types.BoolType,
73-
},
74-
},
75-
},
57+
names.AttrID: framework.IDAttribute(),
58+
"model_summaries": framework.DataSourceComputedListOfObjectAttribute[foundationModelSummaryModel](ctx),
7659
},
7760
}
7861
}
@@ -120,13 +103,13 @@ type foundationModelsDataSourceModel struct {
120103
}
121104

122105
type foundationModelSummaryModel struct {
123-
CustomizationsSupported fwtypes.SetValueOf[types.String] `tfsdk:"customizations_supported"`
124-
InferenceTypesSupported fwtypes.SetValueOf[types.String] `tfsdk:"inference_types_supported"`
125-
InputModalities fwtypes.SetValueOf[types.String] `tfsdk:"input_modalities"`
126-
ModelARN types.String `tfsdk:"model_arn"`
127-
ModelID types.String `tfsdk:"model_id"`
128-
ModelName types.String `tfsdk:"model_name"`
129-
OutputModalities fwtypes.SetValueOf[types.String] `tfsdk:"output_modalities"`
130-
ProviderName types.String `tfsdk:"provider_name"`
131-
ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"`
106+
CustomizationsSupported fwtypes.SetOfString `tfsdk:"customizations_supported"`
107+
InferenceTypesSupported fwtypes.SetOfString `tfsdk:"inference_types_supported"`
108+
InputModalities fwtypes.SetOfString `tfsdk:"input_modalities"`
109+
ModelARN fwtypes.ARN `tfsdk:"model_arn"`
110+
ModelID types.String `tfsdk:"model_id"`
111+
ModelName types.String `tfsdk:"model_name"`
112+
OutputModalities fwtypes.SetOfString `tfsdk:"output_modalities"`
113+
ProviderName types.String `tfsdk:"provider_name"`
114+
ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"`
132115
}

0 commit comments

Comments
 (0)