Skip to content

Commit 9a83349

Browse files
authored
Merge pull request #43825 from oracle-community/system-shape-and-gi-version
System shape and gi version
2 parents dd7b8f6 + d3024a7 commit 9a83349

8 files changed

+417
-0
lines changed

.changelog/43825.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:new-data-source
2+
aws_odb_gi_versions
3+
```
4+
5+
```release-note:new-data-source
6+
aws_odb_db_system_shapes
7+
```
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package odb
5+
6+
import (
7+
"context"
8+
9+
"github.com/aws/aws-sdk-go-v2/service/odb"
10+
"github.com/hashicorp/terraform-plugin-framework/datasource"
11+
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
12+
"github.com/hashicorp/terraform-plugin-framework/types"
13+
"github.com/hashicorp/terraform-provider-aws/internal/create"
14+
"github.com/hashicorp/terraform-provider-aws/internal/framework"
15+
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
16+
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
17+
"github.com/hashicorp/terraform-provider-aws/names"
18+
)
19+
20+
// Function annotations are used for datasource registration to the Provider. DO NOT EDIT.
21+
// @FrameworkDataSource("aws_odb_db_system_shapes", name="Db System Shapes")
22+
func newDataSourceDBSystemShapes(context.Context) (datasource.DataSourceWithConfigure, error) {
23+
return &dataSourceDBSystemShapesList{}, nil
24+
}
25+
26+
const (
27+
DSNameDBSystemShapesList = "Db System Shapes List Data Source"
28+
)
29+
30+
type dataSourceDBSystemShapesList struct {
31+
framework.DataSourceWithModel[dbSystemShapesListDataSourceModel]
32+
}
33+
34+
func (d *dataSourceDBSystemShapesList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
35+
resp.Schema = schema.Schema{
36+
Attributes: map[string]schema.Attribute{
37+
"availability_zone_id": schema.StringAttribute{
38+
Optional: true,
39+
Description: "The physical ID of the AZ, for example, use1-az4. This ID persists across accounts.",
40+
},
41+
"db_system_shapes": schema.ListAttribute{
42+
Computed: true,
43+
CustomType: fwtypes.NewListNestedObjectTypeOf[dbSystemShapeDataSourceModel](ctx),
44+
Description: "The list of shapes and their properties. Information about a hardware system model (shape) that's available for an Exadata infrastructure." +
45+
"The shape determines resources, such as CPU cores, memory, and storage, to allocate to the Exadata infrastructure.",
46+
},
47+
},
48+
}
49+
}
50+
51+
func (d *dataSourceDBSystemShapesList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
52+
conn := d.Meta().ODBClient(ctx)
53+
54+
var data dbSystemShapesListDataSourceModel
55+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
56+
if resp.Diagnostics.HasError() {
57+
return
58+
}
59+
input := odb.ListDbSystemShapesInput{}
60+
if !data.AvailabilityZoneId.IsNull() && !data.AvailabilityZoneId.IsUnknown() {
61+
input.AvailabilityZoneId = data.AvailabilityZoneId.ValueStringPointer()
62+
}
63+
paginator := odb.NewListDbSystemShapesPaginator(conn, &input)
64+
var out odb.ListDbSystemShapesOutput
65+
for paginator.HasMorePages() {
66+
page, err := paginator.NextPage(ctx)
67+
if err != nil {
68+
resp.Diagnostics.AddError(
69+
create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameDBSystemShapesList, "", err),
70+
err.Error(),
71+
)
72+
return
73+
}
74+
75+
if page != nil && len(page.DbSystemShapes) > 0 {
76+
out.DbSystemShapes = append(out.DbSystemShapes, page.DbSystemShapes...)
77+
}
78+
}
79+
resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...)
80+
if resp.Diagnostics.HasError() {
81+
return
82+
}
83+
84+
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
85+
}
86+
87+
type dbSystemShapesListDataSourceModel struct {
88+
framework.WithRegionModel
89+
AvailabilityZoneId types.String `tfsdk:"availability_zone_id"`
90+
DbSystemShapes fwtypes.ListNestedObjectValueOf[dbSystemShapeDataSourceModel] `tfsdk:"db_system_shapes"`
91+
}
92+
93+
type dbSystemShapeDataSourceModel struct {
94+
AvailableCoreCount types.Int32 `tfsdk:"available_core_count"`
95+
AvailableCoreCountPerNode types.Int32 `tfsdk:"available_core_count_per_node"`
96+
AvailableDataStorageInTBs types.Int32 `tfsdk:"available_data_storage_in_tbs"`
97+
AvailableDataStoragePerServerInTBs types.Int32 `tfsdk:"available_data_storage_per_server_in_tbs"`
98+
AvailableDbNodePerNodeInGBs types.Int32 `tfsdk:"available_db_node_per_node_in_gbs"`
99+
AvailableDbNodeStorageInGBs types.Int32 `tfsdk:"available_db_node_storage_in_gbs"`
100+
AvailableMemoryInGBs types.Int32 `tfsdk:"available_memory_in_gbs"`
101+
AvailableMemoryPerNodeInGBs types.Int32 `tfsdk:"available_memory_per_node_in_gbs"`
102+
CoreCountIncrement types.Int32 `tfsdk:"core_count_increment"`
103+
MaxStorageCount types.Int32 `tfsdk:"max_storage_count"`
104+
MaximumNodeCount types.Int32 `tfsdk:"maximum_node_count"`
105+
MinCoreCountPerNode types.Int32 `tfsdk:"min_core_count_per_node"`
106+
MinDataStorageInTBs types.Int32 `tfsdk:"min_data_storage_in_tbs"`
107+
MinDbNodeStoragePerNodeInGBs types.Int32 `tfsdk:"min_db_node_storage_per_node_in_gbs"`
108+
MinMemoryPerNodeInGBs types.Int32 `tfsdk:"min_memory_per_node_in_gbs"`
109+
MinStorageCount types.Int32 `tfsdk:"min_storage_count"`
110+
MinimumCoreCount types.Int32 `tfsdk:"minimum_core_count"`
111+
MinimumNodeCount types.Int32 `tfsdk:"minimum_node_count"`
112+
Name types.String `tfsdk:"name"`
113+
RuntimeMinimumCoreCount types.Int32 `tfsdk:"runtime_minimum_core_count"`
114+
ShapeFamily types.String `tfsdk:"shape_family"`
115+
ShapeType types.String `tfsdk:"shape_type"`
116+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package odb_test
5+
6+
import (
7+
"fmt"
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+
dataSourceName := "data.aws_odb_db_system_shapes.test"
21+
resource.ParallelTest(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: basicConfigDBSystemShapeDataSource("use1-az6"),
30+
Check: resource.ComposeAggregateTestCheckFunc(
31+
resource.TestCheckResourceAttr(dataSourceName, "db_system_shapes.#", "2"),
32+
),
33+
},
34+
},
35+
})
36+
}
37+
38+
func basicConfigDBSystemShapeDataSource(availabilityZoneId string) string {
39+
return fmt.Sprintf(`
40+
data "aws_odb_db_system_shapes" "test"{
41+
availability_zone_id = %[1]q
42+
}
43+
`, availabilityZoneId)
44+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package odb
5+
6+
import (
7+
"context"
8+
9+
"github.com/aws/aws-sdk-go-v2/service/odb"
10+
"github.com/hashicorp/terraform-plugin-framework/datasource"
11+
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
12+
"github.com/hashicorp/terraform-plugin-framework/types"
13+
"github.com/hashicorp/terraform-provider-aws/internal/create"
14+
"github.com/hashicorp/terraform-provider-aws/internal/framework"
15+
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
16+
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
17+
"github.com/hashicorp/terraform-provider-aws/names"
18+
)
19+
20+
// Function annotations are used for datasource registration to the Provider. DO NOT EDIT.
21+
// @FrameworkDataSource("aws_odb_gi_versions", name="Gi Versions")
22+
func newDataSourceGiVersions(context.Context) (datasource.DataSourceWithConfigure, error) {
23+
return &dataSourceGiVersionsList{}, nil
24+
}
25+
26+
const (
27+
DSNameGiVersionsList = "Gi Versions List Data Source"
28+
)
29+
30+
type dataSourceGiVersionsList struct {
31+
framework.DataSourceWithModel[giVersionDataSourceModel]
32+
}
33+
34+
func (d *dataSourceGiVersionsList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
35+
resp.Schema = schema.Schema{
36+
Attributes: map[string]schema.Attribute{
37+
"shape": schema.StringAttribute{
38+
Optional: true,
39+
Description: "The system shape.",
40+
},
41+
"gi_versions": schema.ListAttribute{
42+
Computed: true,
43+
CustomType: fwtypes.NewListNestedObjectTypeOf[giVersionSummaryModel](ctx),
44+
Description: "Information about a specific version of Oracle Grid Infrastructure (GI) software that can be installed on a VM cluster.",
45+
},
46+
},
47+
}
48+
}
49+
50+
func (d *dataSourceGiVersionsList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
51+
conn := d.Meta().ODBClient(ctx)
52+
var data giVersionDataSourceModel
53+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
54+
if resp.Diagnostics.HasError() {
55+
return
56+
}
57+
var input odb.ListGiVersionsInput
58+
if !data.Shape.IsNull() {
59+
input.Shape = data.Shape.ValueStringPointer()
60+
}
61+
paginator := odb.NewListGiVersionsPaginator(conn, &input)
62+
var out odb.ListGiVersionsOutput
63+
for paginator.HasMorePages() {
64+
page, err := paginator.NextPage(ctx)
65+
if err != nil {
66+
resp.Diagnostics.AddError(
67+
create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameGiVersionsList, "", err),
68+
err.Error(),
69+
)
70+
return
71+
}
72+
if page != nil && len(page.GiVersions) > 0 {
73+
out.GiVersions = append(out.GiVersions, page.GiVersions...)
74+
}
75+
}
76+
resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...)
77+
if resp.Diagnostics.HasError() {
78+
return
79+
}
80+
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
81+
}
82+
83+
type giVersionDataSourceModel struct {
84+
framework.WithRegionModel
85+
GiVersions fwtypes.ListNestedObjectValueOf[giVersionSummaryModel] `tfsdk:"gi_versions"`
86+
Shape types.String `tfsdk:"shape"`
87+
}
88+
89+
type giVersionSummaryModel struct {
90+
Version types.String `tfsdk:"version"`
91+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package odb_test
5+
6+
import (
7+
"fmt"
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 TestAccODBGiVersionsListDataSource_basicX9M(t *testing.T) {
16+
ctx := acctest.Context(t)
17+
18+
if testing.Short() {
19+
t.Skip("skipping long-running test in short mode")
20+
}
21+
dataSourceName := "data.aws_odb_gi_versions.test"
22+
23+
resource.Test(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: testAccGiVersionsListConfigBasic("Exadata.X9M"),
32+
Check: resource.ComposeAggregateTestCheckFunc(
33+
resource.TestCheckResourceAttr(dataSourceName, "gi_versions.#", "2"),
34+
),
35+
},
36+
},
37+
})
38+
}
39+
40+
func TestAccODBGiVersionsListDataSource_basicX11M(t *testing.T) {
41+
ctx := acctest.Context(t)
42+
if testing.Short() {
43+
t.Skip("skipping long-running test in short mode")
44+
}
45+
dataSourceName := "data.aws_odb_gi_versions.test"
46+
resource.Test(t, resource.TestCase{
47+
PreCheck: func() {
48+
acctest.PreCheck(ctx, t)
49+
},
50+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
51+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
52+
Steps: []resource.TestStep{
53+
{
54+
Config: testAccGiVersionsListConfigBasic("Exadata.X11M"),
55+
Check: resource.ComposeAggregateTestCheckFunc(
56+
resource.TestCheckResourceAttr(dataSourceName, "gi_versions.#", "2"),
57+
),
58+
},
59+
},
60+
})
61+
}
62+
63+
func testAccGiVersionsListConfigBasic(shape string) string {
64+
return fmt.Sprintf(`
65+
66+
67+
data "aws_odb_gi_versions" "test" {
68+
shape = %[1]q
69+
}
70+
`, shape)
71+
}

internal/service/odb/service_package_gen.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
subcategory: "Oracle Database@AWS"
3+
layout: "AWS: aws_odb_db_system_shapes"
4+
page_title: "AWS: aws_odb_db_system_shapes"
5+
description: |-
6+
Terraform data source to retrieve available system shapes Oracle Database@AWS.
7+
---
8+
9+
# Data Source: aws_odb_db_system_shapes
10+
11+
Terraform data source to retrieve available system shapes Oracle Database@AWS.
12+
13+
You can find out more about Oracle Database@AWS from [User Guide](https://docs.aws.amazon.com/odb/latest/UserGuide/what-is-odb.html).
14+
15+
## Example Usage
16+
17+
### Basic Usage
18+
19+
```terraform
20+
data "aws_odb_db_system_shapes" "example" {}
21+
```
22+
23+
## Argument Reference
24+
25+
The following arguments are optional:
26+
27+
* `availability_zone_id` - (Optional) The physical ID of the AZ, for example, use1-az4. This ID persists across accounts.
28+
* `region` - (Optional) Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#aws-configuration-reference).
29+
30+
## Attribute Reference
31+
32+
This data source exports the following attributes in addition to the arguments above:
33+
34+
* `db_system_shapes` - IThe list of shapes and their properties. Information about a hardware system model (shape) that's available for an Exadata infrastructure. The shape determines resources, such as CPU cores, memory, and storage, to allocate to the Exadata infrastructure.

0 commit comments

Comments
 (0)