Skip to content

Commit

Permalink
Add google_site_verification_web_resource (GoogleCloudPlatform#11624)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirGitsalot authored Sep 13, 2024
1 parent f431d48 commit 8709d00
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 1 deletion.
100 changes: 100 additions & 0 deletions mmv1/products/siteverification/WebResource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Resource
name: 'WebResource'
description: |
A web resource is a website or domain with verified ownership. Once your
ownership is verified you will be able to manage your website in the
[Google Search Console](https://www.google.com/webmasters/tools/).
~> **Note:** The verification data (DNS `TXT` record, HTML file, `meta` tag, etc.)
must already exist before the web resource is created, and must be deleted before
the web resource is destroyed. The Google Site Verification API checks that the
verification data exists at creation time and does not exist at destruction time
and will fail if the required condition is not met.
base_url: webResource
self_link: webResource/{{web_resource_id}}
create_url: webResource?verificationMethod={{verification_method}}
delete_url: webResource/{{web_resource_id}}
id_format: webResource/{{web_resource_id}}
immutable: true
identity:
- web_resource_id
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Getting Started': 'https://developers.google.com/site-verification/v1/getting_started'
api: 'https://developers.google.com/site-verification/v1'
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 60
error_retry_predicates: ['transport_tpg.IsSiteVerificationRetryableError']
examples:
- !ruby/object:Provider::Terraform::Examples
skip_test: true
name: "site_verification_domain_record"
primary_resource_id: "example"
vars:
managed_zone: "example.com"
domain: "www.example.com"
dns_name: "www.example.com."
supports_indirect_user_project_override: true
parameters:
- !ruby/object:Api::Type::Enum
name: 'verification_method'
required: true
immutable: true
url_param_only: true
description: |
The verification method for the Site Verification system to use to verify
this site or domain.
values:
- :ANALYTICS
- :DNS_CNAME
- :DNS_TXT
- :FILE
- :META
- :TAG_MANAGER
properties:
- !ruby/object:Api::Type::String
name: 'web_resource_id'
output: true
api_name: id
description: |
The string used to identify this web resource.
- !ruby/object:Api::Type::NestedObject
name: 'site'
required: true
description: |
Container for the address and type of a site for which a verification token will be verified.
properties:
- !ruby/object:Api::Type::Enum
name: 'type'
required: true
description: |
The type of resource to be verified.
values:
- :INET_DOMAIN
- :SITE
- !ruby/object:Api::Type::String
name: 'identifier'
required: true
description: |
The site identifier. If the type is set to SITE, the identifier is a URL. If the type is
set to INET_DOMAIN, the identifier is a domain name.
- !ruby/object:Api::Type::Array
name: 'owners'
description: |
The email addresses of all direct, verified owners of this exact property. Indirect owners —
for example verified owners of the containing domain—are not included in this list.
output: true
item_type: Api::Type::String
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data "google_site_verification_token" "token" {
type = "INET_DOMAIN"
identifier = "<%= ctx[:vars]['domain'] %>"
verification_method = "DNS_TXT"
}

resource "google_dns_record_set" "example" {
managed_zone = "<%= ctx[:vars]['managed_zone'] %>"
name = "<%= ctx[:vars]['dns_name'] %>"
type = "TXT"
rrdatas = [data.google_site_verification_token.token.token]
ttl = 86400
}

resource "google_site_verification_web_resource" "<%= ctx[:primary_resource_id] %>" {
site {
type = data.google_site_verification_token.token.type
identifier = data.google_site_verification_token.token.identifier
}
verification_method = data.google_site_verification_token.token.verification_method

depends_on = [google_dns_record_set.example]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
<% if version == 'ga' -%>
"github.com/hashicorp/terraform-provider-google/google/services/composer"
"github.com/hashicorp/terraform-provider-google/google/services/siteverification"
<% end -%>
"github.com/hashicorp/terraform-provider-google/google/services/container"
"github.com/hashicorp/terraform-provider-google/google/services/containeraws"
Expand Down
Loading

0 comments on commit 8709d00

Please sign in to comment.