From 1dec77910e686ca23a6f32d7ab8b49ee436190bf Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 19 Aug 2024 15:49:16 -0700 Subject: [PATCH] Add Resource for V2 SCC Findings Exports to Big Query Organization Config (#11428) (#2687) [upstream:fc331844a15843473edf0704ba5ed1814759b296] Signed-off-by: Modular Magician --- go.mod | 2 +- go.sum | 4 +- ...erv2_organization_scc_big_query_exports.go | 99 +++++++++++++++++++ 3 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_scc_big_query_exports.go diff --git a/go.mod b/go.mod index eafe9373e..7e038d047 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/hcl/v2 v2.20.1 github.com/hashicorp/terraform-json v0.22.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240819191242-4b3d7b6e63b8 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240819224532-c1cd51a19865 github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 04d407bd3..6285a6d20 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c= github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240819191242-4b3d7b6e63b8 h1:l/Ug5J9ApKevxvr7YPSLYfiaXJdW7KdQuMnS+Li17gI= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240819191242-4b3d7b6e63b8/go.mod h1:IkI2dOHongwQ2RIUyitBH4rDJvYBuClAoFCheApCTpY= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240819224532-c1cd51a19865 h1:Zi0cajUAaZ6xSzSAGSBZbBpd590rTY08IPSITHi4c/A= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240819224532-c1cd51a19865/go.mod h1:IkI2dOHongwQ2RIUyitBH4rDJvYBuClAoFCheApCTpY= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_scc_big_query_exports.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_scc_big_query_exports.go new file mode 100644 index 000000000..276920c4e --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_scc_big_query_exports.go @@ -0,0 +1,99 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 securitycenterv2 + +import ( + "reflect" + + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +const SecurityCenterV2OrganizationSccBigQueryExportsAssetType string = "securitycenter.googleapis.com/OrganizationSccBigQueryExports" + +func ResourceConverterSecurityCenterV2OrganizationSccBigQueryExports() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2OrganizationSccBigQueryExportsAssetType, + Convert: GetSecurityCenterV2OrganizationSccBigQueryExportsCaiObject, + } +} + +func GetSecurityCenterV2OrganizationSccBigQueryExportsCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//securitycenter.googleapis.com/organizations/{{organization}}/locations/{{location}}/bigQueryExports/{{big_query_export_id}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetSecurityCenterV2OrganizationSccBigQueryExportsApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: SecurityCenterV2OrganizationSccBigQueryExportsAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/securitycenter/v2/rest", + DiscoveryName: "OrganizationSccBigQueryExports", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetSecurityCenterV2OrganizationSccBigQueryExportsApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + nameProp, err := expandSecurityCenterV2OrganizationSccBigQueryExportsName(d.Get("name"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { + obj["name"] = nameProp + } + descriptionProp, err := expandSecurityCenterV2OrganizationSccBigQueryExportsDescription(d.Get("description"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { + obj["description"] = descriptionProp + } + datasetProp, err := expandSecurityCenterV2OrganizationSccBigQueryExportsDataset(d.Get("dataset"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("dataset"); !tpgresource.IsEmptyValue(reflect.ValueOf(datasetProp)) && (ok || !reflect.DeepEqual(v, datasetProp)) { + obj["dataset"] = datasetProp + } + filterProp, err := expandSecurityCenterV2OrganizationSccBigQueryExportsFilter(d.Get("filter"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("filter"); !tpgresource.IsEmptyValue(reflect.ValueOf(filterProp)) && (ok || !reflect.DeepEqual(v, filterProp)) { + obj["filter"] = filterProp + } + + return obj, nil +} + +func expandSecurityCenterV2OrganizationSccBigQueryExportsName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2OrganizationSccBigQueryExportsDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2OrganizationSccBigQueryExportsDataset(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2OrganizationSccBigQueryExportsFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +}