Skip to content

Commit b80dde4

Browse files
committed
added copy write notice
1 parent d2ac54b commit b80dde4

40 files changed

+309
-263
lines changed

examples/odb/main.tf

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
2+
3+
provider "aws" {
4+
region = "us-east-1"
5+
}
6+
7+
resource "aws_odb_cloud_exadata_infrastructure" "test" {
8+
display_name = "Ofake-exa-4157426154220451194"
9+
shape = "Exadata.X9M"
10+
storage_count = 3
11+
compute_count = 2
12+
availability_zone_id = "use1-az6"
13+
customer_contacts_to_send_to_oci = ["[email protected]"]
14+
maintenance_window = {
15+
custom_action_timeout_in_mins = 16
16+
days_of_week = []
17+
hours_of_day = []
18+
is_custom_action_timeout_enabled = true
19+
lead_time_in_weeks = 0
20+
months = []
21+
patching_mode = "ROLLING"
22+
preference = "NO_PREFERENCE"
23+
weeks_of_month =[]
24+
}
25+
}
26+
27+
28+
29+
30+
31+
32+
resource "aws_odb_network" "test" {
33+
display_name = "odb-net-6310376148776971562"
34+
availability_zone_id = "use1-az6"
35+
client_subnet_cidr = "10.2.0.0/24"
36+
backup_subnet_cidr = "10.2.1.0/24"
37+
s3_access = "DISABLED"
38+
zero_etl_access = "DISABLED"
39+
}
40+
41+
42+
43+
data "aws_odb_db_servers_list" "test" {
44+
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
45+
}
46+
47+
resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
48+
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
49+
odb_network_id =aws_odb_network.test.id
50+
display_name = "Ofake-avmc-1515523754357569237"
51+
autonomous_data_storage_size_in_tbs = 5
52+
memory_per_oracle_compute_unit_in_gbs = 2
53+
total_container_databases = 1
54+
cpu_core_count_per_node = 40
55+
license_model = "LICENSE_INCLUDED"
56+
db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
57+
scan_listener_port_tls = 8561
58+
scan_listener_port_non_tls = 1024
59+
maintenance_window = {
60+
preference = "NO_PREFERENCE"
61+
days_of_week = []
62+
hours_of_day = []
63+
months = []
64+
weeks_of_month =[]
65+
lead_time_in_weeks = 0
66+
}
67+
68+
}
69+
70+
71+
data "aws_odb_cloud_autonomous_vm_cluster" "test" {
72+
id = aws_odb_cloud_autonomous_vm_cluster.test.id
73+
74+
}

examples/odb/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//Copyright © 2025, Oracle and/or its affiliates. All rights reserved.

internal/service/odb/cloud_autonomous_vm_cluster.go

Lines changed: 1 addition & 2 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 © 2025, Oracle and/or its affiliates. All rights reserved.
32

43
package odb
54

internal/service/odb/cloud_autonomous_vm_cluster_data_source.go

Lines changed: 1 addition & 2 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 © 2025, Oracle and/or its affiliates. All rights reserved.
32

43
package odb
54

internal/service/odb/cloud_autonomous_vm_cluster_data_source_test.go

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

43
package odb_test
54

