mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-03 08:42:39 +00:00
Add new generated tests for examples (#2111)
This commit is contained in:
parent
d29140f23c
commit
645eab7ced
200
google/resource_compute_ssl_certificate_generated_test.go
Normal file
200
google/resource_compute_ssl_certificate_generated_test.go
Normal file
|
@ -0,0 +1,200 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeSslCertificate_sslCertificateBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeSslCertificateDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeSslCertificate_sslCertificateBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_ssl_certificate.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"private_key", "name_prefix"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeSslCertificate_sslCertificateBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name_prefix = "my-certificate-"
|
||||
description = "a description"
|
||||
private_key = "${file("test-fixtures/ssl_cert/test.key")}"
|
||||
certificate = "${file("test-fixtures/ssl_cert/test.crt")}"
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
`,
|
||||
)
|
||||
}
|
||||
|
||||
func TestAccComputeSslCertificate_sslCertificateRandomProviderExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeSslCertificateDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeSslCertificate_sslCertificateRandomProviderExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_ssl_certificate.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"private_key"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeSslCertificate_sslCertificateRandomProviderExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
# 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("test-fixtures/ssl_cert/test.key")}"
|
||||
certificate = "${file("test-fixtures/ssl_cert/test.crt")}"
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
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("test-fixtures/ssl_cert/test.key"))}"
|
||||
certificate = "${base64sha256(file("test-fixtures/ssl_cert/test.crt"))}"
|
||||
}
|
||||
}
|
||||
`,
|
||||
)
|
||||
}
|
||||
|
||||
func TestAccComputeSslCertificate_sslCertificateTargetHttpsProxiesExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeSslCertificateDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeSslCertificate_sslCertificateTargetHttpsProxiesExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_ssl_certificate.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"private_key", "name_prefix"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeSslCertificate_sslCertificateTargetHttpsProxiesExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
// 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:
|
||||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name_prefix = "my-certificate-"
|
||||
private_key = "${file("test-fixtures/ssl_cert/test.key")}"
|
||||
certificate = "${file("test-fixtures/ssl_cert/test.crt")}"
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_target_https_proxy" "default" {
|
||||
name = "test-proxy-%s"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "default" {
|
||||
name = "url-map-%s"
|
||||
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-%s"
|
||||
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-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
`, val, val, val, val,
|
||||
)
|
||||
}
|
89
google/resource_compute_target_http_proxy_generated_test.go
Normal file
89
google/resource_compute_target_http_proxy_generated_test.go
Normal file
|
@ -0,0 +1,89 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeTargetHttpProxy_targetHttpProxyBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeTargetHttpProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeTargetHttpProxy_targetHttpProxyBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_target_http_proxy.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeTargetHttpProxy_targetHttpProxyBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_http_proxy" "default" {
|
||||
name = "test-proxy-%s"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "default" {
|
||||
name = "url-map-%s"
|
||||
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-%s"
|
||||
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-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
`, val, val, val, val,
|
||||
)
|
||||
}
|
98
google/resource_compute_target_https_proxy_generated_test.go
Normal file
98
google/resource_compute_target_https_proxy_generated_test.go
Normal file
|
@ -0,0 +1,98 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeTargetHttpsProxy_targetHttpsProxyBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeTargetHttpsProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeTargetHttpsProxy_targetHttpsProxyBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_target_https_proxy.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeTargetHttpsProxy_targetHttpsProxyBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_https_proxy" "default" {
|
||||
name = "test-proxy-%s"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name = "my-certificate-%s"
|
||||
private_key = "${file("test-fixtures/ssl_cert/test.key")}"
|
||||
certificate = "${file("test-fixtures/ssl_cert/test.crt")}"
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "default" {
|
||||
name = "url-map-%s"
|
||||
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-%s"
|
||||
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-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
`, val, val, val, val, val,
|
||||
)
|
||||
}
|
75
google/resource_compute_target_ssl_proxy_generated_test.go
Normal file
75
google/resource_compute_target_ssl_proxy_generated_test.go
Normal file
|
@ -0,0 +1,75 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeTargetSslProxy_targetSslProxyBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeTargetSslProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeTargetSslProxy_targetSslProxyBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_target_ssl_proxy.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeTargetSslProxy_targetSslProxyBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_ssl_proxy" "default" {
|
||||
name = "test-proxy-%s"
|
||||
backend_service = "${google_compute_backend_service.default.self_link}"
|
||||
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name = "default-cert-%s"
|
||||
private_key = "${file("test-fixtures/ssl_cert/test.key")}"
|
||||
certificate = "${file("test-fixtures/ssl_cert/test.crt")}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "backend-service-%s"
|
||||
protocol = "SSL"
|
||||
health_checks = ["${google_compute_health_check.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_health_check" "default" {
|
||||
name = "health-check-%s"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
tcp_health_check {
|
||||
port = "443"
|
||||
}
|
||||
}
|
||||
`, val, val, val, val,
|
||||
)
|
||||
}
|
71
google/resource_compute_target_tcp_proxy_generated_test.go
Normal file
71
google/resource_compute_target_tcp_proxy_generated_test.go
Normal file
|
@ -0,0 +1,71 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeTargetTcpProxy_targetTcpProxyBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeTargetTcpProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeTargetTcpProxy_targetTcpProxyBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_target_tcp_proxy.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeTargetTcpProxy_targetTcpProxyBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_tcp_proxy" "default" {
|
||||
name = "test-proxy-%s"
|
||||
backend_service = "${google_compute_backend_service.default.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "backend-service-%s"
|
||||
protocol = "TCP"
|
||||
timeout_sec = 10
|
||||
|
||||
health_checks = ["${google_compute_health_check.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_health_check" "default" {
|
||||
name = "health-check-%s"
|
||||
timeout_sec = 1
|
||||
check_interval_sec = 1
|
||||
|
||||
tcp_health_check {
|
||||
port = "443"
|
||||
}
|
||||
}
|
||||
`, val, val, val,
|
||||
)
|
||||
}
|
107
google/resource_compute_vpn_gateway_generated_test.go
Normal file
107
google/resource_compute_vpn_gateway_generated_test.go
Normal file
|
@ -0,0 +1,107 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeVpnGateway_targetVpnGatewayBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeVpnGatewayDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeVpnGateway_targetVpnGatewayBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_vpn_gateway.target_gateway",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeVpnGateway_targetVpnGatewayBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_vpn_gateway" "target_gateway" {
|
||||
name = "vpn1-%s"
|
||||
network = "${google_compute_network.network1.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_network" "network1" {
|
||||
name = "network1-%s"
|
||||
}
|
||||
|
||||
resource "google_compute_address" "vpn_static_ip" {
|
||||
name = "vpn-static-ip-%s"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_esp" {
|
||||
name = "fr-esp-%s"
|
||||
ip_protocol = "ESP"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_udp500" {
|
||||
name = "fr-udp500-%s"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_udp4500" {
|
||||
name = "fr-udp4500-%s"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "4500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_vpn_tunnel" "tunnel1" {
|
||||
name = "tunnel1-%s"
|
||||
peer_ip = "15.0.0.120"
|
||||
shared_secret = "a secret message"
|
||||
|
||||
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
|
||||
depends_on = [
|
||||
"google_compute_forwarding_rule.fr_esp",
|
||||
"google_compute_forwarding_rule.fr_udp500",
|
||||
"google_compute_forwarding_rule.fr_udp4500",
|
||||
]
|
||||
}
|
||||
|
||||
resource "google_compute_route" "route1" {
|
||||
name = "route1-%s"
|
||||
network = "${google_compute_network.network1.name}"
|
||||
dest_range = "15.0.0.0/24"
|
||||
priority = 1000
|
||||
|
||||
next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}"
|
||||
}
|
||||
`, val, val, val, val, val, val, val, val,
|
||||
)
|
||||
}
|
108
google/resource_compute_vpn_tunnel_generated_test.go
Normal file
108
google/resource_compute_vpn_tunnel_generated_test.go
Normal file
|
@ -0,0 +1,108 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeVpnTunnel_vpnTunnelBasicExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeVpnTunnelDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeVpnTunnel_vpnTunnelBasicExample(acctest.RandString(10)),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_vpn_tunnel.tunnel1",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"shared_secret"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeVpnTunnel_vpnTunnelBasicExample(val string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_vpn_tunnel" "tunnel1" {
|
||||
name = "tunnel1-%s"
|
||||
peer_ip = "15.0.0.120"
|
||||
shared_secret = "a secret message"
|
||||
|
||||
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
|
||||
depends_on = [
|
||||
"google_compute_forwarding_rule.fr_esp",
|
||||
"google_compute_forwarding_rule.fr_udp500",
|
||||
"google_compute_forwarding_rule.fr_udp4500",
|
||||
]
|
||||
}
|
||||
|
||||
resource "google_compute_vpn_gateway" "target_gateway" {
|
||||
name = "vpn1-%s"
|
||||
network = "${google_compute_network.network1.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_network" "network1" {
|
||||
name = "network1-%s"
|
||||
}
|
||||
|
||||
resource "google_compute_address" "vpn_static_ip" {
|
||||
name = "vpn-static-ip-%s"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_esp" {
|
||||
name = "fr-esp-%s"
|
||||
ip_protocol = "ESP"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_udp500" {
|
||||
name = "fr-udp500-%s"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_udp4500" {
|
||||
name = "fr-udp4500-%s"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "4500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_route" "route1" {
|
||||
name = "route1-%s"
|
||||
network = "${google_compute_network.network1.name}"
|
||||
dest_range = "15.0.0.0/24"
|
||||
priority = 1000
|
||||
|
||||
next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}"
|
||||
}
|
||||
`, val, val, val, val, val, val, val, val,
|
||||
)
|
||||
}
|
|
@ -45,20 +45,9 @@ resource "google_compute_ssl_certificate" "default" {
|
|||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
```hcl
|
||||
# You may also want to control name generation explicitly:
|
||||
|
||||
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"))}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
# The name will contain 8 random hex digits,
|
||||
# e.g. "my-certificate-48ab27cd2a"
|
||||
|
@ -70,6 +59,17 @@ resource "google_compute_ssl_certificate" "default" {
|
|||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
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"))}"
|
||||
}
|
||||
}
|
||||
```
|
||||
```hcl
|
||||
// Using with Target HTTPS Proxies
|
||||
|
@ -84,7 +84,6 @@ resource "google_compute_ssl_certificate" "default" {
|
|||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name_prefix = "my-certificate-"
|
||||
description = "a description"
|
||||
private_key = "${file("path/to/private.key")}"
|
||||
certificate = "${file("path/to/certificate.crt")}"
|
||||
|
||||
|
@ -93,11 +92,49 @@ resource "google_compute_ssl_certificate" "default" {
|
|||
}
|
||||
}
|
||||
|
||||
resource "google_compute_target_https_proxy" "my_proxy" {
|
||||
name = "public-proxy"
|
||||
url_map = # ...
|
||||
resource "google_compute_target_https_proxy" "default" {
|
||||
name = "test-proxy"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
```
|
||||
|
||||
## Argument Reference
|
||||
|
|
|
@ -37,14 +37,11 @@ To get more information about TargetHttpProxy, see:
|
|||
```hcl
|
||||
resource "google_compute_target_http_proxy" "default" {
|
||||
name = "test-proxy"
|
||||
description = "a description"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "default" {
|
||||
name = "url-map"
|
||||
description = "a description"
|
||||
|
||||
default_service = "${google_compute_backend_service.default.self_link}"
|
||||
|
||||
host_rule {
|
||||
|
@ -64,7 +61,7 @@ resource "google_compute_url_map" "default" {
|
|||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "default-backend"
|
||||
name = "backend-service"
|
||||
port_name = "http"
|
||||
protocol = "HTTP"
|
||||
timeout_sec = 10
|
||||
|
@ -73,7 +70,7 @@ resource "google_compute_backend_service" "default" {
|
|||
}
|
||||
|
||||
resource "google_compute_http_health_check" "default" {
|
||||
name = "test"
|
||||
name = "http-health-check"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
|
|
|
@ -37,14 +37,12 @@ To get more information about TargetHttpsProxy, see:
|
|||
```hcl
|
||||
resource "google_compute_target_https_proxy" "default" {
|
||||
name = "test-proxy"
|
||||
description = "a description"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name = "my-certificate"
|
||||
description = "a description"
|
||||
private_key = "${file("path/to/private.key")}"
|
||||
certificate = "${file("path/to/certificate.crt")}"
|
||||
}
|
||||
|
@ -72,7 +70,7 @@ resource "google_compute_url_map" "default" {
|
|||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "default-backend"
|
||||
name = "backend-service"
|
||||
port_name = "http"
|
||||
protocol = "HTTP"
|
||||
timeout_sec = 10
|
||||
|
@ -81,7 +79,7 @@ resource "google_compute_backend_service" "default" {
|
|||
}
|
||||
|
||||
resource "google_compute_http_health_check" "default" {
|
||||
name = "test"
|
||||
name = "http-health-check"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
|
|
|
@ -38,27 +38,27 @@ To get more information about TargetSslProxy, see:
|
|||
|
||||
```hcl
|
||||
resource "google_compute_target_ssl_proxy" "default" {
|
||||
name = "test"
|
||||
backend_service = "${google_compute_backend_service.default.self_link}"
|
||||
name = "test-proxy"
|
||||
backend_service = "${google_compute_backend_service.default.self_link}"
|
||||
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_ssl_certificate" "default" {
|
||||
name = "default-cert"
|
||||
private_key = "${file("path/to/test.key")}"
|
||||
certificate = "${file("path/to/test.crt")}"
|
||||
name = "default-cert"
|
||||
private_key = "${file("path/to/private.key")}"
|
||||
certificate = "${file("path/to/certificate.crt")}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "default-backend"
|
||||
protocol = "SSL"
|
||||
name = "backend-service"
|
||||
protocol = "SSL"
|
||||
health_checks = ["${google_compute_health_check.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_health_check" "default" {
|
||||
name = "default-health-check"
|
||||
name = "health-check"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
timeout_sec = 1
|
||||
tcp_health_check {
|
||||
port = "443"
|
||||
}
|
||||
|
|
|
@ -38,21 +38,20 @@ To get more information about TargetTcpProxy, see:
|
|||
|
||||
```hcl
|
||||
resource "google_compute_target_tcp_proxy" "default" {
|
||||
name = "test"
|
||||
description = "test"
|
||||
name = "test-proxy"
|
||||
backend_service = "${google_compute_backend_service.default.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "default-backend"
|
||||
protocol = "TCP"
|
||||
timeout_sec = 10
|
||||
name = "backend-service"
|
||||
protocol = "TCP"
|
||||
timeout_sec = 10
|
||||
|
||||
health_checks = ["${google_compute_health_check.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_health_check" "default" {
|
||||
name = "default"
|
||||
name = "health-check"
|
||||
timeout_sec = 1
|
||||
check_interval_sec = 1
|
||||
|
||||
|
|
|
@ -32,25 +32,21 @@ To get more information about VpnGateway, see:
|
|||
## Example Usage
|
||||
|
||||
```hcl
|
||||
resource "google_compute_network" "network1" {
|
||||
name = "network1"
|
||||
ipv4_range = "10.120.0.0/16"
|
||||
}
|
||||
|
||||
resource "google_compute_vpn_gateway" "target_gateway" {
|
||||
name = "vpn1"
|
||||
network = "${google_compute_network.network1.self_link}"
|
||||
region = "${var.region}"
|
||||
}
|
||||
|
||||
resource "google_compute_network" "network1" {
|
||||
name = "network1"
|
||||
}
|
||||
|
||||
resource "google_compute_address" "vpn_static_ip" {
|
||||
name = "vpn-static-ip"
|
||||
region = "${var.region}"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_esp" {
|
||||
name = "fr-esp"
|
||||
region = "${var.region}"
|
||||
ip_protocol = "ESP"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
|
@ -58,7 +54,6 @@ resource "google_compute_forwarding_rule" "fr_esp" {
|
|||
|
||||
resource "google_compute_forwarding_rule" "fr_udp500" {
|
||||
name = "fr-udp500"
|
||||
region = "${var.region}"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
|
@ -67,7 +62,6 @@ resource "google_compute_forwarding_rule" "fr_udp500" {
|
|||
|
||||
resource "google_compute_forwarding_rule" "fr_udp4500" {
|
||||
name = "fr-udp4500"
|
||||
region = "${var.region}"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "4500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
|
@ -76,7 +70,6 @@ resource "google_compute_forwarding_rule" "fr_udp4500" {
|
|||
|
||||
resource "google_compute_vpn_tunnel" "tunnel1" {
|
||||
name = "tunnel1"
|
||||
region = "${var.region}"
|
||||
peer_ip = "15.0.0.120"
|
||||
shared_secret = "a secret message"
|
||||
|
||||
|
|
|
@ -38,26 +38,31 @@ state as plain-text.
|
|||
## Example Usage
|
||||
|
||||
```hcl
|
||||
resource "google_compute_network" "network1" {
|
||||
name = "network1"
|
||||
}
|
||||
resource "google_compute_vpn_tunnel" "tunnel1" {
|
||||
name = "tunnel1"
|
||||
peer_ip = "15.0.0.120"
|
||||
shared_secret = "a secret message"
|
||||
|
||||
resource "google_compute_subnetwork" "subnet1" {
|
||||
name = "subnet1"
|
||||
network = "${google_compute_network.network1.self_link}"
|
||||
ip_cidr_range = "10.120.0.0/16"
|
||||
region = "us-central1"
|
||||
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
|
||||
depends_on = [
|
||||
"google_compute_forwarding_rule.fr_esp",
|
||||
"google_compute_forwarding_rule.fr_udp500",
|
||||
"google_compute_forwarding_rule.fr_udp4500",
|
||||
]
|
||||
}
|
||||
|
||||
resource "google_compute_vpn_gateway" "target_gateway" {
|
||||
name = "vpn1"
|
||||
network = "${google_compute_network.network1.self_link}"
|
||||
region = "${google_compute_subnetwork.subnet1.region}"
|
||||
}
|
||||
|
||||
resource "google_compute_network" "network1" {
|
||||
name = "network1"
|
||||
}
|
||||
|
||||
resource "google_compute_address" "vpn_static_ip" {
|
||||
name = "vpn-static-ip"
|
||||
region = "${google_compute_subnetwork.subnet1.region}"
|
||||
}
|
||||
|
||||
resource "google_compute_forwarding_rule" "fr_esp" {
|
||||
|
@ -70,7 +75,7 @@ resource "google_compute_forwarding_rule" "fr_esp" {
|
|||
resource "google_compute_forwarding_rule" "fr_udp500" {
|
||||
name = "fr-udp500"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "500-500"
|
||||
port_range = "500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
@ -78,28 +83,11 @@ resource "google_compute_forwarding_rule" "fr_udp500" {
|
|||
resource "google_compute_forwarding_rule" "fr_udp4500" {
|
||||
name = "fr-udp4500"
|
||||
ip_protocol = "UDP"
|
||||
port_range = "4500-4500"
|
||||
port_range = "4500"
|
||||
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
||||
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_vpn_tunnel" "tunnel1" {
|
||||
name = "tunnel1"
|
||||
peer_ip = "15.0.0.120"
|
||||
shared_secret = "a secret message"
|
||||
|
||||
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
||||
|
||||
local_traffic_selector = ["${google_compute_subnetwork.subnet1.ip_cidr_range}"]
|
||||
remote_traffic_selector = ["172.16.0.0/12"]
|
||||
|
||||
depends_on = [
|
||||
"google_compute_forwarding_rule.fr_esp",
|
||||
"google_compute_forwarding_rule.fr_udp500",
|
||||
"google_compute_forwarding_rule.fr_udp4500",
|
||||
]
|
||||
}
|
||||
|
||||
resource "google_compute_route" "route1" {
|
||||
name = "route1"
|
||||
network = "${google_compute_network.network1.name}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user