Skip to content

Commit 988be43

Browse files
Add client scope (#13212)
[upstream:4e49b7ef4148798533d74f008751ce0b02d8c5c0] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 1120ef3 commit 988be43

4 files changed

+68
-2
lines changed

.changelog/13212.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
certificatemanager: add CLIENT_AUTH value documentation/example for `scope` in `google_certificate_manager_certificate`.
3+
```

google/services/certificatemanager/resource_certificate_manager_certificate.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ EDGE_CACHE: Certificates with scope EDGE_CACHE are special-purposed certificates
218218
See https://cloud.google.com/vpc/docs/edge-locations.
219219
220220
ALL_REGIONS: Certificates with ALL_REGIONS scope are served from all GCP regions (You can only use ALL_REGIONS with global certs).
221-
See https://cloud.google.com/compute/docs/regions-zones`,
221+
See https://cloud.google.com/compute/docs/regions-zones.
222+
223+
CLIENT_AUTH: Certificates with CLIENT_AUTH scope are used by a load balancer (TLS client) to be presented to the backend (TLS server) when backend mTLS is configured.
224+
See https://cloud.google.com/load-balancing/docs/backend-authenticated-tls-backend-mtls#client-certificate.`,
222225
Default: "DEFAULT",
223226
},
224227
"self_managed": {

google/services/certificatemanager/resource_certificate_manager_certificate_generated_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,45 @@ resource "google_certificate_manager_dns_authorization" "instance" {
482482
`, context)
483483
}
484484

485+
func TestAccCertificateManagerCertificate_certificateManagerClientAuthCertificateExample(t *testing.T) {
486+
t.Parallel()
487+
488+
context := map[string]interface{}{
489+
"random_suffix": acctest.RandString(t, 10),
490+
}
491+
492+
acctest.VcrTest(t, resource.TestCase{
493+
PreCheck: func() { acctest.AccTestPreCheck(t) },
494+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
495+
CheckDestroy: testAccCheckCertificateManagerCertificateDestroyProducer(t),
496+
Steps: []resource.TestStep{
497+
{
498+
Config: testAccCertificateManagerCertificate_certificateManagerClientAuthCertificateExample(context),
499+
},
500+
{
501+
ResourceName: "google_certificate_manager_certificate.default",
502+
ImportState: true,
503+
ImportStateVerify: true,
504+
ImportStateVerifyIgnore: []string{"labels", "location", "name", "self_managed", "terraform_labels"},
505+
},
506+
},
507+
})
508+
}
509+
510+
func testAccCertificateManagerCertificate_certificateManagerClientAuthCertificateExample(context map[string]interface{}) string {
511+
return acctest.Nprintf(`
512+
resource "google_certificate_manager_certificate" "default" {
513+
name = "tf-test-client-auth-cert%{random_suffix}"
514+
description = "Global cert"
515+
scope = "CLIENT_AUTH"
516+
self_managed {
517+
pem_certificate = file("test-fixtures/cert.pem")
518+
pem_private_key = file("test-fixtures/private-key.pem")
519+
}
520+
}
521+
`, context)
522+
}
523+
485524
func testAccCheckCertificateManagerCertificateDestroyProducer(t *testing.T) func(s *terraform.State) error {
486525
return func(s *terraform.State) error {
487526
for name, rs := range s.RootModule().Resources {

website/docs/r/certificate_manager_certificate.html.markdown

+22-1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,25 @@ resource "google_certificate_manager_dns_authorization" "instance" {
341341
domain = "subdomain.hashicorptest.com"
342342
}
343343
```
344+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
345+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=certificate_manager_client_auth_certificate&open_in_editor=main.tf" target="_blank">
346+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
347+
</a>
348+
</div>
349+
## Example Usage - Certificate Manager Client Auth Certificate
350+
351+
352+
```hcl
353+
resource "google_certificate_manager_certificate" "default" {
354+
name = "client-auth-cert"
355+
description = "Global cert"
356+
scope = "CLIENT_AUTH"
357+
self_managed {
358+
pem_certificate = file("test-fixtures/cert.pem")
359+
pem_private_key = file("test-fixtures/private-key.pem")
360+
}
361+
}
362+
```
344363

345364
## Argument Reference
346365

@@ -375,7 +394,9 @@ The following arguments are supported:
375394
EDGE_CACHE: Certificates with scope EDGE_CACHE are special-purposed certificates, served from Edge Points of Presence.
376395
See https://cloud.google.com/vpc/docs/edge-locations.
377396
ALL_REGIONS: Certificates with ALL_REGIONS scope are served from all GCP regions (You can only use ALL_REGIONS with global certs).
378-
See https://cloud.google.com/compute/docs/regions-zones
397+
See https://cloud.google.com/compute/docs/regions-zones.
398+
CLIENT_AUTH: Certificates with CLIENT_AUTH scope are used by a load balancer (TLS client) to be presented to the backend (TLS server) when backend mTLS is configured.
399+
See https://cloud.google.com/load-balancing/docs/backend-authenticated-tls-backend-mtls#client-certificate.
379400

380401
* `self_managed` -
381402
(Optional)

0 commit comments

Comments
 (0)