WebResource class

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.

> 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.

To get more information about WebResource, see:

Example Usage

Site Verification Domain Record

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const token = gcp.siteverification.getToken({
    type: "INET_DOMAIN",
    identifier: "www.example.com",
    verificationMethod: "DNS_TXT",
});
const example = new gcp.dns.RecordSet("example", {
    managedZone: "example.com",
    name: "www.example.com.",
    type: "TXT",
    rrdatas: [token.then(token => token.token)],
    ttl: 86400,
});
const exampleWebResource = new gcp.siteverification.WebResource("example", {
    site: {
        type: token.then(token => token.type),
        identifier: token.then(token => token.identifier),
    },
    verificationMethod: token.then(token => token.verificationMethod),
}, {
    dependsOn: [example],
});
import pulumi
import pulumi_gcp as gcp

token = gcp.siteverification.get_token(type="INET_DOMAIN",
    identifier="www.example.com",
    verification_method="DNS_TXT")
example = gcp.dns.RecordSet("example",
    managed_zone="example.com",
    name="www.example.com.",
    type="TXT",
    rrdatas=[token.token],
    ttl=86400)
example_web_resource = gcp.siteverification.WebResource("example",
    site={
        "type": token.type,
        "identifier": token.identifier,
    },
    verification_method=token.verification_method,
    opts = pulumi.ResourceOptions(depends_on=[example]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var token = Gcp.SiteVerification.GetToken.Invoke(new()
    {
        Type = "INET_DOMAIN",
        Identifier = "www.example.com",
        VerificationMethod = "DNS_TXT",
    });

    var example = new Gcp.Dns.RecordSet("example", new()
    {
        ManagedZone = "example.com",
        Name = "www.example.com.",
        Type = "TXT",
        Rrdatas = new[]
        {
            token.Apply(getTokenResult => getTokenResult.Token),
        },
        Ttl = 86400,
    });

    var exampleWebResource = new Gcp.SiteVerification.WebResource("example", new()
    {
        Site = new Gcp.SiteVerification.Inputs.WebResourceSiteArgs
        {
            Type = token.Apply(getTokenResult => getTokenResult.Type),
            Identifier = token.Apply(getTokenResult => getTokenResult.Identifier),
        },
        VerificationMethod = token.Apply(getTokenResult => getTokenResult.VerificationMethod),
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            example,
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dns"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/siteverification"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		token, err := siteverification.GetToken(ctx, &siteverification.GetTokenArgs{
			Type:               "INET_DOMAIN",
			Identifier:         "www.example.com",
			VerificationMethod: "DNS_TXT",
		}, nil)
		if err != nil {
			return err
		}
		example, err := dns.NewRecordSet(ctx, "example", &dns.RecordSetArgs{
			ManagedZone: pulumi.String("example.com"),
			Name:        pulumi.String("www.example.com."),
			Type:        pulumi.String("TXT"),
			Rrdatas: pulumi.StringArray{
				pulumi.String(token.Token),
			},
			Ttl: pulumi.Int(86400),
		})
		if err != nil {
			return err
		}
		_, err = siteverification.NewWebResource(ctx, "example", &siteverification.WebResourceArgs{
			Site: &siteverification.WebResourceSiteArgs{
				Type:       pulumi.String(token.Type),
				Identifier: pulumi.String(token.Identifier),
			},
			VerificationMethod: pulumi.String(token.VerificationMethod),
		}, pulumi.DependsOn([]pulumi.Resource{
			example,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

data "gcp_siteverification_gettoken" "token" {
  type                = "INET_DOMAIN"
  identifier          = "www.example.com"
  verification_method = "DNS_TXT"
}

resource "gcp_dns_recordset" "example" {
  managed_zone = "example.com"
  name         = "www.example.com."
  type         = "TXT"
  rrdatas      = [data.gcp_siteverification_gettoken.token.token]
  ttl          = 86400
}
resource "gcp_siteverification_webresource" "example" {
  depends_on = [gcp_dns_recordset.example]
  site = {
    type       = data.gcp_siteverification_gettoken.token.type
    identifier = data.gcp_siteverification_gettoken.token.identifier
  }
  verification_method = data.gcp_siteverification_gettoken.token.verification_method
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.siteverification.SiteverificationFunctions;
import com.pulumi.gcp.siteverification.inputs.GetTokenArgs;
import com.pulumi.gcp.dns.RecordSet;
import com.pulumi.gcp.dns.RecordSetArgs;
import com.pulumi.gcp.siteverification.WebResource;
import com.pulumi.gcp.siteverification.WebResourceArgs;
import com.pulumi.gcp.siteverification.inputs.WebResourceSiteArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var token = SiteverificationFunctions.getToken(GetTokenArgs.builder()
            .type("INET_DOMAIN")
            .identifier("www.example.com")
            .verificationMethod("DNS_TXT")
            .build());

        var example = new RecordSet("example", RecordSetArgs.builder()
            .managedZone("example.com")
            .name("www.example.com.")
            .type("TXT")
            .rrdatas(token.token())
            .ttl(86400)
            .build());

        var exampleWebResource = new WebResource("exampleWebResource", WebResourceArgs.builder()
            .site(WebResourceSiteArgs.builder()
                .type(token.type())
                .identifier(token.identifier())
                .build())
            .verificationMethod(token.verificationMethod())
            .build(), CustomResourceOptions.builder()
                .dependsOn(example)
                .build());

    }
}
resources:
  example:
    type: gcp:dns:RecordSet
    properties:
      managedZone: example.com
      name: www.example.com.
      type: TXT
      rrdatas:
        - ${token.token}
      ttl: 86400
  exampleWebResource:
    type: gcp:siteverification:WebResource
    name: example
    properties:
      site:
        type: ${token.type}
        identifier: ${token.identifier}
      verificationMethod: ${token.verificationMethod}
    options:
      dependsOn:
        - ${example}
variables:
  token:
    fn::invoke:
      function: gcp:siteverification:getToken
      arguments:
        type: INET_DOMAIN
        identifier: www.example.com
        verificationMethod: DNS_TXT

Import

WebResource can be imported using any of these accepted formats:

  • webResource/{{web_resource_id}}
  • {{web_resource_id}}

When using the pulumi import command, WebResource can be imported using one of the formats above. For example:

$ pulumi import gcp:siteverification/webResource:WebResource default webResource/{{web_resource_id}}
$ pulumi import gcp:siteverification/webResource:WebResource default {{web_resource_id}}

Constructors

WebResource(String name, {WebResourceArgs? args, CustomResourceOptions? options})
Creates a new WebResource. name The Pulumi resource name. args Arguments used to configure this WebResource. The set of arguments for WebResource. options Resource options controlling this resource's behavior.
WebResource.reference(String urn)
Creates a typed reference to an existing WebResource resource.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deletionPolicy ↔ Output<String>
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. When a 'terraform destroy' or 'pulumi up' would delete the resource, the command will fail if this field is set to "PREVENT" in Terraform state. When set to "ABANDON", the command will remove the resource from Terraform management without updating or deleting the resource in the API. When set to "DELETE", deleting the resource is allowed.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
owners ↔ Output<List<String>>
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.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
site ↔ Output<WebResourceSite>
Container for the address and type of a site for which a verification token will be verified. Structure is documented below.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
verificationMethod ↔ Output<String>
The verification method for the Site Verification system to use to verify this site or domain. Possible values are: ANALYTICS, DNS_CNAME, DNS_TXT, FILE, META, TAG_MANAGER.
latefinal
webResourceId ↔ Output<String>
The string used to identify this web resource.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {WebResourceState? state, CustomResourceOptions? options}) → WebResource
Gets an existing WebResource resource's state with the given name and id.