Skip to content

Commit 65b4382

Browse files
committed
system shape and gi version data source
1 parent bfdc400 commit 65b4382

8 files changed

+434
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
data "aws_odb_db_system_shapes_list" "test"{
4+
availability_zone_id = "use1-az6" # pass the availability zone id
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
data "aws_odb_gi_versions_list" "shape_9XM" {
3+
shape = "Exadata.X9M"
4+
}
5+
6+
data "aws_odb_gi_versions_list" "shape_11XM" {
7+
shape = "Exadata.X11M"
8+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
package odb
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"github.com/hashicorp/terraform-plugin-framework/attr"
9+
10+
"github.com/aws/aws-sdk-go-v2/service/odb"
11+
12+
"github.com/hashicorp/terraform-plugin-framework/datasource"
13+
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
14+
"github.com/hashicorp/terraform-plugin-framework/types"
15+
"github.com/hashicorp/terraform-provider-aws/internal/create"
16+
"github.com/hashicorp/terraform-provider-aws/internal/framework"
17+
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
18+
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
19+
"github.com/hashicorp/terraform-provider-aws/names"
20+
)
21+
22+
// Function annotations are used for datasource registration to the Provider. DO NOT EDIT.
23+
// @FrameworkDataSource("aws_odb_db_system_shapes_list", name="Db System Shapes List")
24+
func newDataSourceDbSystemShapesList(context.Context) (datasource.DataSourceWithConfigure, error) {
25+
return &dataSourceDbSystemShapesList{}, nil
26+
}
27+
28+
const (
29+
DSNameDbSystemShapesList = "Db System Shapes List Data Source"
30+
)
31+
32+
type dataSourceDbSystemShapesList struct {
33+
framework.DataSourceWithModel[dbSystemShapesListDataSourceModel]
34+
}
35+
36+
func (d *dataSourceDbSystemShapesList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
37+
resp.Schema = schema.Schema{
38+
Attributes: map[string]schema.Attribute{
39+
"availability_zone_id": schema.StringAttribute{
40+
Optional: true,
41+
Description: "The physical ID of the AZ, for example, use1-az4. This ID persists across accounts",
42+
},
43+
"db_system_shapes": schema.ListAttribute{
44+
Computed: true,
45+
CustomType: fwtypes.NewListNestedObjectTypeOf[dbSystemShapeDataSourceModel](ctx),
46+
Description: fmt.Sprint("The list of shapes and their properties.\n\n" +
47+
"(structure)\n" +
48+
"Information about a hardware system model (shape) that's\n " +
49+
"available for an Exadata infrastructure. The shape determines\n" +
50+
"resources, such as CPU cores, memory, and storage, to allocate to\n " +
51+
"the Exadata infrastructure.\n"),
52+
ElementType: types.ObjectType{
53+
54+
AttrTypes: map[string]attr.Type{
55+
"available_core_count": types.Int32Type,
56+
"available_core_count_per_node": types.Int32Type,
57+
"available_data_storage_in_tbs": types.Int32Type,
58+
"available_data_storage_per_server_in_tbs": types.Int32Type,
59+
"available_db_node_per_node_in_gbs": types.Int32Type,
60+
"available_db_node_storage_in_gbs": types.Int32Type,
61+
"available_memory_in_gbs": types.Int32Type,
62+
"available_memory_per_node_in_gbs": types.Int32Type,
63+
"core_count_increment": types.Int32Type,
64+
"max_storage_count": types.Int32Type,
65+
"maximum_node_count": types.Int32Type,
66+
"min_core_count_per_node": types.Int32Type,
67+
"min_data_storage_in_tbs": types.Int32Type,
68+
"min_db_node_storage_per_node_in_gbs": types.Int32Type,
69+
"min_memory_per_node_in_gbs": types.Int32Type,
70+
"min_storage_count": types.Int32Type,
71+
"minimum_core_count": types.Int32Type,
72+
"minimum_node_count": types.Int32Type,
73+
"name": types.StringType,
74+
"runtime_minimum_core_count": types.Int32Type,
75+
"shape_family": types.StringType,
76+
"shape_type": types.StringType,
77+
},
78+
},
79+
},
80+
},
81+
}
82+
}
83+
84+
func (d *dataSourceDbSystemShapesList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
85+
86+
conn := d.Meta().ODBClient(ctx)
87+
88+
var data dbSystemShapesListDataSourceModel
89+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
90+
if resp.Diagnostics.HasError() {
91+
return
92+
}
93+
input := odb.ListDbSystemShapesInput{}
94+
if !data.AvailabilityZoneId.IsNull() && !data.AvailabilityZoneId.IsUnknown() {
95+
input.AvailabilityZoneId = data.AvailabilityZoneId.ValueStringPointer()
96+
}
97+
paginator := odb.NewListDbSystemShapesPaginator(conn, &input)
98+
var out odb.ListDbSystemShapesOutput
99+
for paginator.HasMorePages() {
100+
page, err := paginator.NextPage(ctx)
101+
if err != nil {
102+
resp.Diagnostics.AddError(
103+
create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameDbSystemShapesList, "", err),
104+
err.Error(),
105+
)
106+
return
107+
}
108+
109+
if page != nil && len(page.DbSystemShapes) > 0 {
110+
out.DbSystemShapes = append(out.DbSystemShapes, page.DbSystemShapes...)
111+
}
112+
}
113+
resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...)
114+
if resp.Diagnostics.HasError() {
115+
return
116+
}
117+
118+
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
119+
}
120+
121+
type dbSystemShapesListDataSourceModel struct {
122+
framework.WithRegionModel
123+
AvailabilityZoneId types.String `tfsdk:"availability_zone_id"`
124+
DbSystemShapes fwtypes.ListNestedObjectValueOf[dbSystemShapeDataSourceModel] `tfsdk:"db_system_shapes"`
125+
}
126+
127+
type dbSystemShapeDataSourceModel struct {
128+
AvailableCoreCount types.Int32 `tfsdk:"available_core_count"`
129+
AvailableCoreCountPerNode types.Int32 `tfsdk:"available_core_count_per_node"`
130+
AvailableDataStorageInTBs types.Int32 `tfsdk:"available_data_storage_in_tbs"`
131+
AvailableDataStoragePerServerInTBs types.Int32 `tfsdk:"available_data_storage_per_server_in_tbs"`
132+
AvailableDbNodePerNodeInGBs types.Int32 `tfsdk:"available_db_node_per_node_in_gbs"`
133+
AvailableDbNodeStorageInGBs types.Int32 `tfsdk:"available_db_node_storage_in_gbs"`
134+
AvailableMemoryInGBs types.Int32 `tfsdk:"available_memory_in_gbs"`
135+
AvailableMemoryPerNodeInGBs types.Int32 `tfsdk:"available_memory_per_node_in_gbs"`
136+
CoreCountIncrement types.Int32 `tfsdk:"core_count_increment"`
137+
MaxStorageCount types.Int32 `tfsdk:"max_storage_count"`
138+
MaximumNodeCount types.Int32 `tfsdk:"maximum_node_count"`
139+
MinCoreCountPerNode types.Int32 `tfsdk:"min_core_count_per_node"`
140+
MinDataStorageInTBs types.Int32 `tfsdk:"min_data_storage_in_tbs"`
141+
MinDbNodeStoragePerNodeInGBs types.Int32 `tfsdk:"min_db_node_storage_per_node_in_gbs"`
142+
MinMemoryPerNodeInGBs types.Int32 `tfsdk:"min_memory_per_node_in_gbs"`
143+
MinStorageCount types.Int32 `tfsdk:"min_storage_count"`
144+
MinimumCoreCount types.Int32 `tfsdk:"minimum_core_count"`
145+
MinimumNodeCount types.Int32 `tfsdk:"minimum_node_count"`
146+
Name types.String `tfsdk:"name"`
147+
RuntimeMinimumCoreCount types.Int32 `tfsdk:"runtime_minimum_core_count"`
148+
ShapeFamily types.String `tfsdk:"shape_family"`
149+
ShapeType types.String `tfsdk:"shape_type"`
150+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
package odb_test
4+
5+
import (
6+
"fmt"
7+
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
12+
"github.com/hashicorp/terraform-provider-aws/names"
13+
)
14+
15+
func TestAccODBDbSystemShapesListDataSource_basic(t *testing.T) {
16+
ctx := acctest.Context(t)
17+
if testing.Short() {
18+
t.Skip("skipping long-running test in short mode")
19+
}
20+
21+
dataSourceName := "data.aws_odb_db_system_shapes_list.test"
22+
23+
resource.ParallelTest(t, resource.TestCase{
24+
PreCheck: func() {
25+
acctest.PreCheck(ctx, t)
26+
},
27+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
28+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
29+
Steps: []resource.TestStep{
30+
{
31+
Config: basicConfigDbSystemShapeDataSource("use1-az6"),
32+
Check: resource.ComposeAggregateTestCheckFunc(
33+
resource.TestCheckResourceAttr(dataSourceName, "db_system_shapes.#", "2"),
34+
),
35+
},
36+
},
37+
})
38+
}
39+
40+
func basicConfigDbSystemShapeDataSource(availabilityZoneId string) string {
41+
return fmt.Sprintf(`
42+
data "aws_odb_db_system_shapes_list" "test"{
43+
availability_zone_id = %[1]q
44+
}
45+
`, availabilityZoneId)
46+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
package odb
4+
5+
import (
6+
"context"
7+
"fmt"
8+
9+
"github.com/aws/aws-sdk-go-v2/service/odb"
10+
11+
"github.com/hashicorp/terraform-plugin-framework/datasource"
12+
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
13+
"github.com/hashicorp/terraform-plugin-framework/types"
14+
"github.com/hashicorp/terraform-provider-aws/internal/create"
15+
"github.com/hashicorp/terraform-provider-aws/internal/framework"
16+
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
17+
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
18+
"github.com/hashicorp/terraform-provider-aws/names"
19+
)
20+
21+
// Function annotations are used for datasource registration to the Provider. DO NOT EDIT.
22+
// @FrameworkDataSource("aws_odb_gi_versions_list", name="Gi Versions List")
23+
func newDataSourceGiVersionsList(context.Context) (datasource.DataSourceWithConfigure, error) {
24+
return &dataSourceGiVersionsList{}, nil
25+
}
26+
27+
const (
28+
DSNameGiVersionsList = "Gi Versions List Data Source"
29+
)
30+
31+
type dataSourceGiVersionsList struct {
32+
framework.DataSourceWithModel[giVersionDataSourceModel]
33+
}
34+
35+
func (d *dataSourceGiVersionsList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
36+
resp.Schema = schema.Schema{
37+
Attributes: map[string]schema.Attribute{
38+
"shape": schema.StringAttribute{
39+
Optional: true,
40+
Description: "The system shape.",
41+
},
42+
},
43+
Blocks: map[string]schema.Block{
44+
"gi_versions": schema.ListNestedBlock{
45+
Description: fmt.Sprint(" (structure)\n " +
46+
"Information about a specific version of Oracle Grid\n" +
47+
"Infrastructure (GI) software that can be installed on a VM\n " +
48+
"cluster.\n\n " +
49+
"version -> (string)\n " +
50+
"The GI software version."),
51+
CustomType: fwtypes.NewListNestedObjectTypeOf[giVersionSummaryModel](ctx),
52+
NestedObject: schema.NestedBlockObject{
53+
Attributes: map[string]schema.Attribute{
54+
"version": schema.StringAttribute{
55+
Computed: true,
56+
},
57+
},
58+
},
59+
},
60+
},
61+
}
62+
}
63+
64+
func (d *dataSourceGiVersionsList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
65+
66+
conn := d.Meta().ODBClient(ctx)
67+
68+
var data giVersionDataSourceModel
69+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
70+
if resp.Diagnostics.HasError() {
71+
return
72+
}
73+
74+
var input odb.ListGiVersionsInput
75+
if !data.Shape.IsNull() {
76+
input.Shape = data.Shape.ValueStringPointer()
77+
}
78+
out, err := conn.ListGiVersions(ctx, &input)
79+
if err != nil {
80+
resp.Diagnostics.AddError(
81+
create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameGiVersionsList, "", err),
82+
err.Error(),
83+
)
84+
return
85+
}
86+
87+
resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...)
88+
if resp.Diagnostics.HasError() {
89+
return
90+
}
91+
92+
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
93+
}
94+
95+
type giVersionDataSourceModel struct {
96+
framework.WithRegionModel
97+
GiVersions fwtypes.ListNestedObjectValueOf[giVersionSummaryModel] `tfsdk:"gi_versions"`
98+
Shape types.String `tfsdk:"shape"`
99+
}
100+
101+
type giVersionSummaryModel struct {
102+
Version types.String `tfsdk:"version"`
103+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
package odb_test
4+
5+
import (
6+
"fmt"
7+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
8+
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
9+
"github.com/hashicorp/terraform-provider-aws/names"
10+
"testing"
11+
)
12+
13+
func TestAccGiVersionsListDataSource_basicX9M(t *testing.T) {
14+
ctx := acctest.Context(t)
15+
16+
if testing.Short() {
17+
t.Skip("skipping long-running test in short mode")
18+
}
19+
dataSourceName := "data.aws_odb_gi_versions_list.test"
20+
21+
resource.Test(t, resource.TestCase{
22+
PreCheck: func() {
23+
acctest.PreCheck(ctx, t)
24+
},
25+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
26+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
27+
Steps: []resource.TestStep{
28+
{
29+
Config: testAccGiVersionsListeConfig_basic("Exadata.X9M"),
30+
Check: resource.ComposeAggregateTestCheckFunc(
31+
resource.TestCheckResourceAttr(dataSourceName, "gi_versions.#", "2"),
32+
),
33+
},
34+
},
35+
})
36+
37+
}
38+
39+
func TestAccGiVersionsListDataSource_basicX11M(t *testing.T) {
40+
ctx := acctest.Context(t)
41+
42+
if testing.Short() {
43+
t.Skip("skipping long-running test in short mode")
44+
}
45+
dataSourceName := "data.aws_odb_gi_versions_list.test"
46+
47+
resource.Test(t, resource.TestCase{
48+
PreCheck: func() {
49+
acctest.PreCheck(ctx, t)
50+
},
51+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
52+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
53+
Steps: []resource.TestStep{
54+
{
55+
Config: testAccGiVersionsListeConfig_basic("Exadata.X11M"),
56+
Check: resource.ComposeAggregateTestCheckFunc(
57+
resource.TestCheckResourceAttr(dataSourceName, "gi_versions.#", "2"),
58+
),
59+
},
60+
},
61+
})
62+
}
63+
64+
func testAccGiVersionsListeConfig_basic(shape string) string {
65+
return fmt.Sprintf(`
66+
67+
data "aws_odb_gi_versions_list" "test" {
68+
shape = %[1]q
69+
}
70+
`, shape)
71+
}

0 commit comments

Comments
 (0)