@@ -78,6 +78,7 @@ type ServiceResourceModel struct {
7878 Topology types.String `tfsdk:"topology"`
7979 Storage types.Int64 `tfsdk:"storage"`
8080 VolumeIOPS types.Int64 `tfsdk:"volume_iops"`
81+ VolumeThroughput types.Int64 `tfsdk:"volume_throughput"`
8182 SSLEnabled types.Bool `tfsdk:"ssl_enabled"`
8283 NoSQLEnabled types.Bool `tfsdk:"nosql_enabled"`
8384 VolumeType types.String `tfsdk:"volume_type"`
@@ -221,6 +222,13 @@ var serviceResourceSchemaV0 = schema.Schema{
221222 int64planmodifier .UseStateForUnknown (),
222223 },
223224 },
225+ "volume_throughput" : schema.Int64Attribute {
226+ Optional : true ,
227+ Description : "The volume Throughput. This is only applicable for AWS" ,
228+ PlanModifiers : []planmodifier.Int64 {
229+ int64planmodifier .UseStateForUnknown (),
230+ },
231+ },
224232 "ssl_enabled" : schema.BoolAttribute {
225233 Optional : true ,
226234 Computed : true ,
@@ -241,7 +249,7 @@ var serviceResourceSchemaV0 = schema.Schema{
241249 "volume_type" : schema.StringAttribute {
242250 Optional : true ,
243251 Computed : true ,
244- Description : "The volume type. Valid values are: gp2 and io1. This is only applicable for AWS" ,
252+ Description : "The volume type. Valid values are: gp3 and io1. This is only applicable for AWS" ,
245253 PlanModifiers : []planmodifier.String {
246254 stringplanmodifier .UseStateForUnknown (),
247255 stringplanmodifier .RequiresReplaceIf (
@@ -452,6 +460,7 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
452460 Topology : state .Topology .ValueString (),
453461 Storage : uint (state .Storage .ValueInt64 ()),
454462 VolumeIOPS : uint (state .VolumeIOPS .ValueInt64 ()),
463+ VolumeThroughput : uint (state .VolumeThroughput .ValueInt64 ()),
455464 SSLEnabled : state .SSLEnabled .ValueBool (),
456465 NoSQLEnabled : state .NoSQLEnabled .ValueBool (),
457466 VolumeType : state .VolumeType .ValueString (),
@@ -523,6 +532,11 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
523532 } else {
524533 state .VolumeIOPS = types .Int64Null ()
525534 }
535+ if service .StorageVolume .Throughput > 0 {
536+ state .VolumeThroughput = types .Int64Value (int64 (service .StorageVolume .Throughput ))
537+ } else {
538+ state .VolumeThroughput = types .Int64Null ()
539+ }
526540 if service .StorageVolume .VolumeType != "" {
527541 state .VolumeType = types .StringValue (service .StorageVolume .VolumeType )
528542 } else {
@@ -679,6 +693,11 @@ func (r *ServiceResource) readServiceState(ctx context.Context, data *ServiceRes
679693 } else {
680694 data .VolumeIOPS = types .Int64Null ()
681695 }
696+ if ! data .VolumeThroughput .IsNull () && service .StorageVolume .Throughput > 0 {
697+ data .VolumeThroughput = types .Int64Value (int64 (service .StorageVolume .Throughput ))
698+ } else {
699+ data .VolumeThroughput = types .Int64Null ()
700+ }
682701 data .VolumeType = types .StringValue (service .StorageVolume .VolumeType )
683702 if ! data .ReplicationEnabled .IsNull () {
684703 data .ReplicationEnabled = types .BoolValue (service .ReplicationEnabled )
@@ -805,16 +824,18 @@ func (r *ServiceResource) updateAllowListState(plan *ServiceResourceModel, state
805824}
806825
807826func (r * ServiceResource ) updateServiceStorage (ctx context.Context , plan * ServiceResourceModel , state * ServiceResourceModel , resp * resource.UpdateResponse ) {
808- if plan .Storage .ValueInt64 () != state .Storage .ValueInt64 () || plan .VolumeIOPS .ValueInt64 () != state .VolumeIOPS .ValueInt64 () {
827+ if plan .Storage .ValueInt64 () != state .Storage .ValueInt64 () || plan .VolumeIOPS .ValueInt64 () != state .VolumeIOPS .ValueInt64 () || plan . VolumeThroughput . ValueInt64 () != state . VolumeThroughput . ValueInt64 () {
809828 tflog .Info (ctx , "Updating storage size for the service" , map [string ]interface {}{
810- "id" : state .ID .ValueString (),
811- "from" : state .Storage .ValueInt64 (),
812- "to" : plan .Storage .ValueInt64 (),
813- "iops_from" : state .VolumeIOPS .ValueInt64 (),
814- "iops_to" : plan .VolumeIOPS .ValueInt64 (),
829+ "id" : state .ID .ValueString (),
830+ "from" : state .Storage .ValueInt64 (),
831+ "to" : plan .Storage .ValueInt64 (),
832+ "iops_from" : state .VolumeIOPS .ValueInt64 (),
833+ "iops_to" : plan .VolumeIOPS .ValueInt64 (),
834+ "throughput_from" : state .VolumeThroughput .ValueInt64 (),
835+ "throughput_to" : plan .VolumeThroughput .ValueInt64 (),
815836 })
816837
817- err := r .client .ModifyServiceStorage (ctx , state .ID .ValueString (), plan .Storage .ValueInt64 (), plan .VolumeIOPS .ValueInt64 ())
838+ err := r .client .ModifyServiceStorage (ctx , state .ID .ValueString (), plan .Storage .ValueInt64 (), plan .VolumeIOPS .ValueInt64 (), plan . VolumeThroughput . ValueInt64 () )
818839 if err != nil {
819840 resp .Diagnostics .AddError ("Error updating a storage for the service" ,
820841 fmt .Sprintf ("Unable to update a storage size for the service, got error: %s" , err ))
@@ -1148,19 +1169,42 @@ func (r *ServiceResource) ModifyPlan(ctx context.Context, req resource.ModifyPla
11481169 }
11491170
11501171 if plan .Provider .ValueString () == "aws" {
1151- if ! plan .VolumeIOPS .IsNull () && plan .VolumeType .IsNull () {
1172+
1173+ if plan .VolumeType .IsNull () {
11521174 resp .Diagnostics .AddAttributeError (path .Root ("volume_type" ),
1153- "volume_type is require" ,
1154- "volume_type is required when volume_iops is set. " +
1155- "Use: io1 for volume_type if volume_iops is set" )
1175+ "volume_type is required" ,
1176+ "volume_type is required for AWS. Use: io1 or gp3 for volume_type." )
11561177 return
11571178 }
1158- if ! plan .VolumeIOPS .IsNull () && plan .VolumeType .ValueString () != "io1" {
1179+
1180+ if plan .VolumeType .ValueString () != "io1" && plan .VolumeType .ValueString () != "gp3" {
11591181 resp .Diagnostics .AddAttributeError (path .Root ("volume_type" ),
1160- "volume_type must be io1 when you want to set IOPS " ,
1161- "Use: io1 for volume_type if volume_iops is set " )
1182+ "volume_type is not supported " ,
1183+ "volume_type provided is not supported. Use: io1 or gp3 for volume_type. " )
11621184 return
11631185 }
1186+
1187+ if plan .VolumeIOPS .IsNull () {
1188+ resp .Diagnostics .AddAttributeError (path .Root ("volume_iops" ),
1189+ "volume_iops are required" ,
1190+ "volume_iops are required for AWS" )
1191+ return
1192+ }
1193+
1194+ if plan .VolumeType .ValueString () == "io1" && ! plan .VolumeThroughput .IsNull () {
1195+ resp .Diagnostics .AddAttributeError (path .Root ("volume_throughput" ),
1196+ "volume_throughput is not supported for io1" ,
1197+ "volume_throughput is supported only for gp3 volume_type for AWS" )
1198+ return
1199+ }
1200+
1201+ if plan .VolumeType .ValueString () == "gp3" && plan .VolumeThroughput .IsNull () {
1202+ resp .Diagnostics .AddAttributeError (path .Root ("volume_throughput" ),
1203+ "volume_throughput is required" ,
1204+ "volume_throughput is required for gp3 volume_type for AWS" )
1205+ return
1206+ }
1207+
11641208 } else if plan .Provider .ValueString () == "gcp" {
11651209 if ! (plan .VolumeType .ValueString () == "" || plan .VolumeType .IsNull () || plan .VolumeType .ValueString () == "pd-ssd" ) {
11661210 resp .Diagnostics .AddAttributeError (
0 commit comments