From 3ef857a41a6ad2a4b61199b184b4e0fbb6d3fd8c Mon Sep 17 00:00:00 2001 From: JHBaik Date: Wed, 30 Oct 2024 23:12:04 +0900 Subject: [PATCH 1/3] Fix elasticache node mapping --- .../service/elasticache/reserved_cache_node.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/elasticache/reserved_cache_node.go b/internal/service/elasticache/reserved_cache_node.go index 9716af3eb14..a98e067801b 100644 --- a/internal/service/elasticache/reserved_cache_node.go +++ b/internal/service/elasticache/reserved_cache_node.go @@ -68,11 +68,11 @@ func (r *resourceReservedCacheNode) Schema(ctx context.Context, request resource }, }, "cache_node_type": schema.StringAttribute{ - CustomType: fwtypes.RFC3339DurationType, - Computed: true, + Computed: true, }, names.AttrDuration: schema.StringAttribute{ - Computed: true, + CustomType: fwtypes.RFC3339DurationType, + Computed: true, }, "fixed_price": schema.Float64Attribute{ Computed: true, @@ -183,7 +183,7 @@ func (r *resourceReservedCacheNode) Read(ctx context.Context, request resource.R conn := r.Meta().ElastiCacheClient(ctx) - reservation, err := findReservedCacheNodeByID(ctx, conn, data.ID.ValueString()) + reservation, err := findReservedCacheNodeByID(ctx, conn, data.ReservedCacheNodeId.ValueString()) if tfresource.NotFound(err) { response.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) @@ -192,7 +192,7 @@ func (r *resourceReservedCacheNode) Read(ctx context.Context, request resource.R } if err != nil { - response.Diagnostics.AddError(fmt.Sprintf("reading ElastiCache Reserved Cache Node (%s)", data.ID.ValueString()), err.Error()) + response.Diagnostics.AddError(fmt.Sprintf("reading ElastiCache Reserved Cache Node (%s)", data.ReservedCacheNodeId.ValueString()), err.Error()) return } @@ -222,12 +222,12 @@ func (r *resourceReservedCacheNode) flexOpts() []flex.AutoFlexOptionsFunc { } type resourceReservedCacheNodeModel struct { - ARN types.String `tfsdk:"arn"` + ReservationARN types.String `tfsdk:"arn"` CacheNodeCount types.Int32 `tfsdk:"cache_node_count"` CacheNodeType types.String `tfsdk:"cache_node_type"` Duration fwtypes.RFC3339Duration `tfsdk:"duration" autoflex:",noflatten"` FixedPrice types.Float64 `tfsdk:"fixed_price"` - ID types.String `tfsdk:"id"` + ReservedCacheNodeId types.String `tfsdk:"id"` ReservedCacheNodesOfferingID types.String `tfsdk:"reserved_cache_nodes_offering_id"` OfferingType types.String `tfsdk:"offering_type"` ProductDescription types.String `tfsdk:"product_description"` From e8794ccd41174486b6298b93a8920e68613dec4d Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Thu, 31 Oct 2024 14:16:18 -0400 Subject: [PATCH 2/3] r/aws_elasticache_reserved_cache_node: revert `ID` struct field name change This inconsistency with the AWS data structure is already accounted for by the AutoFlex `flex.WithFieldNamePrefix` option passed to the `flex.Flatten` function. The change to `ReservationARN was left in place. --- internal/service/elasticache/reserved_cache_node.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/elasticache/reserved_cache_node.go b/internal/service/elasticache/reserved_cache_node.go index a98e067801b..4aa7fceca63 100644 --- a/internal/service/elasticache/reserved_cache_node.go +++ b/internal/service/elasticache/reserved_cache_node.go @@ -183,7 +183,7 @@ func (r *resourceReservedCacheNode) Read(ctx context.Context, request resource.R conn := r.Meta().ElastiCacheClient(ctx) - reservation, err := findReservedCacheNodeByID(ctx, conn, data.ReservedCacheNodeId.ValueString()) + reservation, err := findReservedCacheNodeByID(ctx, conn, data.ID.ValueString()) if tfresource.NotFound(err) { response.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) @@ -192,7 +192,7 @@ func (r *resourceReservedCacheNode) Read(ctx context.Context, request resource.R } if err != nil { - response.Diagnostics.AddError(fmt.Sprintf("reading ElastiCache Reserved Cache Node (%s)", data.ReservedCacheNodeId.ValueString()), err.Error()) + response.Diagnostics.AddError(fmt.Sprintf("reading ElastiCache Reserved Cache Node (%s)", data.ID.ValueString()), err.Error()) return } @@ -227,7 +227,7 @@ type resourceReservedCacheNodeModel struct { CacheNodeType types.String `tfsdk:"cache_node_type"` Duration fwtypes.RFC3339Duration `tfsdk:"duration" autoflex:",noflatten"` FixedPrice types.Float64 `tfsdk:"fixed_price"` - ReservedCacheNodeId types.String `tfsdk:"id"` + ID types.String `tfsdk:"id"` ReservedCacheNodesOfferingID types.String `tfsdk:"reserved_cache_nodes_offering_id"` OfferingType types.String `tfsdk:"offering_type"` ProductDescription types.String `tfsdk:"product_description"` From fb796e3087beccf5556e87cbd30d58fb6bbc30fc Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Thu, 31 Oct 2024 14:16:26 -0400 Subject: [PATCH 3/3] chore: changelog --- .changelog/39945.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/39945.txt diff --git a/.changelog/39945.txt b/.changelog/39945.txt new file mode 100644 index 00000000000..df8074cd641 --- /dev/null +++ b/.changelog/39945.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_elasticache_reserved_cache_node: Fix `Value Conversion Error` during resource creation +```