Skip to content

Commit da5fbf1

Browse files
Added logging service from DCL and log view resource. (#5795) (#4125)
* Added logging service from DCL and log view resource. Ran make serialize. * Added USE_DCL_ID override. * Ran make upgrade-dcl. * Removed some debug lines and ran make serialize. * Made the test ignore long-form vs short-form bucket name for import purposes. Signed-off-by: Modular Magician <[email protected]>
1 parent 3cdf8b9 commit da5fbf1

16 files changed

+614
-23
lines changed

.changelog/5795.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
google_logging_log_view
3+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/hashicorp/terraform-provider-google-beta
22
require (
33
cloud.google.com/go/bigtable v1.10.1
44
cloud.google.com/go/iam v0.1.1 // indirect
5-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512
5+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220310234957-05f157784867
66
github.com/apparentlymart/go-cidr v1.1.0
77
github.com/client9/misspell v0.3.4
88
github.com/davecgh/go-spew v1.1.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,3 +1533,5 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-202202
15331533
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
15341534
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512 h1:8/Sn9pDdk/RxECtLUh4xum2eyUvf0h7bpx8h+lYvE+Q=
15351535
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
1536+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220310234957-05f157784867 h1:spnm9WU2KGFDrqgn0XL2d5H0oo7Lw0rvm/E8t1qWSdI=
1537+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220310234957-05f157784867/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=

google-beta/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ type Config struct {
257257
// dataprocBasePath is implemented in mm
258258
AssuredWorkloadsBasePath string
259259
CloudResourceManagerBasePath string
260+
ContainerAwsBasePath string
261+
ContainerAzureBasePath string
260262
EventarcBasePath string
261263
GkeHubBasePath string
262-
ContainerAzureBasePath string
263-
ContainerAwsBasePath string
264264
NetworkConnectivityBasePath string
265265
OrgPolicyBasePath string
266266
RecaptchaEnterpriseBasePath string

google-beta/provider.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,22 +1384,23 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
13841384
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
13851385
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
13861386
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
1387+
"google_container_aws_cluster": resourceContainerAwsCluster(),
1388+
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
1389+
"google_container_azure_client": resourceContainerAzureClient(),
1390+
"google_container_azure_cluster": resourceContainerAzureCluster(),
1391+
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
13871392
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
13881393
"google_eventarc_trigger": resourceEventarcTrigger(),
13891394
"google_gke_hub_feature": resourceGkeHubFeature(),
13901395
"google_gke_hub_feature_membership": resourceGkeHubFeatureMembership(),
1396+
"google_logging_log_view": resourceLoggingLogView(),
13911397
"google_monitoring_monitored_project": resourceMonitoringMonitoredProject(),
13921398
"google_network_connectivity_hub": resourceNetworkConnectivityHub(),
13931399
"google_network_connectivity_spoke": resourceNetworkConnectivitySpoke(),
13941400
"google_org_policy_policy": resourceOrgPolicyPolicy(),
13951401
"google_os_config_os_policy_assignment": resourceOsConfigOsPolicyAssignment(),
13961402
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
13971403
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
1398-
"google_container_aws_cluster": resourceContainerAwsCluster(),
1399-
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
1400-
"google_container_azure_client": resourceContainerAzureClient(),
1401-
"google_container_azure_cluster": resourceContainerAzureCluster(),
1402-
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
14031404
},
14041405
// ------------------------------------
14051406
map[string]*schema.Resource{

google-beta/provider_dcl_client_creation.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc/beta"
3131
eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta"
3232
gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
33+
logging "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/logging/beta"
3334
monitoring "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/monitoring/beta"
3435
networkconnectivity "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/networkconnectivity/beta"
3536
orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/beta"
@@ -291,6 +292,29 @@ func NewDCLGkeHubClient(config *Config, userAgent, billingProject string, timeou
291292
return gkehub.NewClient(dclConfig)
292293
}
293294

295+
func NewDCLLoggingClient(config *Config, userAgent, billingProject string, timeout time.Duration) *logging.Client {
296+
configOptions := []dcl.ConfigOption{
297+
dcl.WithHTTPClient(config.client),
298+
dcl.WithUserAgent(userAgent),
299+
dcl.WithLogger(dclLogger{}),
300+
dcl.WithBasePath(config.LoggingBasePath),
301+
}
302+
303+
if timeout != 0 {
304+
configOptions = append(configOptions, dcl.WithTimeout(timeout))
305+
}
306+
307+
if config.UserProjectOverride {
308+
configOptions = append(configOptions, dcl.WithUserProjectOverride())
309+
if billingProject != "" {
310+
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
311+
}
312+
}
313+
314+
dclConfig := dcl.NewConfig(configOptions...)
315+
return logging.NewClient(dclConfig)
316+
}
317+
294318
func NewDCLMonitoringClient(config *Config, userAgent, billingProject string, timeout time.Duration) *monitoring.Client {
295319
configOptions := []dcl.ConfigOption{
296320
dcl.WithHTTPClient(config.client),

google-beta/provider_dcl_endpoints.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ var EventarcEndpointEntry = &schema.Schema{
9494
}, ""),
9595
}
9696

97+
var LoggingEndpointEntryKey = "logging_custom_endpoint"
98+
var LoggingEndpointEntry = &schema.Schema{
99+
Type: schema.TypeString,
100+
Optional: true,
101+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
102+
"GOOGLE_LOGGING_CUSTOM_ENDPOINT",
103+
}, ""),
104+
}
105+
97106
var MonitoringEndpointEntryKey = "monitoring_custom_endpoint"
98107
var MonitoringEndpointEntry = &schema.Schema{
99108
Type: schema.TypeString,
@@ -157,6 +166,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
157166
//ContainerAwsBasePath string
158167
//ContainerAzureBasePath string
159168
//EventarcBasePath string
169+
//LoggingBasePath string
160170
//MonitoringBasePath string
161171
//NetworkConnectivityBasePath string
162172
//OrgPolicyBasePath string
@@ -173,6 +183,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
173183
// ContainerAwsEndpointEntryKey: ContainerAwsEndpointEntry,
174184
// ContainerAzureEndpointEntryKey: ContainerAzureEndpointEntry,
175185
// EventarcEndpointEntryKey: EventarcEndpointEntry,
186+
// LoggingEndpointEntryKey: LoggingEndpointEntry,
176187
// MonitoringEndpointEntryKey: MonitoringEndpointEntry,
177188
// NetworkConnectivityEndpointEntryKey: NetworkConnectivityEndpointEntry,
178189
// OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
@@ -189,6 +200,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
189200
// config.ContainerAwsBasePath = d.Get(ContainerAwsEndpointEntryKey).(string)
190201
// config.ContainerAzureBasePath = d.Get(ContainerAzureEndpointEntryKey).(string)
191202
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
203+
// config.LoggingBasePath = d.Get(LoggingEndpointEntryKey).(string)
192204
// config.MonitoringBasePath = d.Get(MonitoringEndpointEntryKey).(string)
193205
// config.NetworkConnectivityBasePath = d.Get(NetworkConnectivityEndpointEntryKey).(string)
194206
// config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)

google-beta/resource_apikeys_key_generated_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ resource "google_apikeys_key" "primary" {
200200
}
201201
202202
api_targets {
203-
methods = ["GET*"]
204203
service = "translate.googleapis.com"
204+
methods = ["GET*"]
205205
}
206206
}
207207
}
@@ -232,8 +232,8 @@ resource "google_apikeys_key" "primary" {
232232
}
233233
234234
api_targets {
235-
methods = ["GET*"]
236235
service = "translate.googleapis.com"
236+
methods = ["GET*"]
237237
}
238238
}
239239
}
@@ -257,8 +257,8 @@ resource "google_apikeys_key" "primary" {
257257
258258
restrictions {
259259
api_targets {
260-
methods = ["GET*"]
261260
service = "translate.googleapis.com"
261+
methods = ["GET*"]
262262
}
263263
264264
browser_key_restrictions {
@@ -286,8 +286,8 @@ resource "google_apikeys_key" "primary" {
286286
287287
restrictions {
288288
api_targets {
289-
methods = ["POST*"]
290289
service = "maps.googleapis.com"
290+
methods = ["POST*"]
291291
}
292292
293293
browser_key_restrictions {
@@ -315,8 +315,8 @@ resource "google_apikeys_key" "primary" {
315315
316316
restrictions {
317317
api_targets {
318-
methods = ["GET*"]
319318
service = "translate.googleapis.com"
319+
methods = ["GET*"]
320320
}
321321
322322
ios_key_restrictions {
@@ -344,8 +344,8 @@ resource "google_apikeys_key" "primary" {
344344
345345
restrictions {
346346
api_targets {
347-
methods = ["GET*"]
348347
service = "translate.googleapis.com"
348+
methods = ["GET*"]
349349
}
350350
351351
ios_key_restrictions {
@@ -391,8 +391,8 @@ resource "google_apikeys_key" "primary" {
391391
392392
restrictions {
393393
api_targets {
394-
methods = ["GET*"]
395394
service = "translate.googleapis.com"
395+
methods = ["GET*"]
396396
}
397397
398398
server_key_restrictions {
@@ -420,8 +420,8 @@ resource "google_apikeys_key" "primary" {
420420
421421
restrictions {
422422
api_targets {
423-
methods = ["GET*"]
424423
service = "translate.googleapis.com"
424+
methods = ["GET*"]
425425
}
426426
427427
server_key_restrictions {

google-beta/resource_eventarc_trigger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func resourceEventarcTrigger() *schema.Resource {
9595
Type: schema.TypeString,
9696
Optional: true,
9797
DiffSuppressFunc: compareSelfLinkOrResourceName,
98-
Description: "Optional. The IAM service account email associated with the trigger. The service account represents the identity of the trigger. The principal who calls this API must have `iam.serviceAccounts.actAs` permission in the service account. See https://cloud.google.com/iam/docs/understanding-service-accounts?hl=en#sa_common for more information. For Cloud Run destinations, this service account is used to generate identity tokens when invoking the service. See https://cloud.google.com/run/docs/triggering/pubsub-push#create-service-account for information on how to invoke authenticated Cloud Run services. In order to create Audit Log triggers, the service account should also have `roles/eventarc.eventReceiver` IAM role.",
98+
Description: "Optional. The IAM service account email associated with the trigger. The service account represents the identity of the trigger. The principal who calls this API must have `iam.serviceAccounts.actAs` permission in the service account. See https://cloud.google.com/iam/docs/understanding-service-accounts#sa_common for more information. For Cloud Run destinations, this service account is used to generate identity tokens when invoking the service. See https://cloud.google.com/run/docs/triggering/pubsub-push#create-service-account for information on how to invoke authenticated Cloud Run services. In order to create Audit Log triggers, the service account should also have `roles/eventarc.eventReceiver` IAM role.",
9999
},
100100

101101
"transport": {

0 commit comments

Comments
 (0)