diff --git a/go.mod b/go.mod index ed241b31f..0fbe7ed89 100644 --- a/go.mod +++ b/go.mod @@ -11,13 +11,13 @@ 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.20240809161150-306a821f7d63 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240809171910-b44d6e9b3cea github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 github.com/zclconf/go-cty v1.14.4 go.uber.org/zap v1.21.0 - google.golang.org/api v0.189.0 + google.golang.org/api v0.190.0 ) require github.com/spf13/cobra v1.7.0 @@ -26,13 +26,14 @@ require ( bitbucket.org/creachadair/stringset v0.0.11 // indirect cel.dev/expr v0.15.0 // indirect cloud.google.com/go v0.115.0 // indirect - cloud.google.com/go/auth v0.7.2 // indirect + cloud.google.com/go/auth v0.7.3 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect - cloud.google.com/go/bigtable v1.26.0 // indirect + cloud.google.com/go/bigtable v1.27.2-0.20240730134218-123c88616251 // indirect cloud.google.com/go/compute/metadata v0.5.0 // indirect - cloud.google.com/go/iam v1.1.10 // indirect - cloud.google.com/go/longrunning v0.5.9 // indirect - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.68.0 // indirect + cloud.google.com/go/iam v1.1.12 // indirect + cloud.google.com/go/longrunning v0.5.11 // indirect + cloud.google.com/go/monitoring v1.20.3 // indirect + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.70.0 // indirect github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect @@ -55,7 +56,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cpy v0.0.0-20211218193943-a9c933c06932 // indirect - github.com/google/s2a-go v0.1.7 // indirect + github.com/google/s2a-go v0.1.8 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.13.0 // indirect @@ -100,6 +101,8 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/sdk v1.24.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect @@ -115,9 +118,9 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240722135656-d784300faade // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240722135656-d784300faade // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect + google.golang.org/genproto v0.0.0-20240730163845-b1a4ccb954bf // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect google.golang.org/grpc v1.64.1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 8f293c041..794be213d 100644 --- a/go.sum +++ b/go.sum @@ -5,23 +5,25 @@ cel.dev/expr v0.15.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= -cloud.google.com/go/auth v0.7.2 h1:uiha352VrCDMXg+yoBtaD0tUF4Kv9vrtrWPYXwutnDE= -cloud.google.com/go/auth v0.7.2/go.mod h1:VEc4p5NNxycWQTMQEDQF0bd6aTMb6VgYDXEwiJJQAbs= +cloud.google.com/go/auth v0.7.3 h1:98Vr+5jMaCZ5NZk6e/uBgf60phTk/XN84r8QEWB9yjY= +cloud.google.com/go/auth v0.7.3/go.mod h1:HJtWUx1P5eqjy/f6Iq5KeytNpbAcGolPhOgyop2LlzA= cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI= cloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I= -cloud.google.com/go/bigtable v1.26.0 h1:Gxk6UA21+3uz6QUm8d9wpxHznf6hr29HkwqWekfZ8Rs= -cloud.google.com/go/bigtable v1.26.0/go.mod h1:nqDsH+YoPA1oTmCEfWfsUGYV7NDIaufhwJgs+eh5bGo= +cloud.google.com/go/bigtable v1.27.2-0.20240730134218-123c88616251 h1:OF+V7OrVPhsXy++iTHewE4VD1kv6ikWQJbRIiq1/Kjc= +cloud.google.com/go/bigtable v1.27.2-0.20240730134218-123c88616251/go.mod h1:avmXcmxVbLJAo9moICRYMgDyTTPoV0MA0lHKnyqV4fQ= cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= -cloud.google.com/go/iam v1.1.10 h1:ZSAr64oEhQSClwBL670MsJAW5/RLiC6kfw3Bqmd5ZDI= -cloud.google.com/go/iam v1.1.10/go.mod h1:iEgMq62sg8zx446GCaijmA2Miwg5o3UbO+nI47WHJps= -cloud.google.com/go/longrunning v0.5.9 h1:haH9pAuXdPAMqHvzX0zlWQigXT7B0+CL4/2nXXdBo5k= -cloud.google.com/go/longrunning v0.5.9/go.mod h1:HD+0l9/OOW0za6UWdKJtXoFAX/BGg/3Wj8p10NeWF7c= +cloud.google.com/go/iam v1.1.12 h1:JixGLimRrNGcxvJEQ8+clfLxPlbeZA6MuRJ+qJNQ5Xw= +cloud.google.com/go/iam v1.1.12/go.mod h1:9LDX8J7dN5YRyzVHxwQzrQs9opFFqn0Mxs9nAeB+Hhg= +cloud.google.com/go/longrunning v0.5.11 h1:Havn1kGjz3whCfoD8dxMLP73Ph5w+ODyZB9RUsDxtGk= +cloud.google.com/go/longrunning v0.5.11/go.mod h1:rDn7//lmlfWV1Dx6IB4RatCPenTwwmqXuiP0/RgoEO4= +cloud.google.com/go/monitoring v1.20.3 h1:v/7MXFxYrhXLEZ9sSfwXdlTLLB/xrU7xTyYjY5acynQ= +cloud.google.com/go/monitoring v1.20.3/go.mod h1:GPIVIdNznIdGqEjtRKQWTLcUeRnPjZW85szouimiczU= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.68.0 h1:LIPIYi4hy7ttUSrziY/TYwMDuEvvV593n80kRmz6nZ4= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.68.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.70.0 h1:dqqxHZYK0tlzViFqAbKzMIkfboQVWYN1CTEM2sjBtmQ= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.70.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= @@ -130,8 +132,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cpy v0.0.0-20211218193943-a9c933c06932 h1:5/4TSDzpDnHQ8rKEEQBjRlYx77mHOvXu08oGchxej7o= github.com/google/go-cpy v0.0.0-20211218193943-a9c933c06932/go.mod h1:cC6EdPbj/17GFCPDK39NRarlMI+kt+O60S12cNB5J9Y= -github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= -github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM= +github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -188,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.20240809161150-306a821f7d63 h1:Ge1Ba5JEjTyAegaNPD378/Q6rsY9yUw2Ol7ugGco3rw= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240809161150-306a821f7d63/go.mod h1:ItwW2jftNIDP6Iqt0KAiZ2jew7+81E0MwxeQxMDmI8I= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240809171910-b44d6e9b3cea h1:ZaXOngMQO71xTTVsHRVmWF/PbZ7v5QrKRqBelFGfvkg= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240809171910-b44d6e9b3cea/go.mod h1:mbLHS7zKRfkaFt9qpT/cmmwnrB5NSdnz1jpDoAZd6A0= 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= @@ -306,6 +308,8 @@ go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGX go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9osbiBrJrz/w8= +go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -418,8 +422,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.189.0 h1:equMo30LypAkdkLMBqfeIqtyAnlyig1JSZArl4XPwdI= -google.golang.org/api v0.189.0/go.mod h1:FLWGJKb0hb+pU2j+rJqwbnsF+ym+fQs73rbJ+KAUgy8= +google.golang.org/api v0.190.0 h1:ASM+IhLY1zljNdLu19W1jTmU6A+gMk6M46Wlur61s+Q= +google.golang.org/api v0.190.0/go.mod h1:QIr6I9iedBLnfqoD6L6Vze1UvS5Hzj5r2aUBOaZnLHo= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= @@ -428,12 +432,12 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20240722135656-d784300faade h1:lKFsS7wpngDgSCeFn7MoLy+wBDQZ1UQIJD4UNM1Qvkg= -google.golang.org/genproto v0.0.0-20240722135656-d784300faade/go.mod h1:FfBgJBJg9GcpPvKIuHSZ/aE1g2ecGL74upMzGZjiGEY= -google.golang.org/genproto/googleapis/api v0.0.0-20240722135656-d784300faade h1:WxZOF2yayUHpHSbUE6NMzumUzBxYc3YGwo0YHnbzsJY= -google.golang.org/genproto/googleapis/api v0.0.0-20240722135656-d784300faade/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade h1:oCRSWfwGXQsqlVdErcyTt4A93Y8fo0/9D4b1gnI++qo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto v0.0.0-20240730163845-b1a4ccb954bf h1:OqdXDEakZCVtDiZTjcxfwbHPCT11ycCEsTKesBVKvyY= +google.golang.org/genproto v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:mCr1K1c8kX+1iSBREvU3Juo11CB+QOEWxbRS01wWl5M= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f h1:b1Ln/PG8orm0SsBbHZWke8dDp2lrCD4jSmfglFpTZbk= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/tfplan2cai/converters/google/resources/resource_converters.go b/tfplan2cai/converters/google/resources/resource_converters.go index a8af2bc29..f2a2784da 100644 --- a/tfplan2cai/converters/google/resources/resource_converters.go +++ b/tfplan2cai/converters/google/resources/resource_converters.go @@ -57,6 +57,7 @@ import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/secretmanager" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/securesourcemanager" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/securitycenter" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/securitycenterv2" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/servicemanagement" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/spanner" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/sql" @@ -371,6 +372,9 @@ func ResourceConverters() map[string][]cai.ResourceConverter { "google_scc_source_iam_policy": {securitycenter.ResourceConverterSecurityCenterSourceIamPolicy()}, "google_scc_source_iam_binding": {securitycenter.ResourceConverterSecurityCenterSourceIamBinding()}, "google_scc_source_iam_member": {securitycenter.ResourceConverterSecurityCenterSourceIamMember()}, + "google_scc_v2_organization_source_iam_policy": {securitycenterv2.ResourceConverterSecurityCenterV2OrganizationSourceIamPolicy()}, + "google_scc_v2_organization_source_iam_binding": {securitycenterv2.ResourceConverterSecurityCenterV2OrganizationSourceIamBinding()}, + "google_scc_v2_organization_source_iam_member": {securitycenterv2.ResourceConverterSecurityCenterV2OrganizationSourceIamMember()}, "google_endpoints_service_iam_policy": {servicemanagement.ResourceConverterServiceManagementServiceIamPolicy()}, "google_endpoints_service_iam_binding": {servicemanagement.ResourceConverterServiceManagementServiceIamBinding()}, "google_endpoints_service_iam_member": {servicemanagement.ResourceConverterServiceManagementServiceIamMember()}, diff --git a/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go b/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go index 25171565d..ff2bacd4c 100644 --- a/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go +++ b/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go @@ -149,6 +149,13 @@ func expandCloudRunV2JobBinaryAuthorization(v interface{}, d tpgresource.Terrafo transformed["useDefault"] = transformedUseDefault } + transformedPolicy, err := expandCloudRunV2JobBinaryAuthorizationPolicy(original["policy"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPolicy); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["policy"] = transformedPolicy + } + return transformed, nil } @@ -160,6 +167,10 @@ func expandCloudRunV2JobBinaryAuthorizationUseDefault(v interface{}, d tpgresour return v, nil } +func expandCloudRunV2JobBinaryAuthorizationPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandCloudRunV2JobStartExecutionToken(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_service.go b/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_service.go index 5334fdccc..8cce06827 100644 --- a/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_service.go +++ b/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_service.go @@ -181,6 +181,13 @@ func expandCloudRunV2ServiceBinaryAuthorization(v interface{}, d tpgresource.Ter transformed["useDefault"] = transformedUseDefault } + transformedPolicy, err := expandCloudRunV2ServiceBinaryAuthorizationPolicy(original["policy"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPolicy); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["policy"] = transformedPolicy + } + return transformed, nil } @@ -192,6 +199,10 @@ func expandCloudRunV2ServiceBinaryAuthorizationUseDefault(v interface{}, d tpgre return v, nil } +func expandCloudRunV2ServiceBinaryAuthorizationPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandCloudRunV2ServiceCustomAudiences(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/tfplan2cai/converters/google/resources/services/compute/compute_instance_helpers.go b/tfplan2cai/converters/google/resources/services/compute/compute_instance_helpers.go index 2c448fa36..61f7b5fe7 100644 --- a/tfplan2cai/converters/google/resources/services/compute/compute_instance_helpers.go +++ b/tfplan2cai/converters/google/resources/services/compute/compute_instance_helpers.go @@ -49,15 +49,28 @@ func expandAliasIpRanges(ranges []interface{}) []*compute.AliasIpRange { return ipRanges } -func flattenAliasIpRange(ranges []*compute.AliasIpRange) []map[string]interface{} { - rangesSchema := make([]map[string]interface{}, 0, len(ranges)) +func flattenAliasIpRange(d *schema.ResourceData, ranges []*compute.AliasIpRange, i int) []map[string]interface{} { + prefix := fmt.Sprintf("network_interface.%d", i) + + configData := []map[string]interface{}{} + for _, item := range d.Get(prefix + ".alias_ip_range").([]interface{}) { + configData = append(configData, item.(map[string]interface{})) + } + + apiData := make([]map[string]interface{}, 0, len(ranges)) for _, ipRange := range ranges { - rangesSchema = append(rangesSchema, map[string]interface{}{ + apiData = append(apiData, map[string]interface{}{ "ip_cidr_range": ipRange.IpCidrRange, "subnetwork_range_name": ipRange.SubnetworkRangeName, }) } - return rangesSchema + + //permadiff fix + sorted, err := tpgresource.SortMapsByConfigOrder(configData, apiData, "ip_cidr_range") + if err != nil { + return apiData + } + return sorted } func expandScheduling(v interface{}) (*compute.Scheduling, error) { @@ -374,7 +387,7 @@ func flattenNetworkInterfaces(d *schema.ResourceData, config *transport_tpg.Conf "subnetwork": tpgresource.ConvertSelfLinkToV1(iface.Subnetwork), "subnetwork_project": subnet.Project, "access_config": ac, - "alias_ip_range": flattenAliasIpRange(iface.AliasIpRanges), + "alias_ip_range": flattenAliasIpRange(d, iface.AliasIpRanges, i), "nic_type": iface.NicType, "stack_type": iface.StackType, "ipv6_access_config": flattenIpv6AccessConfigs(iface.Ipv6AccessConfigs), diff --git a/tfplan2cai/converters/google/resources/services/compute/compute_region_target_https_proxy.go b/tfplan2cai/converters/google/resources/services/compute/compute_region_target_https_proxy.go index 97c6678f6..fa2b6fda8 100644 --- a/tfplan2cai/converters/google/resources/services/compute/compute_region_target_https_proxy.go +++ b/tfplan2cai/converters/google/resources/services/compute/compute_region_target_https_proxy.go @@ -120,6 +120,14 @@ func resourceComputeRegionTargetHttpsProxyEncoder(d tpgresource.TerraformResourc obj["sslCertificates"] = obj["certificateManagerCertificates"] delete(obj, "certificateManagerCertificates") } + + // Send null if serverTlsPolicy is not set. Without this, Terraform would not send any value for `serverTlsPolicy` + // in the "PATCH" payload so if you were to remove a server TLS policy from a target HTTPS proxy, it would NOT remove + // the association. + if _, ok := obj["serverTlsPolicy"]; !ok { + obj["serverTlsPolicy"] = nil + } + return obj, nil } diff --git a/tfplan2cai/converters/google/resources/services/gkehub2/gkehub2_feature.go b/tfplan2cai/converters/google/resources/services/gkehub2/gkehub2_feature.go index d0a9e8046..10d6e8bfe 100644 --- a/tfplan2cai/converters/google/resources/services/gkehub2/gkehub2_feature.go +++ b/tfplan2cai/converters/google/resources/services/gkehub2/gkehub2_feature.go @@ -443,6 +443,13 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagement(v interface{}, transformed["version"] = transformedVersion } + transformedManagement, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementManagement(original["management"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedManagement); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["management"] = transformedManagement + } + transformedConfigSync, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(original["config_sync"], d, config) if err != nil { return nil, err @@ -457,6 +464,10 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementVersion(v inter return v, nil } +func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementManagement(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/iam_securitycenterv2_organization_source.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/iam_securitycenterv2_organization_source.go new file mode 100644 index 000000000..b99c66245 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/iam_securitycenterv2_organization_source.go @@ -0,0 +1,199 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 ( + "fmt" + + "github.com/hashicorp/errwrap" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "google.golang.org/api/cloudresourcemanager/v1" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgiamresource" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +var SecurityCenterV2OrganizationSourceIamSchema = map[string]*schema.Schema{ + "organization": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "source": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + }, +} + +type SecurityCenterV2OrganizationSourceIamUpdater struct { + organization string + source string + d tpgresource.TerraformResourceData + Config *transport_tpg.Config +} + +func SecurityCenterV2OrganizationSourceIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { + values := make(map[string]string) + + if v, ok := d.GetOk("organization"); ok { + values["organization"] = v.(string) + } + + if v, ok := d.GetOk("source"); ok { + values["source"] = v.(string) + } + + // We may have gotten either a long or short name, so attempt to parse long name if possible + m, err := tpgresource.GetImportIdQualifiers([]string{"organizations/(?P[^/]+)/sources/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("source").(string)) + if err != nil { + return nil, err + } + + for k, v := range m { + values[k] = v + } + + u := &SecurityCenterV2OrganizationSourceIamUpdater{ + organization: values["organization"], + source: values["source"], + d: d, + Config: config, + } + + if err := d.Set("organization", u.organization); err != nil { + return nil, fmt.Errorf("Error setting organization: %s", err) + } + if err := d.Set("source", u.GetResourceId()); err != nil { + return nil, fmt.Errorf("Error setting source: %s", err) + } + + return u, nil +} + +func SecurityCenterV2OrganizationSourceIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { + values := make(map[string]string) + + m, err := tpgresource.GetImportIdQualifiers([]string{"organizations/(?P[^/]+)/sources/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) + if err != nil { + return err + } + + for k, v := range m { + values[k] = v + } + + u := &SecurityCenterV2OrganizationSourceIamUpdater{ + organization: values["organization"], + source: values["source"], + d: d, + Config: config, + } + if err := d.Set("source", u.GetResourceId()); err != nil { + return fmt.Errorf("Error setting source: %s", err) + } + d.SetId(u.GetResourceId()) + return nil +} + +func (u *SecurityCenterV2OrganizationSourceIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { + url, err := u.qualifyOrganizationSourceUrl("getIamPolicy") + if err != nil { + return nil, err + } + + var obj map[string]interface{} + + userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) + if err != nil { + return nil, err + } + + policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: u.Config, + Method: "POST", + RawURL: url, + UserAgent: userAgent, + Body: obj, + }) + if err != nil { + return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) + } + + out := &cloudresourcemanager.Policy{} + err = tpgresource.Convert(policy, out) + if err != nil { + return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) + } + + return out, nil +} + +func (u *SecurityCenterV2OrganizationSourceIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { + json, err := tpgresource.ConvertToMap(policy) + if err != nil { + return err + } + + obj := make(map[string]interface{}) + obj["policy"] = json + + url, err := u.qualifyOrganizationSourceUrl("setIamPolicy") + if err != nil { + return err + } + + userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) + if err != nil { + return err + } + + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: u.Config, + Method: "POST", + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: u.d.Timeout(schema.TimeoutCreate), + }) + if err != nil { + return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) + } + + return nil +} + +func (u *SecurityCenterV2OrganizationSourceIamUpdater) qualifyOrganizationSourceUrl(methodIdentifier string) (string, error) { + urlTemplate := fmt.Sprintf("{{SecurityCenterV2BasePath}}%s:%s", fmt.Sprintf("organizations/%s/sources/%s", u.organization, u.source), methodIdentifier) + url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) + if err != nil { + return "", err + } + return url, nil +} + +func (u *SecurityCenterV2OrganizationSourceIamUpdater) GetResourceId() string { + return fmt.Sprintf("organizations/%s/sources/%s", u.organization, u.source) +} + +func (u *SecurityCenterV2OrganizationSourceIamUpdater) GetMutexKey() string { + return fmt.Sprintf("iam-securitycenterv2-organizationsource-%s", u.GetResourceId()) +} + +func (u *SecurityCenterV2OrganizationSourceIamUpdater) DescribeResource() string { + return fmt.Sprintf("securitycenterv2 organizationsource %q", u.GetResourceId()) +} diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_source.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_source.go new file mode 100644 index 000000000..c323786c8 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_source.go @@ -0,0 +1,79 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 SecurityCenterV2OrganizationSourceAssetType string = "securitycenter.googleapis.com/OrganizationSource" + +func ResourceConverterSecurityCenterV2OrganizationSource() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2OrganizationSourceAssetType, + Convert: GetSecurityCenterV2OrganizationSourceCaiObject, + } +} + +func GetSecurityCenterV2OrganizationSourceCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//securitycenter.googleapis.com/{{name}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetSecurityCenterV2OrganizationSourceApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: SecurityCenterV2OrganizationSourceAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/securitycenter/v2/rest", + DiscoveryName: "OrganizationSource", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetSecurityCenterV2OrganizationSourceApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + descriptionProp, err := expandSecurityCenterV2OrganizationSourceDescription(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 + } + displayNameProp, err := expandSecurityCenterV2OrganizationSourceDisplayName(d.Get("display_name"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { + obj["displayName"] = displayNameProp + } + + return obj, nil +} + +func expandSecurityCenterV2OrganizationSourceDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2OrganizationSourceDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_source_iam.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_source_iam.go new file mode 100644 index 000000000..1d941f6a1 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_organization_source_iam.go @@ -0,0 +1,129 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 ( + "fmt" + + "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" +) + +// Provide a separate asset type constant so we don't have to worry about name conflicts between IAM and non-IAM converter files +const SecurityCenterV2OrganizationSourceIAMAssetType string = "securitycenter.googleapis.com/OrganizationSource" + +func ResourceConverterSecurityCenterV2OrganizationSourceIamPolicy() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2OrganizationSourceIAMAssetType, + Convert: GetSecurityCenterV2OrganizationSourceIamPolicyCaiObject, + MergeCreateUpdate: MergeSecurityCenterV2OrganizationSourceIamPolicy, + } +} + +func ResourceConverterSecurityCenterV2OrganizationSourceIamBinding() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2OrganizationSourceIAMAssetType, + Convert: GetSecurityCenterV2OrganizationSourceIamBindingCaiObject, + FetchFullResource: FetchSecurityCenterV2OrganizationSourceIamPolicy, + MergeCreateUpdate: MergeSecurityCenterV2OrganizationSourceIamBinding, + MergeDelete: MergeSecurityCenterV2OrganizationSourceIamBindingDelete, + } +} + +func ResourceConverterSecurityCenterV2OrganizationSourceIamMember() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2OrganizationSourceIAMAssetType, + Convert: GetSecurityCenterV2OrganizationSourceIamMemberCaiObject, + FetchFullResource: FetchSecurityCenterV2OrganizationSourceIamPolicy, + MergeCreateUpdate: MergeSecurityCenterV2OrganizationSourceIamMember, + MergeDelete: MergeSecurityCenterV2OrganizationSourceIamMemberDelete, + } +} + +func GetSecurityCenterV2OrganizationSourceIamPolicyCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + return newSecurityCenterV2OrganizationSourceIamAsset(d, config, cai.ExpandIamPolicyBindings) +} + +func GetSecurityCenterV2OrganizationSourceIamBindingCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + return newSecurityCenterV2OrganizationSourceIamAsset(d, config, cai.ExpandIamRoleBindings) +} + +func GetSecurityCenterV2OrganizationSourceIamMemberCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + return newSecurityCenterV2OrganizationSourceIamAsset(d, config, cai.ExpandIamMemberBindings) +} + +func MergeSecurityCenterV2OrganizationSourceIamPolicy(existing, incoming cai.Asset) cai.Asset { + existing.IAMPolicy = incoming.IAMPolicy + return existing +} + +func MergeSecurityCenterV2OrganizationSourceIamBinding(existing, incoming cai.Asset) cai.Asset { + return cai.MergeIamAssets(existing, incoming, cai.MergeAuthoritativeBindings) +} + +func MergeSecurityCenterV2OrganizationSourceIamBindingDelete(existing, incoming cai.Asset) cai.Asset { + return cai.MergeDeleteIamAssets(existing, incoming, cai.MergeDeleteAuthoritativeBindings) +} + +func MergeSecurityCenterV2OrganizationSourceIamMember(existing, incoming cai.Asset) cai.Asset { + return cai.MergeIamAssets(existing, incoming, cai.MergeAdditiveBindings) +} + +func MergeSecurityCenterV2OrganizationSourceIamMemberDelete(existing, incoming cai.Asset) cai.Asset { + return cai.MergeDeleteIamAssets(existing, incoming, cai.MergeDeleteAdditiveBindings) +} + +func newSecurityCenterV2OrganizationSourceIamAsset( + d tpgresource.TerraformResourceData, + config *transport_tpg.Config, + expandBindings func(d tpgresource.TerraformResourceData) ([]cai.IAMBinding, error), +) ([]cai.Asset, error) { + bindings, err := expandBindings(d) + if err != nil { + return []cai.Asset{}, fmt.Errorf("expanding bindings: %v", err) + } + + name, err := cai.AssetName(d, config, "//securitycenter.googleapis.com/organizations/{{organization}}/sources/{{source}}") + if err != nil { + return []cai.Asset{}, err + } + + return []cai.Asset{{ + Name: name, + Type: SecurityCenterV2OrganizationSourceIAMAssetType, + IAMPolicy: &cai.IAMPolicy{ + Bindings: bindings, + }, + }}, nil +} + +func FetchSecurityCenterV2OrganizationSourceIamPolicy(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (cai.Asset, error) { + // Check if the identity field returns a value + if _, ok := d.GetOk("organization"); !ok { + return cai.Asset{}, cai.ErrEmptyIdentityField + } + if _, ok := d.GetOk("source"); !ok { + return cai.Asset{}, cai.ErrEmptyIdentityField + } + + return cai.FetchIamPolicy( + SecurityCenterV2OrganizationSourceIamUpdaterProducer, + d, + config, + "//securitycenter.googleapis.com/organizations/{{organization}}/sources/{{source}}", + SecurityCenterV2OrganizationSourceIAMAssetType, + ) +} diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_project_mute_config.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_project_mute_config.go new file mode 100644 index 000000000..5c7ce6b15 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_project_mute_config.go @@ -0,0 +1,89 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 SecurityCenterV2ProjectMuteConfigAssetType string = "securitycenter.googleapis.com/ProjectMuteConfig" + +func ResourceConverterSecurityCenterV2ProjectMuteConfig() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2ProjectMuteConfigAssetType, + Convert: GetSecurityCenterV2ProjectMuteConfigCaiObject, + } +} + +func GetSecurityCenterV2ProjectMuteConfigCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//securitycenter.googleapis.com/projects/{{project}}/locations/{{location}}/muteConfigs/{{mute_config_id}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetSecurityCenterV2ProjectMuteConfigApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: SecurityCenterV2ProjectMuteConfigAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/securitycenter/v2/rest", + DiscoveryName: "ProjectMuteConfig", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetSecurityCenterV2ProjectMuteConfigApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + descriptionProp, err := expandSecurityCenterV2ProjectMuteConfigDescription(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 + } + filterProp, err := expandSecurityCenterV2ProjectMuteConfigFilter(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 + } + typeProp, err := expandSecurityCenterV2ProjectMuteConfigType(d.Get("type"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) { + obj["type"] = typeProp + } + + return obj, nil +} + +func expandSecurityCenterV2ProjectMuteConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2ProjectMuteConfigFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2ProjectMuteConfigType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_project_notification_config.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_project_notification_config.go new file mode 100644 index 000000000..3c0c7cac4 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_project_notification_config.go @@ -0,0 +1,108 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 SecurityCenterV2ProjectNotificationConfigAssetType string = "securitycenter.googleapis.com/ProjectNotificationConfig" + +func ResourceConverterSecurityCenterV2ProjectNotificationConfig() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2ProjectNotificationConfigAssetType, + Convert: GetSecurityCenterV2ProjectNotificationConfigCaiObject, + } +} + +func GetSecurityCenterV2ProjectNotificationConfigCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//securitycenter.googleapis.com/{{name}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetSecurityCenterV2ProjectNotificationConfigApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: SecurityCenterV2ProjectNotificationConfigAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/securitycenter/v2/rest", + DiscoveryName: "ProjectNotificationConfig", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetSecurityCenterV2ProjectNotificationConfigApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + descriptionProp, err := expandSecurityCenterV2ProjectNotificationConfigDescription(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 + } + pubsubTopicProp, err := expandSecurityCenterV2ProjectNotificationConfigPubsubTopic(d.Get("pubsub_topic"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("pubsub_topic"); !tpgresource.IsEmptyValue(reflect.ValueOf(pubsubTopicProp)) && (ok || !reflect.DeepEqual(v, pubsubTopicProp)) { + obj["pubsubTopic"] = pubsubTopicProp + } + streamingConfigProp, err := expandSecurityCenterV2ProjectNotificationConfigStreamingConfig(d.Get("streaming_config"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("streaming_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(streamingConfigProp)) && (ok || !reflect.DeepEqual(v, streamingConfigProp)) { + obj["streamingConfig"] = streamingConfigProp + } + + return obj, nil +} + +func expandSecurityCenterV2ProjectNotificationConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2ProjectNotificationConfigPubsubTopic(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2ProjectNotificationConfigStreamingConfig(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{}) + + transformedFilter, err := expandSecurityCenterV2ProjectNotificationConfigStreamingConfigFilter(original["filter"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedFilter); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["filter"] = transformedFilter + } + + return transformed, nil +} + +func expandSecurityCenterV2ProjectNotificationConfigStreamingConfigFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +}