@@ -24,6 +24,8 @@ import (
24
24
intflex "github.com/hashicorp/terraform-provider-aws/internal/flex"
25
25
"github.com/hashicorp/terraform-provider-aws/internal/framework"
26
26
fwflex "github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
27
+ tfstringplanmodifier "github.com/hashicorp/terraform-provider-aws/internal/framework/planmodifiers/stringplanmodifier"
28
+ "github.com/hashicorp/terraform-provider-aws/internal/framework/privatestate"
27
29
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
28
30
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
29
31
"github.com/hashicorp/terraform-provider-aws/names"
@@ -41,6 +43,10 @@ type hostKeyResource struct {
41
43
framework.ResourceWithModel [hostKeyResourceModel ]
42
44
}
43
45
46
+ const (
47
+ hostKeyBodyWOKey = "host_key_body_wo"
48
+ )
49
+
44
50
func (r * hostKeyResource ) Schema (ctx context.Context , request resource.SchemaRequest , response * resource.SchemaResponse ) {
45
51
response .Schema = schema.Schema {
46
52
Attributes : map [string ]schema.Attribute {
@@ -74,7 +80,7 @@ func (r *hostKeyResource) Schema(ctx context.Context, request resource.SchemaReq
74
80
stringvalidator .LengthBetween (0 , 4096 ),
75
81
},
76
82
PlanModifiers : []planmodifier.String {
77
- stringplanmodifier . RequiresReplace ( ),
83
+ tfstringplanmodifier . RequiresReplaceWO ( hostKeyBodyWOKey ),
78
84
},
79
85
},
80
86
"host_key_fingerprint" : schema.StringAttribute {
@@ -131,6 +137,15 @@ func (r *hostKeyResource) Create(ctx context.Context, request resource.CreateReq
131
137
return
132
138
}
133
139
140
+ // Store hash of write-only value.
141
+ if ! config .HostKeyBodyWO .IsNull () {
142
+ woStore := privatestate .NewWriteOnlyValueStore (response .Private , hostKeyBodyWOKey )
143
+ response .Diagnostics .Append (woStore .SetValue (ctx , config .HostKeyBodyWO )... )
144
+ if response .Diagnostics .HasError () {
145
+ return
146
+ }
147
+ }
148
+
134
149
hostKeyID := aws .ToString (out .HostKeyId )
135
150
hostKey , err := findHostKeyByTwoPartKey (ctx , conn , serverID , hostKeyID )
136
151
if err != nil {
0 commit comments