-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
2ac4e21
commit fcea0cb
Showing
10 changed files
with
606 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
```release-note:new-resource | ||
`google_service_networking_peered_dns_domain` | ||
``` | ||
```release-note:new-datasource | ||
`google_service_networking_peered_dns_domain` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
google/data_source_google_service_networking_peered_dns_domain.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package google | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: resourceGoogleServiceNetworkingPeeredDNSDomainRead, | ||
Schema: map[string]*schema.Schema{ | ||
"project": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"network": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"service": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"dns_suffix": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"parent": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
google/data_source_google_service_networking_peered_dns_domain_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic(t *testing.T) { | ||
t.Parallel() | ||
org := getTestOrgFromEnv(t) | ||
billingId := getTestBillingAccountFromEnv(t) | ||
|
||
project := fmt.Sprintf("tf-test-%d", randInt(t)) | ||
|
||
resourceName := "data.google_service_networking_peered_dns_domain.acceptance" | ||
name := fmt.Sprintf("test-name-%d", randInt(t)) | ||
network := "test-network" | ||
service := "servicenetworking.googleapis.com" | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckGoogleServiceNetworkingPeeredDnsDomain_basic(project, org, billingId, name, network, service), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "name"), | ||
resource.TestCheckResourceAttrSet(resourceName, "network"), | ||
resource.TestCheckResourceAttrSet(resourceName, "dns_suffix"), | ||
resource.TestCheckResourceAttrSet(resourceName, "service"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckGoogleServiceNetworkingPeeredDnsDomain_basic(project, org, billing, name, network, service string) string { | ||
return fmt.Sprintf(` | ||
resource "google_project" "host" { | ||
project_id = "%s" | ||
name = "%s" | ||
org_id = "%s" | ||
billing_account = "%s" | ||
} | ||
resource "google_project_service" "host-compute" { | ||
project = google_project.host.project_id | ||
service = "compute.googleapis.com" | ||
} | ||
resource "google_project_service" "host" { | ||
project = google_project.host.project_id | ||
service = "%s" | ||
} | ||
resource "google_compute_network" "test" { | ||
name = "test-network" | ||
project = google_project.host.project_id | ||
routing_mode = "GLOBAL" | ||
depends_on = [google_project_service.host-compute] | ||
} | ||
resource "google_compute_global_address" "host-private-access" { | ||
name = "private-ip-alloc-host" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 24 | ||
address = "192.168.255.0" | ||
network = google_compute_network.test.name | ||
project = google_project.host.project_id | ||
depends_on = [ | ||
google_project_service.host-compute, | ||
google_project_service.host, | ||
google_compute_network.test, | ||
] | ||
} | ||
resource "google_service_networking_connection" "host-private-access" { | ||
network = google_compute_network.test.self_link | ||
service = "%s" | ||
reserved_peering_ranges = [google_compute_global_address.host-private-access.name] | ||
depends_on = [ | ||
google_project_service.host, | ||
google_compute_network.test, | ||
google_compute_global_address.host-private-access, | ||
] | ||
} | ||
resource "google_service_networking_peered_dns_domain" "acceptance" { | ||
name = "%s" | ||
project = google_project.host.number | ||
network = google_compute_network.test.name | ||
dns_suffix = "example.com." | ||
service = "%s" | ||
depends_on = [ | ||
google_compute_network.test, | ||
google_service_networking_connection.host-private-access, | ||
] | ||
} | ||
data "google_service_networking_peered_dns_domain" "acceptance" { | ||
project = google_project.host.number | ||
name = "%s" | ||
network = google_compute_network.test.name | ||
service = "%s" | ||
depends_on = [ | ||
google_service_networking_peered_dns_domain.acceptance, | ||
] | ||
} | ||
`, project, project, org, billing, service, service, name, service, name, service) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.