Skip to content

Commit dd763c2

Browse files
Feat: Add google_oracle_database_cloud_exadata_infrastructure datasource (#11996)
1 parent c951027 commit dd763c2

4 files changed

+113
-0
lines changed

mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
169169
"google_monitoring_uptime_check_ips": monitoring.DataSourceGoogleMonitoringUptimeCheckIps(),
170170
"google_netblock_ip_ranges": resourcemanager.DataSourceGoogleNetblockIpRanges(),
171171
"google_oracle_database_db_servers": oracledatabase.DataSourceOracleDatabaseDbServers(),
172+
"google_oracle_database_cloud_exadata_infrastructure":oracledatabase.DataSourceOracleDatabaseCloudExadataInfrastructure(),
172173
"google_organization": resourcemanager.DataSourceGoogleOrganization(),
173174
"google_privateca_certificate_authority": privateca.DataSourcePrivatecaCertificateAuthority(),
174175
"google_privileged_access_manager_entitlement": privilegedaccessmanager.DataSourceGooglePrivilegedAccessManagerEntitlement(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package oracledatabase
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
8+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
9+
)
10+
11+
func DataSourceOracleDatabaseCloudExadataInfrastructure() *schema.Resource {
12+
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceOracleDatabaseCloudExadataInfrastructure().Schema)
13+
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "cloud_exadata_infrastructure_id")
14+
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
15+
return &schema.Resource{
16+
Read: dataSourceOracleDatabaseCloudExadataInfrastructureRead,
17+
Schema: dsSchema,
18+
}
19+
20+
}
21+
22+
func dataSourceOracleDatabaseCloudExadataInfrastructureRead(d *schema.ResourceData, meta interface{}) error {
23+
config := meta.(*transport_tpg.Config)
24+
25+
id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/cloudExadataInfrastructures/{{cloud_exadata_infrastructure_id}}")
26+
if err != nil {
27+
return fmt.Errorf("Error constructing id: %s", err)
28+
}
29+
err = resourceOracleDatabaseCloudExadataInfrastructureRead(d, meta)
30+
if err != nil {
31+
return err
32+
}
33+
d.SetId(id)
34+
35+
return nil
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package oracledatabase_test
2+
3+
import (
4+
"fmt"
5+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
6+
"github.com/hashicorp/terraform-provider-google/google/acctest"
7+
"testing"
8+
)
9+
10+
func TestAccOracleDatabaseCloudExadataInfrastructure_basic(t *testing.T) {
11+
t.Parallel()
12+
acctest.VcrTest(t, resource.TestCase{
13+
PreCheck: func() { acctest.AccTestPreCheck(t) },
14+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
15+
Steps: []resource.TestStep{
16+
{
17+
Config: testAccOracleDatabaseCloudExadataInfrastructure_basic(),
18+
Check: resource.ComposeTestCheckFunc(
19+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "display_name"),
20+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "name"),
21+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "gcp_oracle_zone"),
22+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.#"),
23+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.compute_count"),
24+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "display_name", "ofake-exadata-for-vm display name"),
25+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "gcp_oracle_zone", "us-east4-b-r1"),
26+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.state", "AVAILABLE"),
27+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.shape", "Exadata.X9M"),
28+
),
29+
},
30+
},
31+
})
32+
}
33+
34+
func testAccOracleDatabaseCloudExadataInfrastructure_basic() string {
35+
return fmt.Sprintf(`
36+
data "google_oracle_database_cloud_exadata_infrastructure" "my-exadata"{
37+
cloud_exadata_infrastructure_id = "ofake-do-not-delete-tf-exadata"
38+
project = "oci-terraform-testing"
39+
location = "us-east4"
40+
}
41+
`)
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
subcategory: "Oracle Database"
3+
description: |-
4+
Get information about an ExadataInfrastructure.
5+
---
6+
7+
# google_oracle_database_cloud_exadata_infrastructure
8+
9+
Get information about an ExadataInfrastructure.
10+
11+
## Example Usage
12+
13+
```hcl
14+
data "google_oracle_database_cloud_exadata_infrastructure" "my-instance"{
15+
location = "us-east4"
16+
cloud_exadata_infrastructure_id = "exadata-id"
17+
}
18+
```
19+
20+
## Argument Reference
21+
22+
The following arguments are supported:
23+
24+
* `cloud_exadata_infrastructure_id` - (Required) The ID of the ExadataInfrastructure.
25+
26+
* `location` - (Required) The location of the resource.
27+
28+
- - -
29+
* `project` - (Optional) The project to which the resource belongs. If it
30+
is not provided, the provider project is used.
31+
32+
## Attributes Reference
33+
34+
See [google_oracle_database_cloud_exadata_infrastructure](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_oracle_database_cloud_exadata_infrastructure#argument-reference) resource for details of the available attributes.

0 commit comments

Comments
 (0)