Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions mmv1/products/observability/OrganizationSettings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2026 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
name: 'OrganizationSettings'
description: Manages Cloud Observability settings for an organization.
min_version: 'beta'
base_url: 'organizations/{{organization}}/locations/{{location}}/settings'
self_link: 'organizations/{{organization}}/locations/{{location}}/settings'

create_url: 'organizations/{{organization}}/locations/{{location}}/settings'
create_verb: 'PATCH'
update_url: 'organizations/{{organization}}/locations/{{location}}/settings'
update_verb: 'PATCH'
update_mask: true
exclude_delete: true
autogen_async: true

custom_code:
pre_create: templates/terraform/pre_create/observability_organization_settings.go.tmpl
import_format:
- 'organizations/{{organization}}/locations/{{location}}/settings'

async:
operation:
timeouts:
insert_minutes: 10
update_minutes: 10
base_url: '{{op_id}}'
result:
resource_inside_response: true

examples:
- name: "observability_organization_settings_basic"
config_path: "templates/terraform/examples/observability_organization_settings_basic.tf.tmpl"
primary_resource_id: "primary"
external_providers: ["time"]
vars:
location: "us"
kms_key_name: "example-key"
test_vars_overrides:
kms_key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us").CryptoKey.Name'
test_env_vars:
org_id: 'ORG_ID'
- name: "observability_organization_settings_basic_global"
config_path: "templates/terraform/examples/observability_organization_settings_basic_global.tf.tmpl"
primary_resource_id: "primary_global"
external_providers: ["time"]
vars:
location: "global"
test_env_vars:
org_id: 'ORG_ID'

parameters:
- name: 'location'
type: String
description: 'The location of the settings.'
url_param_only: true
required: true
immutable: true
- name: 'organization'
type: String
description: 'The organization ID.'
url_param_only: true
required: true
immutable: true

properties:
- name: 'defaultStorageLocation'
type: String
description: 'The default storage location for new resources, e.g. buckets. Only valid for global location.'
- name: 'kmsKeyName'
type: String
description: 'The default Cloud KMS key to use for new resources. Only valid for regional locations.'
- name: 'name'
type: String
description: 'The resource name of the settings.'
output: true
- name: 'serviceAccountId'
type: String
description: 'The service account used by Cloud Observability for this organization.'
output: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data "google_observability_organization_settings" "settings_data" {
provider = "google-beta"
organization = "{{index $.TestEnvVars "org_id"}}"
location = "us"
}

# Add a delay to allow the service account to propagate
resource "time_sleep" "wait_for_sa_propagation" {
create_duration = "90s"
depends_on = [data.google_observability_organization_settings.settings_data]
}

resource "google_kms_crypto_key_iam_member" "iam" {
provider = "google-beta"
crypto_key_id = "{{index $.Vars "kms_key_name"}}"
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:${data.google_observability_organization_settings.settings_data.service_account_id}"
depends_on = [time_sleep.wait_for_sa_propagation]
}

resource "google_observability_organization_settings" "primary" {
provider = "google-beta"
location = "us"
organization = "{{index $.TestEnvVars "org_id"}}"
kms_key_name = "{{index $.Vars "kms_key_name"}}"
depends_on = [google_kms_crypto_key_iam_member.iam]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
data "google_observability_organization_settings" "settings_data" {
provider = "google-beta"
organization = "{{index $.TestEnvVars "org_id"}}"
location = "global"
}

resource "google_observability_organization_settings" "primary_global" {
provider = "google-beta"
location = "global"
organization = "{{index $.TestEnvVars "org_id"}}"
default_storage_location = "us"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var masks []string
if !d.GetRawConfig().GetAttr("default_storage_location").IsNull() {
masks = append(masks, "defaultStorageLocation")
}
if !d.GetRawConfig().GetAttr("kms_key_name").IsNull() {
masks = append(masks, "kmsKeyName")
}

if len(masks) > 0 {
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(masks, ",")})
if err != nil {
return err
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ var handwrittenDatasources = map[string]*schema.Resource{
"google_monitoring_app_engine_service": monitoring.DataSourceMonitoringServiceAppEngine(),
"google_monitoring_uptime_check_ips": monitoring.DataSourceGoogleMonitoringUptimeCheckIps(),
"google_netblock_ip_ranges": resourcemanager.DataSourceGoogleNetblockIpRanges(),
{{- if ne $.TargetVersionName "ga" }}
"google_observability_organization_settings": observability.DataSourceObservabilityOrganizationSettings(),
{{- end }}
"google_oracle_database_autonomous_database": oracledatabase.DataSourceOracleDatabaseAutonomousDatabase(),
"google_oracle_database_autonomous_databases": oracledatabase.DataSourceOracleDatabaseAutonomousDatabases(),
"google_oracle_database_db_nodes": oracledatabase.DataSourceOracleDatabaseDbNodes(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package observability

{{ if ne $.TargetVersionName "ga" -}}
import (
"fmt"

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

func DataSourceObservabilityOrganizationSettings() *schema.Resource {
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceObservabilityOrganizationSettings().Schema)

tpgresource.AddRequiredFieldsToSchema(dsSchema, "organization")
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location")

return &schema.Resource{
Read: dataSourceObservabilityOrganizationSettingsRead,
Schema: dsSchema,
}
}

func dataSourceObservabilityOrganizationSettingsRead(d *schema.ResourceData, meta interface{}) error {
organization := d.Get("organization").(string)
location := d.Get("location").(string)

id := fmt.Sprintf("organizations/%s/locations/%s/settings", organization, location)
d.SetId(id)

err := resourceObservabilityOrganizationSettingsRead(d, meta)
if err != nil {
return nil
}
if d.Id() == "" {
return fmt.Errorf("%s not found", id)
}
return nil
}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package observability_test

{{ if ne $.TargetVersionName "ga" -}}
import (
"testing"

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

func TestAccObservabilityOrganizationSettings_datasource(t *testing.T) {
t.Parallel()

orgId := envvar.GetTestOrgFromEnv(t)

context := map[string]interface{}{
"org_id": orgId,
"location": "us",
}
dataResourceName := "data.google_observability_organization_settings.settings"

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
Steps: []resource.TestStep{
{
Config: testAccObservabilityOrganizationSettings_datasource(context),
Check: acctest.CheckDataSourceStateMatchesResourceState(dataResourceName, "google_observability_organization_settings.settings"),
},
},
})
}
{{- else }}
{{- end }}

{{ if ne $.TargetVersionName "ga" -}}
func testAccObservabilityOrganizationSettings_datasource(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "time_sleep" "wait_for_org" {
create_duration = "60s"
}

resource "google_observability_organization_settings" "settings" {
provider = "google-beta"
organization = "%{org_id}"
location = "global"
default_storage_location = "%{location}"
depends_on = [time_sleep.wait_for_org]
}

data "google_observability_organization_settings" "settings" {
provider = "google-beta"
organization = "%{org_id}"
location = "global"
depends_on = [google_observability_organization_settings.settings]
}
`, context)
}
{{- else }}
{{- end }}
Loading
Loading