Skip to content

Commit

Permalink
Feat: Add google_oracle_database_cloud_exadata_infrastructure datasou…
Browse files Browse the repository at this point in the history
…rce (#11996) (#19856)

[upstream:dd763c2c460db8d79056c0bf33f2b89c5f9b3ab8]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 15, 2024
1 parent e8f2586 commit fc8e5fb
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/11996.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-datasource
`google_oracle_database_cloud_exadata_infrastructure`
```
1 change: 1 addition & 0 deletions google/provider/provider_mmv1_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
"google_monitoring_uptime_check_ips": monitoring.DataSourceGoogleMonitoringUptimeCheckIps(),
"google_netblock_ip_ranges": resourcemanager.DataSourceGoogleNetblockIpRanges(),
"google_oracle_database_db_servers": oracledatabase.DataSourceOracleDatabaseDbServers(),
"google_oracle_database_cloud_exadata_infrastructure": oracledatabase.DataSourceOracleDatabaseCloudExadataInfrastructure(),
"google_organization": resourcemanager.DataSourceGoogleOrganization(),
"google_privateca_certificate_authority": privateca.DataSourcePrivatecaCertificateAuthority(),
"google_privileged_access_manager_entitlement": privilegedaccessmanager.DataSourceGooglePrivilegedAccessManagerEntitlement(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package oracledatabase

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

func DataSourceOracleDatabaseCloudExadataInfrastructure() *schema.Resource {
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceOracleDatabaseCloudExadataInfrastructure().Schema)
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "cloud_exadata_infrastructure_id")
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
return &schema.Resource{
Read: dataSourceOracleDatabaseCloudExadataInfrastructureRead,
Schema: dsSchema,
}

}

func dataSourceOracleDatabaseCloudExadataInfrastructureRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*transport_tpg.Config)

id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/cloudExadataInfrastructures/{{cloud_exadata_infrastructure_id}}")
if err != nil {
return fmt.Errorf("Error constructing id: %s", err)
}
err = resourceOracleDatabaseCloudExadataInfrastructureRead(d, meta)
if err != nil {
return err
}
d.SetId(id)

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package oracledatabase_test

import (
"fmt"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"testing"
)

func TestAccOracleDatabaseCloudExadataInfrastructure_basic(t *testing.T) {
t.Parallel()
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccOracleDatabaseCloudExadataInfrastructure_basic(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "display_name"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "name"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "gcp_oracle_zone"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.#"),
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.compute_count"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "display_name", "ofake-exadata-for-vm display name"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "gcp_oracle_zone", "us-east4-b-r1"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.state", "AVAILABLE"),
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.shape", "Exadata.X9M"),
),
},
},
})
}

func testAccOracleDatabaseCloudExadataInfrastructure_basic() string {
return fmt.Sprintf(`
data "google_oracle_database_cloud_exadata_infrastructure" "my-exadata"{
cloud_exadata_infrastructure_id = "ofake-do-not-delete-tf-exadata"
project = "oci-terraform-testing"
location = "us-east4"
}
`)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
subcategory: "Oracle Database"
description: |-
Get information about an ExadataInfrastructure.
---

# google_oracle_database_cloud_exadata_infrastructure

Get information about an ExadataInfrastructure.

## Example Usage

```hcl
data "google_oracle_database_cloud_exadata_infrastructure" "my-instance"{
location = "us-east4"
cloud_exadata_infrastructure_id = "exadata-id"
}
```

## Argument Reference

The following arguments are supported:

* `cloud_exadata_infrastructure_id` - (Required) The ID of the ExadataInfrastructure.

* `location` - (Required) The location of the resource.

- - -
* `project` - (Optional) The project to which the resource belongs. If it
is not provided, the provider project is used.

## Attributes Reference

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 comments on commit fc8e5fb

Please sign in to comment.