@@ -660,9 +660,35 @@ func resourceLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData,
660
660
var diags diag.Diagnostics
661
661
conn := meta .(* conns.AWSClient ).FSxClient (ctx )
662
662
663
+ updated := false
664
+ // First, update the metadata configuration if it has changed.
665
+ // Sometimes it is necessary to increase IOPS before increasing storage_capacity.
666
+ if d .HasChange ("metadata_configuration" ) {
667
+ input := & fsx.UpdateFileSystemInput {
668
+ ClientRequestToken : aws .String (id .UniqueId ()),
669
+ FileSystemId : aws .String (d .Id ()),
670
+ LustreConfiguration : & awstypes.UpdateFileSystemLustreConfiguration {
671
+ MetadataConfiguration : expandLustreMetadataUpdateConfiguration (d .Get ("metadata_configuration" ).([]any )),
672
+ },
673
+ }
674
+
675
+ startTime := time .Now ()
676
+ _ , err := conn .UpdateFileSystem (ctx , input )
677
+
678
+ if err != nil {
679
+ return sdkdiag .AppendErrorf (diags , "updating FSX for Lustre File System (%s) metadata_configuration: %s" , d .Id (), err )
680
+ }
681
+
682
+ if _ , err := waitFileSystemUpdated (ctx , conn , d .Id (), startTime , d .Timeout (schema .TimeoutUpdate )); err != nil {
683
+ return sdkdiag .AppendErrorf (diags , "waiting for FSx for Lustre File System (%s) metadata_configuration update: %s" , d .Id (), err )
684
+ }
685
+ updated = true
686
+ }
687
+
663
688
if d .HasChangesExcept (
664
689
"final_backup_tags" ,
665
690
"skip_final_backup" ,
691
+ "metadata_configuration" ,
666
692
names .AttrTags ,
667
693
names .AttrTagsAll ,
668
694
) {
@@ -696,10 +722,6 @@ func resourceLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData,
696
722
input .LustreConfiguration .LogConfiguration = expandLustreLogCreateConfiguration (d .Get ("log_configuration" ).([]any ))
697
723
}
698
724
699
- if d .HasChange ("metadata_configuration" ) {
700
- input .LustreConfiguration .MetadataConfiguration = expandLustreMetadataUpdateConfiguration (d .Get ("metadata_configuration" ).([]any ))
701
- }
702
-
703
725
if d .HasChange ("per_unit_storage_throughput" ) {
704
726
input .LustreConfiguration .PerUnitStorageThroughput = aws .Int32 (int32 (d .Get ("per_unit_storage_throughput" ).(int )))
705
727
}
@@ -730,7 +752,10 @@ func resourceLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData,
730
752
if _ , err := waitFileSystemUpdated (ctx , conn , d .Id (), startTime , d .Timeout (schema .TimeoutUpdate )); err != nil {
731
753
return sdkdiag .AppendErrorf (diags , "waiting for FSx for Lustre File System (%s) update: %s" , d .Id (), err )
732
754
}
755
+ updated = true
756
+ }
733
757
758
+ if updated {
734
759
if _ , err := waitFileSystemAdministrativeActionCompleted (ctx , conn , d .Id (), awstypes .AdministrativeActionTypeFileSystemUpdate , d .Timeout (schema .TimeoutUpdate )); err != nil {
735
760
return sdkdiag .AppendErrorf (diags , "waiting for FSx for Lustre File System (%s) administrative action (%s) complete: %s" , d .Id (), awstypes .AdministrativeActionTypeFileSystemUpdate , err )
736
761
}
0 commit comments