Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certificate_manager_dns_authorization examples to use sweepable names #7510

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,26 @@ func testAccComputeTargetHttpsProxy_basic1(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_https_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "httpsproxy-test-%s"
hao-nan-li marked this conversation as resolved.
Show resolved Hide resolved
name = "tf-test-httpsproxy-%s"
url_map = google_compute_url_map.foobar.self_link
ssl_certificates = [google_compute_ssl_certificate.foobar1.self_link]
ssl_policy = google_compute_ssl_policy.foobar.self_link
}

resource "google_compute_backend_service" "foobar" {
name = "httpsproxy-test-backend-%s"
name = "tf-test-httpsproxy-backend-%s"
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
name = "httpsproxy-test-health-check-%s"
name = "tf-test-httpsproxy-check-%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}

resource "google_compute_url_map" "foobar" {
name = "httpsproxy-test-url-map-%s"
name = "tf-test-httpsproxy-urlmap-%s"
default_service = google_compute_backend_service.foobar.self_link
host_rule {
hosts = ["mysite.com", "myothersite.com"]
Expand All @@ -190,21 +190,21 @@ resource "google_compute_url_map" "foobar" {
}

resource "google_compute_ssl_policy" "foobar" {
name = "sslproxy-test-%s"
name = "tf-test-sslproxy-%s"
description = "my-description"
min_tls_version = "TLS_1_2"
profile = "MODERN"
}

resource "google_compute_ssl_certificate" "foobar1" {
name = "httpsproxy-test-cert1-%s"
name = "tf-test-httpsproxy-cert1-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
}

resource "google_compute_ssl_certificate" "foobar2" {
name = "httpsproxy-test-cert2-%s"
name = "tf-test-httpsproxy-cert2-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
Expand All @@ -216,7 +216,7 @@ func testAccComputeTargetHttpsProxy_basic2(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_https_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "httpsproxy-test-%s"
name = "tf-test-httpsproxy-%s"
url_map = google_compute_url_map.foobar.self_link
ssl_certificates = [
google_compute_ssl_certificate.foobar1.self_link,
Expand All @@ -226,19 +226,19 @@ resource "google_compute_target_https_proxy" "foobar" {
}

resource "google_compute_backend_service" "foobar" {
name = "httpsproxy-test-backend-%s"
name = "tf-test-httpsproxy-backend-%s"
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
name = "httpsproxy-test-health-check-%s"
name = "tf-test-httpsproxy-check-%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}

resource "google_compute_url_map" "foobar" {
name = "httpsproxy-test-url-map-%s"
name = "tf-test-httpsproxy-urlmap-%s"
default_service = google_compute_backend_service.foobar.self_link
host_rule {
hosts = ["mysite.com", "myothersite.com"]
Expand All @@ -260,21 +260,21 @@ resource "google_compute_url_map" "foobar" {
}

resource "google_compute_ssl_policy" "foobar" {
name = "sslproxy-test-%s"
name = "tf-test-sslproxy-%s"
description = "my-description"
min_tls_version = "TLS_1_2"
profile = "MODERN"
}

resource "google_compute_ssl_certificate" "foobar1" {
name = "httpsproxy-test-cert1-%s"
name = "tf-test-httpsproxy-cert1-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
}

resource "google_compute_ssl_certificate" "foobar2" {
name = "httpsproxy-test-cert2-%s"
name = "tf-test-httpsproxy-cert2-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
Expand All @@ -286,41 +286,41 @@ func testAccComputeTargetHttpsProxy_certificateMap(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_https_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "httpsproxy-test-%s"
name = "tf-test-httpsproxy-%s"
url_map = google_compute_url_map.foobar.self_link
certificate_map = "//certificatemanager.googleapis.com/${google_certificate_manager_certificate_map.map.id}"
}

resource "google_compute_backend_service" "foobar" {
name = "httpsproxy-test-backend-%s"
name = "tf-test-httpsproxy-backend-%s"
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
name = "httpsproxy-test-health-check-%s"
name = "tf-test-httpsproxy-check-%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}

resource "google_compute_url_map" "foobar" {
name = "httpsproxy-test-url-map-%s"
name = "tf-test-httpsproxy-urlmap-%s"
default_service = google_compute_backend_service.foobar.self_link
}

resource "google_certificate_manager_certificate_map" "map" {
name = "certificatemap-test-%s"
name = "tf-test-certmap-%s"
}

resource "google_certificate_manager_certificate_map_entry" "map_entry" {
name = "certificatemapentry-test-%s"
name = "tf-test-certmapentry-%s"
map = google_certificate_manager_certificate_map.map.name
certificates = [google_certificate_manager_certificate.certificate.id]
matcher = "PRIMARY"
}

resource "google_certificate_manager_certificate" "certificate" {
name = "certificate-test-%s"
name = "tf-test-cert-%s"
scope = "DEFAULT"
managed {
domains = [
Expand All @@ -333,7 +333,7 @@ resource "google_certificate_manager_certificate" "certificate" {
}

resource "google_certificate_manager_dns_authorization" "instance" {
name = "dnsauthorization-test-%s"
name = "tf-test-dnsauthz-%s"
domain = "mysite.com"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
)

func TestAccComputeTargetSslProxy_update(t *testing.T) {
target := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
sslPolicy := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
cert1 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
cert2 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
backend1 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
backend2 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
hc := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
target := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
sslPolicy := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
cert1 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
cert2 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
backend1 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
backend2 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
hc := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))

resourceSuffix := RandString(t, 10)
var proxy compute.TargetSslProxy
Expand Down Expand Up @@ -233,19 +233,19 @@ func testAccComputeTargetSslProxy_certificateMap1(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_ssl_proxy" "with_certificate_map" {
description = "Resource created for Terraform acceptance testing"
name = "ssl-proxy-%s"
name = "tf-test-ssl-proxy-%s"
backend_service = google_compute_backend_service.foo.self_link
certificate_map = "//certificatemanager.googleapis.com/${google_certificate_manager_certificate_map.map1.id}"
}

resource "google_compute_backend_service" "foo" {
name = "backend-service-%s"
name = "tf-test-backend-%s"
protocol = "SSL"
health_checks = [google_compute_health_check.zero.self_link]
}

resource "google_compute_health_check" "zero" {
name = "health-check-%s"
name = "tf-test-check-%s"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
Expand All @@ -254,17 +254,17 @@ resource "google_compute_health_check" "zero" {
}

resource "google_certificate_manager_certificate_map" "map1" {
name = "certificatemap-test-1-%s"
name = "tf-test-certmap-1-%s"
}
resource "google_certificate_manager_certificate_map_entry" "map_entry" {
name = "certificatemapentry-test-%s"
name = "tf-test-certmapentry-%s"
map = google_certificate_manager_certificate_map.map1.name
certificates = [google_certificate_manager_certificate.certificate.id]
matcher = "PRIMARY"
}

resource "google_certificate_manager_certificate" "certificate" {
name = "certificate-test-%s"
name = "tf-test-cert-%s"
scope = "DEFAULT"
managed {
domains = [
Expand All @@ -277,7 +277,7 @@ resource "google_certificate_manager_certificate" "certificate" {
}

resource "google_certificate_manager_dns_authorization" "instance" {
name = "dnsauthorization-test-%s"
name = "tf-test-dnsauthz-%s"
domain = "mysite.com"
}
`, id, id, id, id, id, id, id)
Expand All @@ -287,19 +287,19 @@ func testAccComputeTargetSslProxy_certificateMap2(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_ssl_proxy" "with_certificate_map" {
description = "Resource created for Terraform acceptance testing"
name = "ssl-proxy-%s"
name = "tf-test-ssl-proxy-%s"
backend_service = google_compute_backend_service.foo.self_link
certificate_map = "//certificatemanager.googleapis.com/${google_certificate_manager_certificate_map.map2.id}"
}

resource "google_compute_backend_service" "foo" {
name = "backend-service-%s"
name = "tf-test-backend-%s"
protocol = "SSL"
health_checks = [google_compute_health_check.zero.self_link]
}

resource "google_compute_health_check" "zero" {
name = "health-check-%s"
name = "tf-test-check-%s"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
Expand All @@ -308,22 +308,22 @@ resource "google_compute_health_check" "zero" {
}

resource "google_certificate_manager_certificate_map" "map1" {
name = "certificatemap-test-1-%s"
name = "tf-test-certmap-1-%s"
}

resource "google_certificate_manager_certificate_map" "map2" {
name = "certificatemap-test-2-%s"
name = "tf-test-certmap-2-%s"
}

resource "google_certificate_manager_certificate_map_entry" "map_entry" {
name = "certificatemapentry-test-%s"
name = "tf-test-certmapentry-%s"
map = google_certificate_manager_certificate_map.map1.name
certificates = [google_certificate_manager_certificate.certificate.id]
matcher = "PRIMARY"
}

resource "google_certificate_manager_certificate" "certificate" {
name = "certificate-test-%s"
name = "tf-test-cert-%s"
scope = "DEFAULT"
managed {
domains = [
Expand All @@ -336,7 +336,7 @@ resource "google_certificate_manager_certificate" "certificate" {
}

resource "google_certificate_manager_dns_authorization" "instance" {
name = "dnsauthorization-test-%s"
name = "tf-test-dnsauthz-%s"
domain = "mysite.com"
}
`, id, id, id, id, id, id, id, id)
Expand Down