65
import (
76
"context"
87
"errors"
98
"fmt"
9+
"github.com/aws/aws-sdk-go-v2/aws"
1010
"github.com/aws/aws-sdk-go-v2/service/odb"
1111
odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types"
12+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1213
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1314
"github.com/hashicorp/terraform-plugin-testing/terraform"
1415
"github.com/hashicorp/terraform-provider-aws/internal/conns"
1516
"github.com/hashicorp/terraform-provider-aws/internal/create"
17+
"github.com/hashicorp/terraform-provider-aws/internal/errs"
1618
tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb"
1719
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
1820
"testing"
@@ -42,9 +44,7 @@ func TestAccODBCloudAutonomousVmClusterDataSource_basic(t *testing.T) {
4244
}
4345
var avmc1 odbtypes.CloudAutonomousVmCluster
4446
dataSourceName := "data.aws_odb_cloud_autonomous_vm_cluster.test"
45-
avmcDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.autonomousVmClusterDisplayNamePrefix)
46-
//odbDisplayNamePrefix := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.odbNetDisplayNamePrefix)
47-
//exaDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.exaInfraDisplayNamePrefix)
47+
4848
resource.ParallelTest(t, resource.TestCase{
4949
PreCheck: func() {
5050
acctest.PreCheck(ctx, t)
@@ -55,10 +55,9 @@ func TestAccODBCloudAutonomousVmClusterDataSource_basic(t *testing.T) {
5555
CheckDestroy: autonomousVMClusterDSTestEntity.testAccCheckCloudAutonomousVmClusterDestroy(ctx),
5656
Steps: []resource.TestStep{
5757
{
58-
Config: autonomousVMClusterDSTestEntity.basicHardcodedAVmCluster("exa_ji5quxxzn9", "odbnet_c91byo6y6m", avmcDisplayName),
58+
Config: autonomousVMClusterDSTestEntity.avmcBasic(),
5959
Check: resource.ComposeAggregateTestCheckFunc(
60-
autonomousVMClusterDSTestEntity.checkCloudAutonomousVmClusterExists(ctx, dataSourceName, &avmc1),
61-
resource.TestCheckResourceAttr(dataSourceName, "display_name", avmcDisplayName),
60+
resource.TestCheckResourceAttr(dataSourceName, "display_name", *avmc1.DisplayName),
6261
),
6362
},
6463
},
@@ -76,8 +75,7 @@ func (autonomousVMClusterDSTest) checkCloudAutonomousVmClusterExists(ctx context
7675
}
7776

7877
conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx)
79-
fmt.Println("")
80-
resp, err := autonomousVMClusterResourceTest{}.findVMC(ctx, conn, rs.Primary.ID)
78+
resp, err := autonomousVMClusterDSTestEntity.findAVMC(ctx, conn, rs.Primary.ID)
8179
if err != nil {
8280
return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, err)
8381
}
@@ -87,6 +85,29 @@ func (autonomousVMClusterDSTest) checkCloudAutonomousVmClusterExists(ctx context
8785
return nil
8886
}
8987
}
88+
89+
func (autonomousVMClusterDSTest) findAVMC(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudAutonomousVmCluster, error) {
90+
input := odb.GetCloudAutonomousVmClusterInput{
91+
CloudAutonomousVmClusterId: aws.String(id),
92+
}
93+
out, err := conn.GetCloudAutonomousVmCluster(ctx, &input)
94+
if err != nil {
95+
if errs.IsA[*odbtypes.ResourceNotFoundException](err) {
96+
return nil, &retry.NotFoundError{
97+
LastError: err,
98+
LastRequest: &input,
99+
}
100+
}
101+
return nil, err
102+
}
103+
104+
if out == nil || out.CloudAutonomousVmCluster == nil {
105+
return nil, tfresource.NewEmptyResultError(&input)
106+
}
107+
108+
return out.CloudAutonomousVmCluster, nil
109+
}
110+
90111
func (autonomousVMClusterDSTest) testAccCheckCloudAutonomousVmClusterDestroy(ctx context.Context) resource.TestCheckFunc {
91112
return func(s *terraform.State) error {
92113
conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx)
@@ -125,18 +146,33 @@ func (autonomousVMClusterDSTest) testAccPreCheck(ctx context.Context, t *testing
125146
}
126147
}
127148

128-
func (autonomousVMClusterDSTest) basicHardcodedAVmCluster(exaInfra, odbNetwork, avmcDisplayName string) string {
129-
avmcDataSource := fmt.Sprintf(`
149+
func (autonomousVMClusterDSTest) avmcBasic() string {
150+
151+
exaInfraDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.exaInfraDisplayNamePrefix)
152+
odbNetworkDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.odbNetDisplayNamePrefix)
153+
avmcDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.autonomousVmClusterDisplayNamePrefix)
154+
155+
exaInfraRes := autonomousVMClusterDSTestEntity.exaInfra(exaInfraDisplayName)
156+
odbNetRes := autonomousVMClusterDSTestEntity.odbNet(odbNetworkDisplayName)
157+
res := fmt.Sprintf(`
158+
%s
159+
160+
%s
161+
162+
data "aws_odb_db_servers_list" "test" {
163+
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
164+
}
165+
130166
resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
131-
cloud_exadata_infrastructure_id = %[1]q
132-
odb_network_id = %[2]q
167+
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
168+
odb_network_id =aws_odb_network.test.id
133169
display_name = %[3]q
134170
autonomous_data_storage_size_in_tbs = 5
135171
memory_per_oracle_compute_unit_in_gbs = 2
136172
total_container_databases = 1
137173
cpu_core_count_per_node = 40
138174
license_model = "LICENSE_INCLUDED"
139-
db_servers = ["dbs_7ecm4wbjxy","dbs_uy5wmaqk6s"]
175+
db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
140176
scan_listener_port_tls = 8561
141177
scan_listener_port_non_tls = 1024
142178
maintenance_window = {
@@ -155,41 +191,52 @@ data "aws_odb_cloud_autonomous_vm_cluster" "test" {
155191
id = aws_odb_cloud_autonomous_vm_cluster.test.id
156192
157193
}
158-
`, exaInfra, odbNetwork, avmcDisplayName)
159-
return avmcDataSource
194+
`, exaInfraRes, odbNetRes, avmcDisplayName)
195+
196+
return res
197+
}
198+
199+
func (autonomousVMClusterDSTest) odbNet(odbNetName string) string {
200+
networkRes := fmt.Sprintf(`
201+
202+
203+
resource "aws_odb_network" "test" {
204+
display_name = %[1]q
205+
availability_zone_id = "use1-az6"
206+
client_subnet_cidr = "10.2.0.0/24"
207+
backup_subnet_cidr = "10.2.1.0/24"
208+
s3_access = "DISABLED"
209+
zero_etl_access = "DISABLED"
210+
}
211+
212+
`, odbNetName)
213+
return networkRes
160214
}
161-
func (autonomousVMClusterDSTest) avmcBasic(exaInfra, odbNetwork, avmcDisplayName string) string {
162-
res := fmt.Sprintf(`
215+
216+
func (autonomousVMClusterDSTest) exaInfra(exaInfraName string) string {
217+
exaInfraRes := fmt.Sprintf(`
218+
219+
163220
resource "aws_odb_cloud_exadata_infrastructure" "test" {
164221
display_name = %[1]q
165222
shape = "Exadata.X9M"
166223
storage_count = 3
167224
compute_count = 2
168225
availability_zone_id = "use1-az6"
169226
customer_contacts_to_send_to_oci = ["[email protected]"]
170-
227+
maintenance_window = {
228+
custom_action_timeout_in_mins = 16
229+
days_of_week = []
230+
hours_of_day = []
231+
is_custom_action_timeout_enabled = true
232+
lead_time_in_weeks = 0
233+
months = []
234+
patching_mode = "ROLLING"
235+
preference = "NO_PREFERENCE"
236+
weeks_of_month =[]
237+
}
171238
}
172239
173-
resource "aws_odb_network" "test" {
174-
display_name = %[2]q
175-
availability_zone_id = "use1-az6"
176-
client_subnet_cidr = "10.2.0.0/24"
177-
backup_subnet_cidr = "10.2.1.0/24"
178-
s3_access = "DISABLED"
179-
zero_etl_access = "DISABLED"
180-
}
181-
182-
resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
183-
display_name = %[3]q
184-
cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id
185-
odb_network_id = aws_odb_network.test.id
186-
autonomous_data_storage_size_in_tbs = 5
187-
memory_per_oracle_compute_unit_in_gbs = 2
188-
total_container_databases = 1
189-
cpu_core_count_per_node = 4
190-
191-
}
192-
`, exaInfra, odbNetwork, avmcDisplayName)
193-
194-
return res
240+
`, exaInfraName)
241+
return exaInfraRes
195242
}

0 commit comments

Comments
 (0)