From 54b4e1cea1a45a1931cad1b07ffea2d910cc7081 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 3 Aug 2023 18:30:33 +0000 Subject: [PATCH] feat: add the new resource: google_dataform_repository_release_config (#8511) * feat: add the new resource: google_dataform_repository_release_config * Fix `recentScheduledReleaseRecords` name * Fix linting Signed-off-by: Modular Magician --- .changelog/8511.txt | 3 + google-beta/provider/provider.go | 5 +- ...epository_release_config_generated_test.go | 164 ++++ ...urce_dataform_repository_release_config.go | 732 ++++++++++++++++++ ...aform_repository_release_config_sweeper.go | 139 ++++ ...rm_repository_release_config.html.markdown | 247 ++++++ 6 files changed, 1288 insertions(+), 2 deletions(-) create mode 100644 .changelog/8511.txt create mode 100644 google-beta/resource_dataform_repository_release_config_generated_test.go create mode 100644 google-beta/services/dataform/resource_dataform_repository_release_config.go create mode 100644 google-beta/services/dataform/resource_dataform_repository_release_config_sweeper.go create mode 100644 website/docs/r/dataform_repository_release_config.html.markdown diff --git a/.changelog/8511.txt b/.changelog/8511.txt new file mode 100644 index 0000000000..f8a5a0792a --- /dev/null +++ b/.changelog/8511.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +google_dataform_repository_release_config (beta) +``` diff --git a/google-beta/provider/provider.go b/google-beta/provider/provider.go index d057205624..bfef672ee2 100644 --- a/google-beta/provider/provider.go +++ b/google-beta/provider/provider.go @@ -1074,9 +1074,9 @@ func DatasourceMapWithErrors() (map[string]*schema.Resource, error) { }) } -// Generated resources: 361 +// Generated resources: 362 // Generated IAM resources: 234 -// Total generated resources: 595 +// Total generated resources: 596 func ResourceMap() map[string]*schema.Resource { resourceMap, _ := ResourceMapWithErrors() return resourceMap @@ -1361,6 +1361,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) { "google_data_catalog_taxonomy_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), "google_data_catalog_taxonomy_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), "google_dataform_repository": dataform.ResourceDataformRepository(), + "google_dataform_repository_release_config": dataform.ResourceDataformRepositoryReleaseConfig(), "google_data_fusion_instance": datafusion.ResourceDataFusionInstance(), "google_data_fusion_instance_iam_binding": tpgiamresource.ResourceIamBinding(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), "google_data_fusion_instance_iam_member": tpgiamresource.ResourceIamMember(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), diff --git a/google-beta/resource_dataform_repository_release_config_generated_test.go b/google-beta/resource_dataform_repository_release_config_generated_test.go new file mode 100644 index 0000000000..63472a04ca --- /dev/null +++ b/google-beta/resource_dataform_repository_release_config_generated_test.go @@ -0,0 +1,164 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +func TestAccDataformRepositoryReleaseConfig_dataformRepositoryReleaseConfigExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), + CheckDestroy: testAccCheckDataformRepositoryReleaseConfigDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDataformRepositoryReleaseConfig_dataformRepositoryReleaseConfigExample(context), + }, + { + ResourceName: "google_dataform_repository_release_config.release", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "repository"}, + }, + }, + }) +} + +func testAccDataformRepositoryReleaseConfig_dataformRepositoryReleaseConfigExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_sourcerepo_repository" "git_repository" { + provider = google-beta + name = "my/repository%{random_suffix}" +} + +resource "google_secret_manager_secret" "secret" { + provider = google-beta + secret_id = "secret" + + replication { + automatic = true + } +} + +resource "google_secret_manager_secret_version" "secret_version" { + provider = google-beta + secret = google_secret_manager_secret.secret.id + + secret_data = "tf-test-secret-data%{random_suffix}" +} + +resource "google_dataform_repository" "repository" { + provider = google-beta + name = "tf_test_dataform_repository%{random_suffix}" + region = "us-central1" + + git_remote_settings { + url = google_sourcerepo_repository.git_repository.url + default_branch = "main" + authentication_token_secret_version = google_secret_manager_secret_version.secret_version.id + } + + workspace_compilation_overrides { + default_database = "database" + schema_suffix = "_suffix" + table_prefix = "prefix_" + } +} + +resource "google_dataform_repository_release_config" "release" { + provider = google-beta + + project = google_dataform_repository.repository.project + region = google_dataform_repository.repository.region + repository = google_dataform_repository.repository.name + + name = "tf_test_my_release%{random_suffix}" + git_commitish = "main" + cron_schedule = "0 7 * * *" + time_zone = "America/New_York" + + code_compilation_config { + default_database = "gcp-example-project" + default_schema = "example-dataset" + default_location = "us-central1" + assertion_schema = "example-assertion-dataset" + database_suffix = "" + schema_suffix = "" + table_prefix = "" + vars = { + var1 = "value" + } + } +} +`, context) +} + +func testAccCheckDataformRepositoryReleaseConfigDestroyProducer(t *testing.T) func(s *terraform.State) error { + return func(s *terraform.State) error { + for name, rs := range s.RootModule().Resources { + if rs.Type != "google_dataform_repository_release_config" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := acctest.GoogleProviderConfig(t) + + url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{DataformBasePath}}projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}") + if err != nil { + return err + } + + billingProject := "" + + if config.BillingProject != "" { + billingProject = config.BillingProject + } + + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: billingProject, + RawURL: url, + UserAgent: config.UserAgent, + }) + if err == nil { + return fmt.Errorf("DataformRepositoryReleaseConfig still exists at %s", url) + } + } + + return nil + } +} diff --git a/google-beta/services/dataform/resource_dataform_repository_release_config.go b/google-beta/services/dataform/resource_dataform_repository_release_config.go new file mode 100644 index 0000000000..5c26e57004 --- /dev/null +++ b/google-beta/services/dataform/resource_dataform_repository_release_config.go @@ -0,0 +1,732 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package dataform + +import ( + "fmt" + "log" + "reflect" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +func ResourceDataformRepositoryReleaseConfig() *schema.Resource { + return &schema.Resource{ + Create: resourceDataformRepositoryReleaseConfigCreate, + Read: resourceDataformRepositoryReleaseConfigRead, + Update: resourceDataformRepositoryReleaseConfigUpdate, + Delete: resourceDataformRepositoryReleaseConfigDelete, + + Importer: &schema.ResourceImporter{ + State: resourceDataformRepositoryReleaseConfigImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(20 * time.Minute), + Update: schema.DefaultTimeout(20 * time.Minute), + Delete: schema.DefaultTimeout(20 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "git_commitish": { + Type: schema.TypeString, + Required: true, + Description: `Git commit/tag/branch name at which the repository should be compiled. Must exist in the remote repository.`, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The release's name.`, + }, + "code_compilation_config": { + Type: schema.TypeList, + Optional: true, + Description: `Optional. If set, fields of codeCompilationConfig override the default compilation settings that are specified in dataform.json.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "assertion_schema": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The default schema (BigQuery dataset ID) for assertions.`, + }, + "database_suffix": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The suffix that should be appended to all database (Google Cloud project ID) names.`, + }, + "default_database": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The default database (Google Cloud project ID).`, + }, + "default_location": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The default BigQuery location to use. Defaults to "US". +See the BigQuery docs for a full list of locations: https://cloud.google.com/bigquery/docs/locations.`, + }, + "default_schema": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The default schema (BigQuery dataset ID).`, + }, + "schema_suffix": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The suffix that should be appended to all schema (BigQuery dataset ID) names.`, + }, + "table_prefix": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. The prefix that should be prepended to all table names.`, + }, + "vars": { + Type: schema.TypeMap, + Optional: true, + Description: `Optional. User-defined variables that are made available to project code during compilation. +An object containing a list of "key": value pairs. +Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + "cron_schedule": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. Optional schedule (in cron format) for automatic creation of compilation results.`, + }, + "region": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `A reference to the region`, + }, + "repository": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `A reference to the Dataform repository`, + }, + "time_zone": { + Type: schema.TypeString, + Optional: true, + Description: `Optional. Specifies the time zone to be used when interpreting cronSchedule. Must be a time zone name from the time zone database (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). If left unspecified, the default is UTC.`, + }, + "recent_scheduled_release_records": { + Type: schema.TypeList, + Computed: true, + Description: `Records of the 10 most recent scheduled release attempts, ordered in in descending order of releaseTime. Updated whenever automatic creation of a compilation result is triggered by cronSchedule.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compilation_result": { + Type: schema.TypeString, + Computed: true, + Description: `The name of the created compilation result, if one was successfully created. Must be in the format projects/*/locations/*/repositories/*/compilationResults/*.`, + }, + "error_status": { + Type: schema.TypeList, + Computed: true, + Description: `The error status encountered upon this attempt to create the compilation result, if the attempt was unsuccessful.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "code": { + Type: schema.TypeInt, + Computed: true, + Description: `The status code, which should be an enum value of google.rpc.Code.`, + }, + "message": { + Type: schema.TypeString, + Computed: true, + Description: `A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.`, + }, + }, + }, + }, + "release_time": { + Type: schema.TypeString, + Computed: true, + Description: `The timestamp of this release attempt.`, + }, + }, + }, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func resourceDataformRepositoryReleaseConfigCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + obj := make(map[string]interface{}) + nameProp, err := expandDataformRepositoryReleaseConfigName(d.Get("name"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { + obj["name"] = nameProp + } + gitCommitishProp, err := expandDataformRepositoryReleaseConfigGitCommitish(d.Get("git_commitish"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("git_commitish"); !tpgresource.IsEmptyValue(reflect.ValueOf(gitCommitishProp)) && (ok || !reflect.DeepEqual(v, gitCommitishProp)) { + obj["gitCommitish"] = gitCommitishProp + } + cronScheduleProp, err := expandDataformRepositoryReleaseConfigCronSchedule(d.Get("cron_schedule"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("cron_schedule"); !tpgresource.IsEmptyValue(reflect.ValueOf(cronScheduleProp)) && (ok || !reflect.DeepEqual(v, cronScheduleProp)) { + obj["cronSchedule"] = cronScheduleProp + } + timeZoneProp, err := expandDataformRepositoryReleaseConfigTimeZone(d.Get("time_zone"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("time_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(timeZoneProp)) && (ok || !reflect.DeepEqual(v, timeZoneProp)) { + obj["timeZone"] = timeZoneProp + } + codeCompilationConfigProp, err := expandDataformRepositoryReleaseConfigCodeCompilationConfig(d.Get("code_compilation_config"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("code_compilation_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(codeCompilationConfigProp)) && (ok || !reflect.DeepEqual(v, codeCompilationConfigProp)) { + obj["codeCompilationConfig"] = codeCompilationConfigProp + } + + url, err := tpgresource.ReplaceVars(d, config, "{{DataformBasePath}}projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs?releaseConfigId={{name}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new RepositoryReleaseConfig: %#v", obj) + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for RepositoryReleaseConfig: %s", err) + } + billingProject = project + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "POST", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutCreate), + }) + if err != nil { + return fmt.Errorf("Error creating RepositoryReleaseConfig: %s", err) + } + + // Store the ID now + id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + log.Printf("[DEBUG] Finished creating RepositoryReleaseConfig %q: %#v", d.Id(), res) + + return resourceDataformRepositoryReleaseConfigRead(d, meta) +} + +func resourceDataformRepositoryReleaseConfigRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + url, err := tpgresource.ReplaceVars(d, config, "{{DataformBasePath}}projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}") + if err != nil { + return err + } + + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for RepositoryReleaseConfig: %s", err) + } + billingProject = project + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + }) + if err != nil { + return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataformRepositoryReleaseConfig %q", d.Id())) + } + + if err := d.Set("project", project); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + + if err := d.Set("name", flattenDataformRepositoryReleaseConfigName(res["name"], d, config)); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + if err := d.Set("git_commitish", flattenDataformRepositoryReleaseConfigGitCommitish(res["gitCommitish"], d, config)); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + if err := d.Set("cron_schedule", flattenDataformRepositoryReleaseConfigCronSchedule(res["cronSchedule"], d, config)); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + if err := d.Set("time_zone", flattenDataformRepositoryReleaseConfigTimeZone(res["timeZone"], d, config)); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + if err := d.Set("code_compilation_config", flattenDataformRepositoryReleaseConfigCodeCompilationConfig(res["codeCompilationConfig"], d, config)); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + if err := d.Set("recent_scheduled_release_records", flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecords(res["recentScheduledReleaseRecords"], d, config)); err != nil { + return fmt.Errorf("Error reading RepositoryReleaseConfig: %s", err) + } + + return nil +} + +func resourceDataformRepositoryReleaseConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for RepositoryReleaseConfig: %s", err) + } + billingProject = project + + obj := make(map[string]interface{}) + gitCommitishProp, err := expandDataformRepositoryReleaseConfigGitCommitish(d.Get("git_commitish"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("git_commitish"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, gitCommitishProp)) { + obj["gitCommitish"] = gitCommitishProp + } + cronScheduleProp, err := expandDataformRepositoryReleaseConfigCronSchedule(d.Get("cron_schedule"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("cron_schedule"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, cronScheduleProp)) { + obj["cronSchedule"] = cronScheduleProp + } + timeZoneProp, err := expandDataformRepositoryReleaseConfigTimeZone(d.Get("time_zone"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("time_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, timeZoneProp)) { + obj["timeZone"] = timeZoneProp + } + codeCompilationConfigProp, err := expandDataformRepositoryReleaseConfigCodeCompilationConfig(d.Get("code_compilation_config"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("code_compilation_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, codeCompilationConfigProp)) { + obj["codeCompilationConfig"] = codeCompilationConfigProp + } + + url, err := tpgresource.ReplaceVars(d, config, "{{DataformBasePath}}projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating RepositoryReleaseConfig %q: %#v", d.Id(), obj) + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "PATCH", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutUpdate), + }) + + if err != nil { + return fmt.Errorf("Error updating RepositoryReleaseConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RepositoryReleaseConfig %q: %#v", d.Id(), res) + } + + return resourceDataformRepositoryReleaseConfigRead(d, meta) +} + +func resourceDataformRepositoryReleaseConfigDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for RepositoryReleaseConfig: %s", err) + } + billingProject = project + + url, err := tpgresource.ReplaceVars(d, config, "{{DataformBasePath}}projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}") + if err != nil { + return err + } + + var obj map[string]interface{} + log.Printf("[DEBUG] Deleting RepositoryReleaseConfig %q", d.Id()) + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "DELETE", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutDelete), + }) + if err != nil { + return transport_tpg.HandleNotFoundError(err, d, "RepositoryReleaseConfig") + } + + log.Printf("[DEBUG] Finished deleting RepositoryReleaseConfig %q: %#v", d.Id(), res) + return nil +} + +func resourceDataformRepositoryReleaseConfigImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*transport_tpg.Config) + if err := tpgresource.ParseImportId([]string{ + "projects/(?P[^/]+)/locations/(?P[^/]+)/repositories/(?P[^/]+)/releaseConfigs/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil +} + +func flattenDataformRepositoryReleaseConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return v + } + return tpgresource.NameFromSelfLinkStateFunc(v) +} + +func flattenDataformRepositoryReleaseConfigGitCommitish(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCronSchedule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigTimeZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["default_database"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigDefaultDatabase(original["defaultDatabase"], d, config) + transformed["default_schema"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigDefaultSchema(original["defaultSchema"], d, config) + transformed["default_location"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigDefaultLocation(original["defaultLocation"], d, config) + transformed["assertion_schema"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigAssertionSchema(original["assertionSchema"], d, config) + transformed["vars"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigVars(original["vars"], d, config) + transformed["database_suffix"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigDatabaseSuffix(original["databaseSuffix"], d, config) + transformed["schema_suffix"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigSchemaSuffix(original["schemaSuffix"], d, config) + transformed["table_prefix"] = + flattenDataformRepositoryReleaseConfigCodeCompilationConfigTablePrefix(original["tablePrefix"], d, config) + return []interface{}{transformed} +} +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigDefaultDatabase(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigDefaultSchema(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigDefaultLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigAssertionSchema(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigVars(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigDatabaseSuffix(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigSchemaSuffix(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigCodeCompilationConfigTablePrefix(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecords(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return v + } + l := v.([]interface{}) + transformed := make([]interface{}, 0, len(l)) + for _, raw := range l { + original := raw.(map[string]interface{}) + if len(original) < 1 { + // Do not include empty json objects coming back from the api + continue + } + transformed = append(transformed, map[string]interface{}{ + "release_time": flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsReleaseTime(original["releaseTime"], d, config), + "compilation_result": flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsCompilationResult(original["compilationResult"], d, config), + "error_status": flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsErrorStatus(original["errorStatus"], d, config), + }) + } + return transformed +} +func flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsReleaseTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsCompilationResult(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsErrorStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["code"] = + flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsErrorStatusCode(original["code"], d, config) + transformed["message"] = + flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsErrorStatusMessage(original["message"], d, config) + return []interface{}{transformed} +} +func flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsErrorStatusCode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { + return intVal + } + } + + // number values are represented as float64 + if floatVal, ok := v.(float64); ok { + intVal := int(floatVal) + return intVal + } + + return v // let terraform core handle it otherwise +} + +func flattenDataformRepositoryReleaseConfigRecentScheduledReleaseRecordsErrorStatusMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func expandDataformRepositoryReleaseConfigName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigGitCommitish(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCronSchedule(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigTimeZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedDefaultDatabase, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigDefaultDatabase(original["default_database"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDefaultDatabase); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["defaultDatabase"] = transformedDefaultDatabase + } + + transformedDefaultSchema, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigDefaultSchema(original["default_schema"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDefaultSchema); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["defaultSchema"] = transformedDefaultSchema + } + + transformedDefaultLocation, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigDefaultLocation(original["default_location"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDefaultLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["defaultLocation"] = transformedDefaultLocation + } + + transformedAssertionSchema, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigAssertionSchema(original["assertion_schema"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAssertionSchema); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["assertionSchema"] = transformedAssertionSchema + } + + transformedVars, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigVars(original["vars"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedVars); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["vars"] = transformedVars + } + + transformedDatabaseSuffix, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigDatabaseSuffix(original["database_suffix"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDatabaseSuffix); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["databaseSuffix"] = transformedDatabaseSuffix + } + + transformedSchemaSuffix, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigSchemaSuffix(original["schema_suffix"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSchemaSuffix); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["schemaSuffix"] = transformedSchemaSuffix + } + + transformedTablePrefix, err := expandDataformRepositoryReleaseConfigCodeCompilationConfigTablePrefix(original["table_prefix"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedTablePrefix); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["tablePrefix"] = transformedTablePrefix + } + + return transformed, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigDefaultDatabase(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigDefaultSchema(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigDefaultLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigAssertionSchema(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigVars(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigDatabaseSuffix(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigSchemaSuffix(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataformRepositoryReleaseConfigCodeCompilationConfigTablePrefix(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/google-beta/services/dataform/resource_dataform_repository_release_config_sweeper.go b/google-beta/services/dataform/resource_dataform_repository_release_config_sweeper.go new file mode 100644 index 0000000000..18b3af8c55 --- /dev/null +++ b/google-beta/services/dataform/resource_dataform_repository_release_config_sweeper.go @@ -0,0 +1,139 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package dataform + +import ( + "context" + "log" + "strings" + "testing" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +func init() { + sweeper.AddTestSweepers("DataformRepositoryReleaseConfig", testSweepDataformRepositoryReleaseConfig) +} + +// At the time of writing, the CI only passes us-central1 as the region +func testSweepDataformRepositoryReleaseConfig(region string) error { + resourceName := "DataformRepositoryReleaseConfig" + log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) + + config, err := sweeper.SharedConfigForRegion(region) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) + return err + } + + err = config.LoadAndValidate(context.Background()) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) + return err + } + + t := &testing.T{} + billingId := envvar.GetTestBillingAccountFromEnv(t) + + // Setup variables to replace in list template + d := &tpgresource.ResourceDataMock{ + FieldsInSchema: map[string]interface{}{ + "project": config.Project, + "region": region, + "location": region, + "zone": "-", + "billing_account": billingId, + }, + } + + listTemplate := strings.Split("https://dataform.googleapis.com/v1beta1/projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs", "?")[0] + listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) + return nil + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: config.Project, + RawURL: listUrl, + UserAgent: config.UserAgent, + }) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) + return nil + } + + resourceList, ok := res["repositoryReleaseConfigs"] + if !ok { + log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") + return nil + } + + rl := resourceList.([]interface{}) + + log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) + // Keep count of items that aren't sweepable for logging. + nonPrefixCount := 0 + for _, ri := range rl { + obj := ri.(map[string]interface{}) + if obj["name"] == nil { + log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) + return nil + } + + name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) + // Skip resources that shouldn't be sweeped + if !sweeper.IsSweepableTestResource(name) { + nonPrefixCount++ + continue + } + + deleteTemplate := "https://dataform.googleapis.com/v1beta1/projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}" + deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) + return nil + } + deleteUrl = deleteUrl + name + + // Don't wait on operations as we may have a lot to delete + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "DELETE", + Project: config.Project, + RawURL: deleteUrl, + UserAgent: config.UserAgent, + }) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) + } else { + log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) + } + } + + if nonPrefixCount > 0 { + log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) + } + + return nil +} diff --git a/website/docs/r/dataform_repository_release_config.html.markdown b/website/docs/r/dataform_repository_release_config.html.markdown new file mode 100644 index 0000000000..b662a0fc6a --- /dev/null +++ b/website/docs/r/dataform_repository_release_config.html.markdown @@ -0,0 +1,247 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in +# .github/CONTRIBUTING.md. +# +# ---------------------------------------------------------------------------- +subcategory: "Dataform" +description: |- + A resource represents a Dataform release configuration +--- + +# google\_dataform\_repository\_release\_config + +A resource represents a Dataform release configuration + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + +To get more information about RepositoryReleaseConfig, see: + +* [API documentation](https://cloud.google.com/dataform/reference/rest/v1beta1/projects.locations.repositories.releaseConfigs) +* How-to Guides + * [Official Documentation](https://cloud.google.com/dataform/docs/release-configurations) + + +## Example Usage - Dataform Repository Release Config + + +```hcl +resource "google_sourcerepo_repository" "git_repository" { + provider = google-beta + name = "my/repository" +} + +resource "google_secret_manager_secret" "secret" { + provider = google-beta + secret_id = "secret" + + replication { + automatic = true + } +} + +resource "google_secret_manager_secret_version" "secret_version" { + provider = google-beta + secret = google_secret_manager_secret.secret.id + + secret_data = "secret-data" +} + +resource "google_dataform_repository" "repository" { + provider = google-beta + name = "dataform_repository" + region = "us-central1" + + git_remote_settings { + url = google_sourcerepo_repository.git_repository.url + default_branch = "main" + authentication_token_secret_version = google_secret_manager_secret_version.secret_version.id + } + + workspace_compilation_overrides { + default_database = "database" + schema_suffix = "_suffix" + table_prefix = "prefix_" + } +} + +resource "google_dataform_repository_release_config" "release" { + provider = google-beta + + project = google_dataform_repository.repository.project + region = google_dataform_repository.repository.region + repository = google_dataform_repository.repository.name + + name = "my_release" + git_commitish = "main" + cron_schedule = "0 7 * * *" + time_zone = "America/New_York" + + code_compilation_config { + default_database = "gcp-example-project" + default_schema = "example-dataset" + default_location = "us-central1" + assertion_schema = "example-assertion-dataset" + database_suffix = "" + schema_suffix = "" + table_prefix = "" + vars = { + var1 = "value" + } + } +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `name` - + (Required) + The release's name. + +* `git_commitish` - + (Required) + Git commit/tag/branch name at which the repository should be compiled. Must exist in the remote repository. + + +- - - + + +* `cron_schedule` - + (Optional) + Optional. Optional schedule (in cron format) for automatic creation of compilation results. + +* `time_zone` - + (Optional) + Optional. Specifies the time zone to be used when interpreting cronSchedule. Must be a time zone name from the time zone database (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). If left unspecified, the default is UTC. + +* `code_compilation_config` - + (Optional) + Optional. If set, fields of codeCompilationConfig override the default compilation settings that are specified in dataform.json. + Structure is [documented below](#nested_code_compilation_config). + +* `region` - + (Optional) + A reference to the region + +* `repository` - + (Optional) + A reference to the Dataform repository + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + + +The `code_compilation_config` block supports: + +* `default_database` - + (Optional) + Optional. The default database (Google Cloud project ID). + +* `default_schema` - + (Optional) + Optional. The default schema (BigQuery dataset ID). + +* `default_location` - + (Optional) + Optional. The default BigQuery location to use. Defaults to "US". + See the BigQuery docs for a full list of locations: https://cloud.google.com/bigquery/docs/locations. + +* `assertion_schema` - + (Optional) + Optional. The default schema (BigQuery dataset ID) for assertions. + +* `vars` - + (Optional) + Optional. User-defined variables that are made available to project code during compilation. + An object containing a list of "key": value pairs. + Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. + +* `database_suffix` - + (Optional) + Optional. The suffix that should be appended to all database (Google Cloud project ID) names. + +* `schema_suffix` - + (Optional) + Optional. The suffix that should be appended to all schema (BigQuery dataset ID) names. + +* `table_prefix` - + (Optional) + Optional. The prefix that should be prepended to all table names. + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}` + +* `recent_scheduled_release_records` - + Records of the 10 most recent scheduled release attempts, ordered in in descending order of releaseTime. Updated whenever automatic creation of a compilation result is triggered by cronSchedule. + Structure is [documented below](#nested_recent_scheduled_release_records). + + +The `recent_scheduled_release_records` block contains: + +* `release_time` - + (Output) + The timestamp of this release attempt. + +* `compilation_result` - + (Output) + The name of the created compilation result, if one was successfully created. Must be in the format projects/*/locations/*/repositories/*/compilationResults/*. + +* `error_status` - + (Output) + The error status encountered upon this attempt to create the compilation result, if the attempt was unsuccessful. + Structure is [documented below](#nested_error_status). + + +The `error_status` block contains: + +* `code` - + (Output) + The status code, which should be an enum value of google.rpc.Code. + +* `message` - + (Output) + A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. + +## Timeouts + +This resource provides the following +[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: + +- `create` - Default is 20 minutes. +- `update` - Default is 20 minutes. +- `delete` - Default is 20 minutes. + +## Import + + +RepositoryReleaseConfig can be imported using any of these accepted formats: + +``` +$ terraform import google_dataform_repository_release_config.default projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}} +$ terraform import google_dataform_repository_release_config.default {{project}}/{{region}}/{{repository}}/{{name}} +$ terraform import google_dataform_repository_release_config.default {{region}}/{{repository}}/{{name}} +$ terraform import google_dataform_repository_release_config.default {{repository}}/{{name}} +``` + +## User Project Overrides + +This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).