@@ -31,6 +31,7 @@ import (
3131 "github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag"
3232 "github.com/hashicorp/terraform-provider-aws/internal/framework"
3333 fwflex "github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
34+ fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
3435 tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
3536 "github.com/hashicorp/terraform-provider-aws/internal/tfresource"
3637 "github.com/hashicorp/terraform-provider-aws/names"
@@ -57,7 +58,15 @@ func (r *logicallyAirGappedVaultResource) Schema(ctx context.Context, request re
5758 response .Schema = schema.Schema {
5859 Attributes : map [string ]schema.Attribute {
5960 names .AttrARN : framework .ARNAttributeComputedOnly (),
60- names .AttrID : framework .IDAttribute (),
61+ "encryption_key_arn" : schema.StringAttribute {
62+ CustomType : fwtypes .ARNType ,
63+ Optional : true ,
64+ Computed : true ,
65+ PlanModifiers : []planmodifier.String {
66+ stringplanmodifier .RequiresReplace (),
67+ },
68+ },
69+ names .AttrID : framework .IDAttribute (),
6170 "max_retention_days" : schema.Int64Attribute {
6271 Required : true ,
6372 PlanModifiers : []planmodifier.Int64 {
@@ -102,9 +111,9 @@ func (r *logicallyAirGappedVaultResource) Create(ctx context.Context, request re
102111
103112 conn := r .Meta ().BackupClient (ctx )
104113
105- name := data .BackupVaultName . ValueString ( )
106- input := & backup.CreateLogicallyAirGappedBackupVaultInput {}
107- response .Diagnostics .Append (fwflex .Expand (ctx , data , input )... )
114+ name := fwflex . StringValueFromFramework ( ctx , data .BackupVaultName )
115+ var input backup.CreateLogicallyAirGappedBackupVaultInput
116+ response .Diagnostics .Append (fwflex .Expand (ctx , data , & input )... )
108117 if response .Diagnostics .HasError () {
109118 return
110119 }
@@ -113,7 +122,7 @@ func (r *logicallyAirGappedVaultResource) Create(ctx context.Context, request re
113122 input .BackupVaultTags = getTagsIn (ctx )
114123 input .CreatorRequestId = aws .String (sdkid .UniqueId ())
115124
116- output , err := conn .CreateLogicallyAirGappedBackupVault (ctx , input )
125+ output , err := conn .CreateLogicallyAirGappedBackupVault (ctx , & input )
117126
118127 if err != nil {
119128 response .Diagnostics .AddError (fmt .Sprintf ("creating Backup Logically Air Gapped Vault (%s)" , name ), err .Error ())
@@ -123,15 +132,21 @@ func (r *logicallyAirGappedVaultResource) Create(ctx context.Context, request re
123132
124133 // Set values for unknowns.
125134 data .BackupVaultARN = fwflex .StringToFramework (ctx , output .BackupVaultArn )
126- data .ID = fwflex .StringToFramework (ctx , output . BackupVaultName )
135+ data .ID = fwflex .StringValueToFramework (ctx , name )
127136
128- if _ , err := waitLogicallyAirGappedVaultCreated (ctx , conn , data .ID .ValueString (), r .CreateTimeout (ctx , data .Timeouts )); err != nil {
137+ vault , err := waitLogicallyAirGappedVaultCreated (ctx , conn , name , r .CreateTimeout (ctx , data .Timeouts ))
138+ if err != nil {
129139 response .State .SetAttribute (ctx , path .Root (names .AttrID ), data .ID ) // Set 'id' so as to taint the resource.
130- response .Diagnostics .AddError (fmt .Sprintf ("waiting for Backup Logically Air Gapped Vault (%s) create" , data . ID . ValueString () ), err .Error ())
140+ response .Diagnostics .AddError (fmt .Sprintf ("waiting for Backup Logically Air Gapped Vault (%s) create" , name ), err .Error ())
131141
132142 return
133143 }
134144
145+ response .Diagnostics .Append (fwflex .Flatten (ctx , vault , & data )... )
146+ if response .Diagnostics .HasError () {
147+ return
148+ }
149+
135150 response .Diagnostics .Append (response .State .Set (ctx , data )... )
136151}
137152
@@ -144,7 +159,8 @@ func (r *logicallyAirGappedVaultResource) Read(ctx context.Context, request reso
144159
145160 conn := r .Meta ().BackupClient (ctx )
146161
147- output , err := findLogicallyAirGappedBackupVaultByName (ctx , conn , data .ID .ValueString ())
162+ name := fwflex .StringValueFromFramework (ctx , data .ID )
163+ output , err := findLogicallyAirGappedBackupVaultByName (ctx , conn , name )
148164
149165 if tfresource .NotFound (err ) {
150166 response .Diagnostics .Append (fwdiag .NewResourceNotFoundWarningDiagnostic (err ))
@@ -154,7 +170,7 @@ func (r *logicallyAirGappedVaultResource) Read(ctx context.Context, request reso
154170 }
155171
156172 if err != nil {
157- response .Diagnostics .AddError (fmt .Sprintf ("reading Backup Logically Air Gapped Vault (%s)" , data . ID . ValueString () ), err .Error ())
173+ response .Diagnostics .AddError (fmt .Sprintf ("reading Backup Logically Air Gapped Vault (%s)" , name ), err .Error ())
158174
159175 return
160176 }
@@ -177,8 +193,9 @@ func (r *logicallyAirGappedVaultResource) Delete(ctx context.Context, request re
177193
178194 conn := r .Meta ().BackupClient (ctx )
179195
196+ name := fwflex .StringValueFromFramework (ctx , data .ID )
180197 input := backup.DeleteBackupVaultInput {
181- BackupVaultName : fwflex . StringFromFramework ( ctx , data . ID ),
198+ BackupVaultName : aws . String ( name ),
182199 }
183200 _ , err := conn .DeleteBackupVault (ctx , & input )
184201
@@ -187,7 +204,7 @@ func (r *logicallyAirGappedVaultResource) Delete(ctx context.Context, request re
187204 }
188205
189206 if err != nil {
190- response .Diagnostics .AddError (fmt .Sprintf ("deleting Backup Logically Air Gapped Vault (%s)" , data . ID . ValueString () ), err .Error ())
207+ response .Diagnostics .AddError (fmt .Sprintf ("deleting Backup Logically Air Gapped Vault (%s)" , name ), err .Error ())
191208
192209 return
193210 }
@@ -197,6 +214,7 @@ type logicallyAirGappedVaultResourceModel struct {
197214 framework.WithRegionModel
198215 BackupVaultARN types.String `tfsdk:"arn"`
199216 BackupVaultName types.String `tfsdk:"name"`
217+ EncryptionKeyARN fwtypes.ARN `tfsdk:"encryption_key_arn"`
200218 ID types.String `tfsdk:"id"`
201219 MaxRetentionDays types.Int64 `tfsdk:"max_retention_days"`
202220 MinRetentionDays types.Int64 `tfsdk:"min_retention_days"`
@@ -245,7 +263,6 @@ func waitLogicallyAirGappedVaultCreated(ctx context.Context, conn *backup.Client
245263 }
246264
247265 outputRaw , err := stateConf .WaitForStateContext (ctx )
248-
249266 if output , ok := outputRaw .(* backup.DescribeBackupVaultOutput ); ok {
250267 return output , err
251268 }
0 commit comments