Skip to content

Commit 756115b

Browse files
Add datasource for google_certificate_manager_dns_authorization (#14865) (#24009)
[upstream:5e2654dd6af322709f7204de83e75d7fa98858f3] Signed-off-by: Modular Magician <[email protected]>
1 parent 63b5683 commit 756115b

File tree

5 files changed

+186
-0
lines changed

5 files changed

+186
-0
lines changed

.changelog/14865.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-datasource
2+
`google_certificate_manager_dns_authorization`
3+
```

google/provider/provider_mmv1_resources.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
214214
"google_bigquery_default_service_account": bigquery.DataSourceGoogleBigqueryDefaultServiceAccount(),
215215
"google_certificate_manager_certificates": certificatemanager.DataSourceGoogleCertificateManagerCertificates(),
216216
"google_certificate_manager_certificate_map": certificatemanager.DataSourceGoogleCertificateManagerCertificateMap(),
217+
"google_certificate_manager_dns_authorization": certificatemanager.DataSourceGoogleCertificateManagerDnsAuthorization(),
217218
"google_cloudbuild_trigger": cloudbuild.DataSourceGoogleCloudBuildTrigger(),
218219
"google_cloudfunctions_function": cloudfunctions.DataSourceGoogleCloudFunctionsFunction(),
219220
"google_cloudfunctions2_function": cloudfunctions2.DataSourceGoogleCloudFunctions2Function(),
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/certificatemanager/data_source_google_certificate_manager_dns_authorization.go
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package certificatemanager
18+
19+
import (
20+
"fmt"
21+
22+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
23+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
24+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
25+
)
26+
27+
func DataSourceGoogleCertificateManagerDnsAuthorization() *schema.Resource {
28+
// Generate datasource schema from resource
29+
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceCertificateManagerDnsAuthorization().Schema)
30+
31+
// Set 'Required' schema elements
32+
tpgresource.AddRequiredFieldsToSchema(dsSchema, "name", "domain")
33+
// Set 'Optional' schema elements
34+
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project", "location")
35+
36+
return &schema.Resource{
37+
Read: dataSourceGoogleCertificateManagerDnsAuthorizationRead,
38+
Schema: dsSchema,
39+
}
40+
}
41+
42+
func dataSourceGoogleCertificateManagerDnsAuthorizationRead(d *schema.ResourceData, meta interface{}) error {
43+
id, err := tpgresource.ReplaceVars(d, meta.(*transport_tpg.Config), "projects/{{project}}/locations/{{location}}/dnsAuthorizations/{{name}}")
44+
if err != nil {
45+
return fmt.Errorf("Error constructing id: %s", err)
46+
}
47+
d.SetId(id)
48+
49+
err = resourceCertificateManagerDnsAuthorizationRead(d, meta)
50+
if err != nil {
51+
return err
52+
}
53+
54+
if err := tpgresource.SetDataSourceLabels(d); err != nil {
55+
return err
56+
}
57+
58+
if d.Id() == "" {
59+
return fmt.Errorf("%s not found", id)
60+
}
61+
return nil
62+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/certificatemanager/data_source_google_certificate_manager_dns_authorization_test.go
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package certificatemanager_test
18+
19+
import (
20+
"testing"
21+
22+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
23+
"github.com/hashicorp/terraform-provider-google/google/acctest"
24+
)
25+
26+
func TestAccCertificateManagerDnsAuthorizationDatasource(t *testing.T) {
27+
t.Parallel()
28+
29+
context := map[string]interface{}{
30+
"random_suffix": acctest.RandString(t, 10),
31+
}
32+
33+
acctest.VcrTest(t, resource.TestCase{
34+
PreCheck: func() { acctest.AccTestPreCheck(t) },
35+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
36+
Steps: []resource.TestStep{
37+
{
38+
Config: testAccCertificateManagerDnsAuthorizationDatasourceConfig(context),
39+
Check: resource.ComposeTestCheckFunc(
40+
acctest.CheckDataSourceStateMatchesResourceState("data.google_certificate_manager_dns_authorization.default", "google_certificate_manager_dns_authorization.default"),
41+
),
42+
},
43+
},
44+
})
45+
}
46+
47+
func testAccCertificateManagerDnsAuthorizationDatasourceConfig(context map[string]interface{}) string {
48+
return acctest.Nprintf(`
49+
resource "google_certificate_manager_dns_authorization" "default" {
50+
name = "tf-test-dns-auth-%{random_suffix}"
51+
location = "global"
52+
description = "The default dns"
53+
domain = "%{random_suffix}.hashicorptest.com"
54+
55+
}
56+
57+
data "google_certificate_manager_dns_authorization" "default" {
58+
name = google_certificate_manager_dns_authorization.default.name
59+
domain = "%{random_suffix}.hashicorptest.com"
60+
location = "global"
61+
62+
}
63+
`, context)
64+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: Handwritten ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This code is generated by Magic Modules using the following:
9+
#
10+
# Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/website/docs/d/certificate_manager_dns_authorization.html.markdown
11+
#
12+
# DO NOT EDIT this file directly. Any changes made to this file will be
13+
# overwritten during the next generation cycle.
14+
#
15+
# ----------------------------------------------------------------------------
16+
subcategory: "Certificate Manager"
17+
description: |-
18+
Fetches the details of a Certificate Manager DNS Authorization.
19+
---
20+
21+
# google_certificate_manager_dns_authorization
22+
23+
Use this data source to get information about a Certificate Manager DNS Authorization. For more details, see the [API documentation](https://cloud.google.com/certificate-manager/docs/reference/certificate-manager/rest/v1/projects.locations.dnsAuthorizations).
24+
25+
## Example Usage
26+
27+
```hcl
28+
data "google_certificate_manager_dns_authorization" "default" {
29+
name = "my-dns-auth"
30+
location = "global"
31+
}
32+
```
33+
34+
## Argument Reference
35+
36+
The following arguments are supported:
37+
38+
* `name` -
39+
(Required)
40+
The name of the DNS Authorization.
41+
42+
* `domain` -
43+
(Required)
44+
The name of the DNS Authorization.
45+
46+
* `location` -
47+
(Optional)
48+
The Certificate Manager location. If not specified, "global" is used.
49+
50+
* `project` -
51+
(Optional)
52+
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
53+
54+
## Attributes Reference
55+
56+
See [google_certificate_manager_dns_authorization](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/certificate_manager_dns_authorization) resource for details of all the available attributes.

0 commit comments

Comments
 (0)