Skip to content

Commit ebf4210

Browse files
committed
added documentation and fixed linter
1 parent 89ad114 commit ebf4210

7 files changed

+296
-73
lines changed

examples/odb/autonomous_vm_cluster.tf

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Copyright (c) HashiCorp, Inc.
2-
# SPDX-License-Identifier: MPL-2.0
1+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
32

43
# Autonomous VM Cluster with default maintenance window and minimum parameters
54
resource "aws_odb_cloud_autonomous_vm_cluster" "avmc_with_minimum_parameters" {
@@ -15,13 +14,8 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "avmc_with_minimum_parameters" {
1514
db_servers = ["<my_db_server_id>"]
1615
scan_listener_port_tls = 8561
1716
scan_listener_port_non_tls = 1024
18-
maintenance_window = {
19-
preference = "NO_PREFERENCE"
20-
days_of_week = []
21-
hours_of_day = []
22-
months = []
23-
weeks_of_month = []
24-
lead_time_in_weeks = 0
17+
maintenance_window {
18+
preference = "NO_PREFERENCE"
2519
}
2620

2721
}
@@ -41,13 +35,13 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
4135
db_servers = ["<my_db_server_1>", "<my_db_server_2>"]
4236
scan_listener_port_tls = 8561
4337
scan_listener_port_non_tls = 1024
44-
maintenance_window = {
45-
preference = "CUSTOM_PREFERENCE"
46-
days_of_week = ["MONDAY", "TUESDAY"]
38+
maintenance_window {
39+
days_of_week = [{ name = "MONDAY" }, { name = "TUESDAY" }]
4740
hours_of_day = [4, 16]
48-
months = ["FEBRUARY", "MAY", "AUGUST", "NOVEMBER"]
49-
weeks_of_month = [2, 4]
5041
lead_time_in_weeks = 3
42+
months = [{ name = "FEBRUARY" }, { name = "MAY" }, { name = "AUGUST" }, { name = "NOVEMBER" }]
43+
preference = "CUSTOM_PREFERENCE"
44+
weeks_of_month = [2, 4]
5145
}
5246
tags = {
5347
"env" = "dev"

internal/service/odb/cloud_autonomous_vm_cluster.go

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -339,55 +339,52 @@ func (r *resourceCloudAutonomousVmCluster) Schema(ctx context.Context, req resou
339339

340340
NestedObject: schema.NestedBlockObject{
341341
Attributes: map[string]schema.Attribute{
342-
"custom_action_timeout_in_mins": schema.Int32Attribute{
343-
Optional: true,
344-
Computed: true,
345-
Description: "The custom action timeout in minutes for the maintenance window.",
346-
},
347342
"days_of_week": schema.SetAttribute{
348343
ElementType: fwtypes.NewObjectTypeOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel](ctx),
349344
Optional: true,
350-
Computed: true,
351345
Description: "The days of the week when maintenance can be performed.",
346+
PlanModifiers: []planmodifier.Set{
347+
setplanmodifier.RequiresReplace(),
348+
},
352349
},
353350
"hours_of_day": schema.SetAttribute{
354-
ElementType: types.Int32Type,
351+
ElementType: types.Int64Type,
355352
Optional: true,
356-
Computed: true,
357353
Description: "The hours of the day when maintenance can be performed.",
358-
},
359-
"is_custom_action_timeout_enabled": schema.BoolAttribute{
360-
Optional: true,
361-
Computed: true,
362-
Description: "Indicates whether custom action timeout is enabled for the maintenance window.",
354+
PlanModifiers: []planmodifier.Set{
355+
setplanmodifier.RequiresReplace(),
356+
},
363357
},
364358
"lead_time_in_weeks": schema.Int32Attribute{
365359
Optional: true,
366-
Computed: true,
367360
Description: "The lead time in weeks before the maintenance window.",
361+
PlanModifiers: []planmodifier.Int32{
362+
int32planmodifier.RequiresReplace(),
363+
},
368364
},
369365
"months": schema.SetAttribute{
370366
ElementType: fwtypes.NewObjectTypeOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel](ctx),
371367
Optional: true,
372-
Computed: true,
373368
Description: "The months when maintenance can be performed.",
374-
},
375-
"patching_mode": schema.StringAttribute{
376-
Optional: true,
377-
Computed: true,
378-
CustomType: fwtypes.StringEnumType[odbtypes.PatchingModeType](),
379-
Description: "The patching mode for the maintenance window.",
369+
PlanModifiers: []planmodifier.Set{
370+
setplanmodifier.RequiresReplace(),
371+
},
380372
},
381373
"preference": schema.StringAttribute{
382374
Required: true,
383375
CustomType: fwtypes.StringEnumType[odbtypes.PreferenceType](),
384376
Description: "The preference for the maintenance window scheduling.",
377+
PlanModifiers: []planmodifier.String{
378+
stringplanmodifier.RequiresReplace(),
379+
},
385380
},
386381
"weeks_of_month": schema.SetAttribute{
387-
ElementType: types.Int32Type,
382+
ElementType: types.Int64Type,
388383
Optional: true,
389-
Computed: true,
390384
Description: "Indicates whether to skip release updates during maintenance.",
385+
PlanModifiers: []planmodifier.Set{
386+
setplanmodifier.RequiresReplace(),
387+
},
391388
},
392389
},
393390
},
@@ -676,15 +673,12 @@ type cloudAutonomousVmClusterResourceModel struct {
676673
}
677674

678675
type cloudAutonomousVmClusterMaintenanceWindowResourceModel struct {
679-
CustomActionTimeoutInMins types.Int32 `tfsdk:"custom_action_timeout_in_mins"`
680-
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"days_of_week"`
681-
HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"`
682-
IsCustomActionTimeoutEnabled types.Bool `tfsdk:"is_custom_action_timeout_enabled"`
683-
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
684-
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"months"`
685-
PatchingMode fwtypes.StringEnum[odbtypes.PatchingModeType] `tfsdk:"patching_mode"`
686-
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
687-
WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"`
676+
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"days_of_week"`
677+
HoursOfDay fwtypes.SetValueOf[types.Int64] `tfsdk:"hours_of_day"`
678+
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
679+
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"months"`
680+
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
681+
WeeksOfMonth fwtypes.SetValueOf[types.Int64] `tfsdk:"weeks_of_month"`
688682
}
689683

690684
type dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel struct {

internal/service/odb/cloud_autonomous_vm_cluster_data_source.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func (d *dataSourceCloudAutonomousVmCluster) Schema(ctx context.Context, req dat
235235
Description: "The time zone of the Autonomous VM cluster.",
236236
},
237237
"total_container_databases": schema.Int32Attribute{
238-
Computed: true,
238+
Computed: true,
239+
Description: "The total number of Autonomous Container Databases that can be created with the allocated local storage.",
239240
},
240241
names.AttrTags: tftags.TagsAttributeComputedOnly(),
241242
"maintenance_window": schema.ListAttribute{
@@ -249,7 +250,6 @@ func (d *dataSourceCloudAutonomousVmCluster) Schema(ctx context.Context, req dat
249250

250251
func (d *dataSourceCloudAutonomousVmCluster) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
251252
conn := d.Meta().ODBClient(ctx)
252-
253253
var data cloudAutonomousVmClusterDataSourceModel
254254
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
255255
if resp.Diagnostics.HasError() {
@@ -329,15 +329,12 @@ type cloudAutonomousVmClusterDataSourceModel struct {
329329
Tags tftags.Map `tfsdk:"tags"`
330330
}
331331
type cloudAutonomousVmClusterMaintenanceWindowDataSourceModel struct {
332-
CustomActionTimeoutInMins types.Int32 `tfsdk:"custom_action_timeout_in_mins"`
333-
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"days_of_week"`
334-
HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"`
335-
IsCustomActionTimeoutEnabled types.Bool `tfsdk:"is_custom_action_timeout_enabled"`
336-
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
337-
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"months"`
338-
PatchingMode fwtypes.StringEnum[odbtypes.PatchingModeType] `tfsdk:"patching_mode"`
339-
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
340-
WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"`
332+
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"days_of_week"`
333+
HoursOfDay fwtypes.SetValueOf[types.Int64] `tfsdk:"hours_of_day"`
334+
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
335+
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"months"`
336+
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
337+
WeeksOfMonth fwtypes.SetValueOf[types.Int64] `tfsdk:"weeks_of_month"`
341338
}
342339
type dayWeekNameAutonomousVmClusterMaintenanceWindowDataSourceModel struct {
343340
Name fwtypes.StringEnum[odbtypes.DayOfWeekName] `tfsdk:"name"`

internal/service/odb/cloud_autonomous_vm_cluster_data_source_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
126126
scan_listener_port_tls = 8561
127127
scan_listener_port_non_tls = 1024
128128
maintenance_window {
129-
custom_action_timeout_in_mins = 16
130-
is_custom_action_timeout_enabled = true
131-
patching_mode = "ROLLING"
132-
preference = "NO_PREFERENCE"
129+
preference = "NO_PREFERENCE"
130+
}
131+
tags = {
132+
"env" = "dev"
133133
}
134134
135135
}
@@ -177,16 +177,11 @@ resource "aws_odb_cloud_exadata_infrastructure" "test" {
177177
compute_count = 2
178178
availability_zone_id = "use1-az6"
179179
customer_contacts_to_send_to_oci = ["%[2]s"]
180-
maintenance_window = {
180+
maintenance_window {
181181
custom_action_timeout_in_mins = 16
182-
days_of_week = []
183-
hours_of_day = []
184182
is_custom_action_timeout_enabled = true
185-
lead_time_in_weeks = 0
186-
months = []
187183
patching_mode = "ROLLING"
188184
preference = "NO_PREFERENCE"
189-
weeks_of_month = []
190185
}
191186
}
192187

internal/service/odb/cloud_autonomous_vm_cluster_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,15 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
294294
db_servers = [for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
295295
scan_listener_port_tls = 8561
296296
scan_listener_port_non_tls = 1024
297-
maintenance_window {
298-
preference = "NO_PREFERENCE"
297+
maintenance_window {
298+
preference = "NO_PREFERENCE"
299299
}
300300
301301
}
302302
303303
304+
305+
304306
`, exaInfraRes, odbNetRes, avmcDisplayName)
305307

306308
return res
@@ -336,12 +338,14 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
336338
scan_listener_port_tls = 8561
337339
scan_listener_port_non_tls = 1024
338340
maintenance_window {
339-
preference = "NO_PREFERENCE"
341+
preference = "NO_PREFERENCE"
340342
}
341343
342344
}
343345
344346
347+
348+
345349
`, exaInfraRes, odbNetRes, avmcDisplayName)
346350
withTag := fmt.Sprintf(`
347351
%s
@@ -365,7 +369,7 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
365369
scan_listener_port_tls = 8561
366370
scan_listener_port_non_tls = 1024
367371
maintenance_window {
368-
preference = "NO_PREFERENCE"
372+
preference = "NO_PREFERENCE"
369373
}
370374
tags = {
371375
"env" = "dev"
@@ -374,6 +378,8 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
374378
}
375379
376380
381+
382+
377383
`, exaInfraRes, odbNetRes, avmcDisplayName)
378384

379385
return noTag, withTag
@@ -411,12 +417,12 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
411417
scan_listener_port_tls = 8561
412418
scan_listener_port_non_tls = 1024
413419
maintenance_window {
414-
preference = "CUSTOM_PREFERENCE"
415420
days_of_week = [{ name = "MONDAY" }, { name = "TUESDAY" }]
416421
hours_of_day = [4, 16]
422+
lead_time_in_weeks = 3
417423
months = [{ name = "FEBRUARY" }, { name = "MAY" }, { name = "AUGUST" }, { name = "NOVEMBER" }]
424+
preference = "CUSTOM_PREFERENCE"
418425
weeks_of_month = [2, 4]
419-
lead_time_in_weeks = 3
420426
}
421427
tags = {
422428
"env" = "dev"
@@ -425,6 +431,8 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
425431
}
426432
427433
434+
435+
428436
`, exaInfraRes, odbNetRes, avmcDisplayName)
429437

430438
return res

0 commit comments

Comments
 (0)