2015-11-02 15:15:19 +00:00
|
|
|
---
|
2018-09-12 22:55:49 +00:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
|
|
#
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# ----------------------------------------------------------------------------
|
2015-11-02 15:15:19 +00:00
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_compute_ssl_certificate"
|
|
|
|
sidebar_current: "docs-google-compute-ssl-certificate"
|
|
|
|
description: |-
|
2018-09-12 22:55:49 +00:00
|
|
|
An SslCertificate resource, used for HTTPS load balancing.
|
2015-11-02 15:15:19 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# google\_compute\_ssl\_certificate
|
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
An SslCertificate resource, used for HTTPS load balancing. This resource
|
|
|
|
provides a mechanism to upload an SSL key and certificate to
|
|
|
|
the load balancer to serve secure connections from the user.
|
2015-11-02 15:15:19 +00:00
|
|
|
|
2018-10-04 02:45:53 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
To get more information about SslCertificate, see:
|
|
|
|
|
|
|
|
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/sslCertificates)
|
|
|
|
* How-to Guides
|
|
|
|
* [Official Documentation](https://cloud.google.com/load-balancing/docs/ssl-certificates)
|
2015-11-02 15:15:19 +00:00
|
|
|
|
2018-10-19 16:18:25 +00:00
|
|
|
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
|
|
|
|
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=ssl_certificate_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
|
|
|
|
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
## Example Usage - Ssl Certificate Basic
|
|
|
|
|
2015-11-02 15:15:19 +00:00
|
|
|
|
2017-04-17 10:17:54 +00:00
|
|
|
```hcl
|
2015-11-02 15:15:19 +00:00
|
|
|
resource "google_compute_ssl_certificate" "default" {
|
2016-12-12 23:57:58 +00:00
|
|
|
name_prefix = "my-certificate-"
|
2016-04-10 21:34:15 +00:00
|
|
|
description = "a description"
|
|
|
|
private_key = "${file("path/to/private.key")}"
|
|
|
|
certificate = "${file("path/to/certificate.crt")}"
|
2018-07-04 20:43:23 +00:00
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
create_before_destroy = true
|
|
|
|
}
|
|
|
|
}
|
2018-10-05 19:32:57 +00:00
|
|
|
```
|
2018-10-19 16:18:25 +00:00
|
|
|
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
|
|
|
|
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=ssl_certificate_random_provider&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
|
|
|
|
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
## Example Usage - Ssl Certificate Random Provider
|
|
|
|
|
|
|
|
|
2018-10-05 19:32:57 +00:00
|
|
|
```hcl
|
2018-07-04 20:43:23 +00:00
|
|
|
# You may also want to control name generation explicitly:
|
|
|
|
resource "google_compute_ssl_certificate" "default" {
|
|
|
|
# The name will contain 8 random hex digits,
|
|
|
|
# e.g. "my-certificate-48ab27cd2a"
|
|
|
|
name = "${random_id.certificate.hex}"
|
|
|
|
private_key = "${file("path/to/private.key")}"
|
|
|
|
certificate = "${file("path/to/certificate.crt")}"
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
create_before_destroy = true
|
|
|
|
}
|
2015-11-02 15:15:19 +00:00
|
|
|
}
|
2018-10-05 19:32:57 +00:00
|
|
|
|
|
|
|
resource "random_id" "certificate" {
|
|
|
|
byte_length = 4
|
|
|
|
prefix = "my-certificate-"
|
|
|
|
|
|
|
|
# For security, do not expose raw certificate values in the output
|
|
|
|
keepers {
|
|
|
|
private_key = "${base64sha256(file("path/to/private.key"))}"
|
|
|
|
certificate = "${base64sha256(file("path/to/certificate.crt"))}"
|
|
|
|
}
|
|
|
|
}
|
2015-11-02 15:15:19 +00:00
|
|
|
```
|
2018-10-19 16:18:25 +00:00
|
|
|
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
|
|
|
|
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=ssl_certificate_target_https_proxies&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
|
|
|
|
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
## Example Usage - Ssl Certificate Target Https Proxies
|
|
|
|
|
|
|
|
|
2017-07-28 17:45:32 +00:00
|
|
|
```hcl
|
2018-09-12 22:55:49 +00:00
|
|
|
// Using with Target HTTPS Proxies
|
|
|
|
//
|
|
|
|
// SSL certificates cannot be updated after creation. In order to apply
|
|
|
|
// the specified configuration, Terraform will destroy the existing
|
|
|
|
// resource and create a replacement. To effectively use an SSL
|
|
|
|
// certificate resource with a Target HTTPS Proxy resource, it's
|
|
|
|
// recommended to specify create_before_destroy in a lifecycle block.
|
|
|
|
// Either omit the Instance Template name attribute, specify a partial
|
|
|
|
// name with name_prefix, or use random_id resource. Example:
|
|
|
|
|
2017-07-28 17:45:32 +00:00
|
|
|
resource "google_compute_ssl_certificate" "default" {
|
|
|
|
name_prefix = "my-certificate-"
|
|
|
|
private_key = "${file("path/to/private.key")}"
|
|
|
|
certificate = "${file("path/to/certificate.crt")}"
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
create_before_destroy = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 19:32:57 +00:00
|
|
|
resource "google_compute_target_https_proxy" "default" {
|
|
|
|
name = "test-proxy"
|
|
|
|
url_map = "${google_compute_url_map.default.self_link}"
|
2017-07-28 17:45:32 +00:00
|
|
|
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
|
|
|
}
|
2018-10-05 19:32:57 +00:00
|
|
|
|
|
|
|
resource "google_compute_url_map" "default" {
|
|
|
|
name = "url-map"
|
|
|
|
description = "a description"
|
|
|
|
|
|
|
|
default_service = "${google_compute_backend_service.default.self_link}"
|
|
|
|
|
|
|
|
host_rule {
|
|
|
|
hosts = ["mysite.com"]
|
|
|
|
path_matcher = "allpaths"
|
|
|
|
}
|
|
|
|
|
|
|
|
path_matcher {
|
|
|
|
name = "allpaths"
|
|
|
|
default_service = "${google_compute_backend_service.default.self_link}"
|
|
|
|
|
|
|
|
path_rule {
|
|
|
|
paths = ["/*"]
|
|
|
|
service = "${google_compute_backend_service.default.self_link}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_backend_service" "default" {
|
|
|
|
name = "backend-service"
|
|
|
|
port_name = "http"
|
|
|
|
protocol = "HTTP"
|
|
|
|
timeout_sec = 10
|
|
|
|
|
|
|
|
health_checks = ["${google_compute_http_health_check.default.self_link}"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_http_health_check" "default" {
|
|
|
|
name = "http-health-check"
|
|
|
|
request_path = "/"
|
|
|
|
check_interval_sec = 1
|
|
|
|
timeout_sec = 1
|
|
|
|
}
|
2017-07-28 17:45:32 +00:00
|
|
|
```
|
|
|
|
|
2015-11-02 15:15:19 +00:00
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
* `certificate` -
|
|
|
|
(Required)
|
|
|
|
The certificate in PEM format.
|
|
|
|
The certificate chain must be no greater than 5 certs long.
|
|
|
|
The chain must include at least one intermediate cert.
|
|
|
|
|
|
|
|
* `private_key` -
|
|
|
|
(Required)
|
|
|
|
The write-only private key in PEM format.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
- - -
|
|
|
|
|
2016-12-12 23:57:58 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
* `description` -
|
|
|
|
(Optional)
|
|
|
|
An optional description of this resource.
|
|
|
|
|
|
|
|
* `name` -
|
|
|
|
(Optional)
|
|
|
|
Name of the resource. Provided by the client when the resource is
|
|
|
|
created. The name must be 1-63 characters long, and comply with
|
|
|
|
RFC1035. Specifically, the name must be 1-63 characters long and match
|
|
|
|
the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the
|
|
|
|
first character must be a lowercase letter, and all following
|
|
|
|
characters must be a dash, lowercase letter, or digit, except the last
|
|
|
|
character, which cannot be a dash.
|
|
|
|
* `project` - (Optional) The ID of the project in which the resource belongs.
|
|
|
|
If it is not provided, the provider project is used.
|
2016-12-12 23:57:58 +00:00
|
|
|
|
2015-11-02 15:15:19 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
* `name_prefix` - (Optional) Creates a unique name beginning with the
|
|
|
|
specified prefix. Conflicts with `name`.
|
2016-04-10 21:34:15 +00:00
|
|
|
|
2015-11-02 15:15:19 +00:00
|
|
|
## Attributes Reference
|
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
In addition to the arguments listed above, the following computed attributes are exported:
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
* `creation_timestamp` -
|
|
|
|
Creation timestamp in RFC3339 text format.
|
2015-11-02 15:15:19 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
* `certificate_id` -
|
|
|
|
The unique identifier for the resource.
|
2015-11-02 15:15:19 +00:00
|
|
|
* `self_link` - The URI of the created resource.
|
2017-07-28 17:45:32 +00:00
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
|
|
|
|
## Timeouts
|
|
|
|
|
|
|
|
This resource provides the following
|
|
|
|
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
|
|
|
|
|
|
|
- `create` - Default is 4 minutes.
|
|
|
|
- `delete` - Default is 4 minutes.
|
2017-11-09 18:16:57 +00:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
2018-09-12 22:55:49 +00:00
|
|
|
SslCertificate can be imported using any of these accepted formats:
|
2017-11-09 18:16:57 +00:00
|
|
|
|
|
|
|
```
|
2018-09-12 22:55:49 +00:00
|
|
|
$ terraform import google_compute_ssl_certificate.default projects/{{project}}/global/sslCertificates/{{name}}
|
|
|
|
$ terraform import google_compute_ssl_certificate.default {{project}}/{{name}}
|
|
|
|
$ terraform import google_compute_ssl_certificate.default {{name}}
|
2017-11-09 18:16:57 +00:00
|
|
|
```
|