Skip to content

Commit be9af86

Browse files
Added logging service from DCL and log view resource. (#5795) (#11282)
* 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 b12eccd commit be9af86

16 files changed

+614
-23
lines changed

.changelog/5795.txt

+3
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/hashicorp/terraform-provider-google
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

+2
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/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ type Config struct {
246246
// dataprocBasePath is implemented in mm
247247
AssuredWorkloadsBasePath string
248248
CloudResourceManagerBasePath string
249+
ContainerAwsBasePath string
250+
ContainerAzureBasePath string
249251
EventarcBasePath string
250252
GkeHubBasePath string
251-
ContainerAzureBasePath string
252-
ContainerAwsBasePath string
253253
NetworkConnectivityBasePath string
254254
OrgPolicyBasePath string
255255
RecaptchaEnterpriseBasePath string

google/provider.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -1226,19 +1226,20 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
12261226
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
12271227
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
12281228
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
1229+
"google_container_aws_cluster": resourceContainerAwsCluster(),
1230+
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
1231+
"google_container_azure_client": resourceContainerAzureClient(),
1232+
"google_container_azure_cluster": resourceContainerAzureCluster(),
1233+
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
12291234
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
12301235
"google_eventarc_trigger": resourceEventarcTrigger(),
1236+
"google_logging_log_view": resourceLoggingLogView(),
12311237
"google_network_connectivity_hub": resourceNetworkConnectivityHub(),
12321238
"google_network_connectivity_spoke": resourceNetworkConnectivitySpoke(),
12331239
"google_org_policy_policy": resourceOrgPolicyPolicy(),
12341240
"google_os_config_os_policy_assignment": resourceOsConfigOsPolicyAssignment(),
12351241
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
12361242
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
1237-
"google_container_aws_cluster": resourceContainerAwsCluster(),
1238-
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
1239-
"google_container_azure_client": resourceContainerAzureClient(),
1240-
"google_container_azure_cluster": resourceContainerAzureCluster(),
1241-
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
12421243
},
12431244
// ------------------------------------
12441245
map[string]*schema.Resource{

google/provider_dcl_client_creation.go

+24
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
containerazure "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/containerazure"
3030
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc"
3131
eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc"
32+
logging "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/logging"
3233
networkconnectivity "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/networkconnectivity"
3334
orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy"
3435
osconfig "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/osconfig"
@@ -266,6 +267,29 @@ func NewDCLEventarcClient(config *Config, userAgent, billingProject string, time
266267
return eventarc.NewClient(dclConfig)
267268
}
268269

270+
func NewDCLLoggingClient(config *Config, userAgent, billingProject string, timeout time.Duration) *logging.Client {
271+
configOptions := []dcl.ConfigOption{
272+
dcl.WithHTTPClient(config.client),
273+
dcl.WithUserAgent(userAgent),
274+
dcl.WithLogger(dclLogger{}),
275+
dcl.WithBasePath(config.LoggingBasePath),
276+
}
277+
278+
if timeout != 0 {
279+
configOptions = append(configOptions, dcl.WithTimeout(timeout))
280+
}
281+
282+
if config.UserProjectOverride {
283+
configOptions = append(configOptions, dcl.WithUserProjectOverride())
284+
if billingProject != "" {
285+
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
286+
}
287+
}
288+
289+
dclConfig := dcl.NewConfig(configOptions...)
290+
return logging.NewClient(dclConfig)
291+
}
292+
269293
func NewDCLNetworkConnectivityClient(config *Config, userAgent, billingProject string, timeout time.Duration) *networkconnectivity.Client {
270294
configOptions := []dcl.ConfigOption{
271295
dcl.WithHTTPClient(config.client),

google/provider_dcl_endpoints.go

+12
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 NetworkConnectivityEndpointEntryKey = "network_connectivity_custom_endpoint"
98107
var NetworkConnectivityEndpointEntry = &schema.Schema{
99108
Type: schema.TypeString,
@@ -148,6 +157,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
148157
//ContainerAwsBasePath string
149158
//ContainerAzureBasePath string
150159
//EventarcBasePath string
160+
//LoggingBasePath string
151161
//NetworkConnectivityBasePath string
152162
//OrgPolicyBasePath string
153163
//OSConfigBasePath string
@@ -163,6 +173,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
163173
// ContainerAwsEndpointEntryKey: ContainerAwsEndpointEntry,
164174
// ContainerAzureEndpointEntryKey: ContainerAzureEndpointEntry,
165175
// EventarcEndpointEntryKey: EventarcEndpointEntry,
176+
// LoggingEndpointEntryKey: LoggingEndpointEntry,
166177
// NetworkConnectivityEndpointEntryKey: NetworkConnectivityEndpointEntry,
167178
// OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
168179
// OSConfigEndpointEntryKey: OSConfigEndpointEntry,
@@ -178,6 +189,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
178189
// config.ContainerAwsBasePath = d.Get(ContainerAwsEndpointEntryKey).(string)
179190
// config.ContainerAzureBasePath = d.Get(ContainerAzureEndpointEntryKey).(string)
180191
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
192+
// config.LoggingBasePath = d.Get(LoggingEndpointEntryKey).(string)
181193
// config.NetworkConnectivityBasePath = d.Get(NetworkConnectivityEndpointEntryKey).(string)
182194
// config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
183195
// config.OSConfigBasePath = d.Get(OSConfigEndpointEntryKey).(string)

google/resource_apikeys_key_generated_test.go

+8-8
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/resource_eventarc_trigger.go

+1-1
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)