Skip to content

Commit 95b63b9

Browse files
authored
Merge pull request hashicorp#1731 from nyurik/patch-1
Update compute_ssl_certificate.html.markdown
2 parents 86a7aaa + a8fe0f7 commit 95b63b9

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

docs/r/compute_ssl_certificate.html.markdown

+32-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,35 @@ resource "google_compute_ssl_certificate" "default" {
2222
description = "a description"
2323
private_key = "${file("path/to/private.key")}"
2424
certificate = "${file("path/to/certificate.crt")}"
25+
26+
lifecycle {
27+
create_before_destroy = true
28+
}
29+
}
30+
31+
# You may also want to control name generation explicitly:
32+
33+
resource "random_id" "certificate" {
34+
byte_length = 4
35+
prefix = "my-certificate-"
36+
37+
# For security, do not expose raw certificate values in the output
38+
keepers {
39+
private_key = "${base64sha256(file("path/to/private.key"))}"
40+
certificate = "${base64sha256(file("path/to/certificate.crt"))}"
41+
}
42+
}
43+
44+
resource "google_compute_ssl_certificate" "default" {
45+
# The name will contain 8 random hex digits,
46+
# e.g. "my-certificate-48ab27cd2a"
47+
name = "${random_id.certificate.hex}"
48+
private_key = "${file("path/to/private.key")}"
49+
certificate = "${file("path/to/certificate.crt")}"
50+
51+
lifecycle {
52+
create_before_destroy = true
53+
}
2554
}
2655
```
2756

@@ -32,8 +61,8 @@ specified configuration, Terraform will destroy the existing resource
3261
and create a replacement. To effectively use an SSL certificate resource
3362
with a [Target HTTPS Proxy resource][1], it's recommended to specify
3463
`create_before_destroy` in a [lifecycle][2] block. Either omit the
35-
Instance Template `name` attribute, or specify a partial name with
36-
`name_prefix`. Example:
64+
Instance Template `name` attribute, specify a partial name with
65+
`name_prefix`, or use [random_id][3] resource. Example:
3766

3867
```hcl
3968
resource "google_compute_ssl_certificate" "default" {
@@ -90,6 +119,7 @@ exported:
90119

91120
[1]: /docs/providers/google/r/compute_target_https_proxy.html
92121
[2]: /docs/configuration/resources.html#lifecycle
122+
[3]: /docs/providers/random/r/id.html
93123

94124
## Import
95125

0 commit comments

Comments
 (0)