import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages a set of DNS records within Google Cloud DNS. For more information see [the official documentation](https://cloud.google.com/dns/docs/records/) and * [API](https://cloud.google.com/dns/api/v1/resourceRecordSets). * * > **Note:** The provider treats this resource as an authoritative record set. This means existing records (including the default records) for the given type will be overwritten when you create this resource in Terraform. In addition, the Google Cloud DNS API requires NS and SOA records to be present at all times, so Terraform will not actually remove NS or SOA records on the root of the zone during destroy but will report that it did. * * ## Example Usage * * ### Binding a DNS name to the ephemeral IP of a new instance: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const frontendInstance = new gcp.compute.Instance("frontend", { * networkInterfaces: [{ * accessConfigs: [{}], * network: "default", * }], * name: "frontend", * machineType: "g1-small", * zone: "us-central1-b", * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * }, * }, * }); * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * }); * const frontend = new gcp.dns.RecordSet("frontend", { * name: pulumi.interpolate`frontend.${prod.dnsName}`, * type: "A", * ttl: 300, * managedZone: prod.name, * rrdatas: [frontendInstance.networkInterfaces.apply(networkInterfaces => networkInterfaces[0].accessConfigs?.[0]?.natIp)], * }); * ``` * * ### Adding an A record * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * }); * const a = new gcp.dns.RecordSet("a", { * name: pulumi.interpolate`backend.${prod.dnsName}`, * managedZone: prod.name, * type: "A", * ttl: 300, * rrdatas: ["8.8.8.8"], * }); * ``` * * ### Adding an MX record * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * }); * const mx = new gcp.dns.RecordSet("mx", { * name: prod.dnsName, * managedZone: prod.name, * type: "MX", * ttl: 3600, * rrdatas: [ * "1 aspmx.l.google.com.", * "5 alt1.aspmx.l.google.com.", * "5 alt2.aspmx.l.google.com.", * "10 alt3.aspmx.l.google.com.", * "10 alt4.aspmx.l.google.com.", * ], * }); * ``` * * ### Adding an SPF record * * Quotes (`""`) must be added around your `rrdatas` for a SPF record. Otherwise `rrdatas` string gets split on spaces. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * }); * const spf = new gcp.dns.RecordSet("spf", { * name: pulumi.interpolate`frontend.${prod.dnsName}`, * managedZone: prod.name, * type: "TXT", * ttl: 300, * rrdatas: ["\"v=spf1 ip4:111.111.111.111 include:backoff.email-example.com -all\""], * }); * ``` * * ### Adding a CNAME record * * The list of `rrdatas` should only contain a single string corresponding to the Canonical Name intended. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * }); * const cname = new gcp.dns.RecordSet("cname", { * name: pulumi.interpolate`frontend.${prod.dnsName}`, * managedZone: prod.name, * type: "CNAME", * ttl: 300, * rrdatas: ["frontend.mydomain.com."], * }); * ``` * * ### Setting Routing Policy instead of using rrdatas * ### Geolocation * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const geo = new gcp.dns.RecordSet("geo", { * name: `backend.${prod.dnsName}`, * managedZone: prod.name, * type: "A", * ttl: 300, * routingPolicy: { * geos: [ * { * location: "asia-east1", * rrdatas: ["10.128.1.1"], * }, * { * location: "us-central1", * rrdatas: ["10.130.1.1"], * }, * ], * }, * }); * ``` * * ### Failover * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * visibility: "private", * }); * const prodRegionBackendService = new gcp.compute.RegionBackendService("prod", { * name: "prod-backend", * region: "us-central1", * }); * const prodNetwork = new gcp.compute.Network("prod", {name: "prod-network"}); * const prodForwardingRule = new gcp.compute.ForwardingRule("prod", { * name: "prod-ilb", * region: "us-central1", * loadBalancingScheme: "INTERNAL", * backendService: prodRegionBackendService.id, * allPorts: true, * network: prodNetwork.name, * allowGlobalAccess: true, * }); * const a = new gcp.dns.RecordSet("a", { * name: pulumi.interpolate`backend.${prod.dnsName}`, * managedZone: prod.name, * type: "A", * ttl: 300, * routingPolicy: { * primaryBackup: { * trickleRatio: 0.1, * primary: { * internalLoadBalancers: [{ * loadBalancerType: "regionalL4ilb", * ipAddress: prodForwardingRule.ipAddress, * port: "80", * ipProtocol: "tcp", * networkUrl: prodNetwork.id, * project: prodForwardingRule.project, * region: prodForwardingRule.region, * }], * }, * backupGeos: [ * { * location: "asia-east1", * rrdatas: ["10.128.1.1"], * }, * { * location: "us-west1", * rrdatas: ["10.130.1.1"], * }, * ], * }, * }, * }); * ``` * * ### Public zone failover * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const http_health_check = new gcp.compute.HealthCheck("http-health-check", { * name: "http-health-check", * description: "Health check via http", * timeoutSec: 5, * checkIntervalSec: 30, * healthyThreshold: 4, * unhealthyThreshold: 5, * httpHealthCheck: { * portSpecification: "USE_SERVING_PORT", * }, * }); * const prod = new gcp.dns.ManagedZone("prod", { * name: "prod-zone", * dnsName: "prod.mydomain.com.", * }); * const a = new gcp.dns.RecordSet("a", { * name: pulumi.interpolate`backend.${prod.dnsName}`, * managedZone: prod.name, * type: "A", * ttl: 300, * routingPolicy: { * healthCheck: http_health_check.id, * primaryBackup: { * trickleRatio: 0.1, * primary: { * externalEndpoints: ["10.128.1.1"], * }, * backupGeos: [{ * location: "us-west1", * healthCheckedTargets: { * externalEndpoints: ["10.130.1.1"], * }, * }], * }, * }, * }); * ``` * * ## Import * * DNS record sets can be imported using either of these accepted formats: * * * `projects/{{project}}/managedZones/{{zone}}/rrsets/{{name}}/{{type}}` * * `{{project}}/{{zone}}/{{name}}/{{type}}` * * `{{zone}}/{{name}}/{{type}}` * * When using the `pulumi import` command, DNS record sets can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:dns/recordSet:RecordSet default projects/{{project}}/managedZones/{{zone}}/rrsets/{{name}}/{{type}} * $ pulumi import gcp:dns/recordSet:RecordSet default {{project}}/{{zone}}/{{name}}/{{type}} * $ pulumi import gcp:dns/recordSet:RecordSet default {{zone}}/{{name}}/{{type}} * ``` * * Note: The record name must include the trailing dot at the end. */ export declare class RecordSet extends pulumi.CustomResource { /** * Get an existing RecordSet resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: RecordSetState, opts?: pulumi.CustomResourceOptions): RecordSet; /** * Returns true if the given object is an instance of RecordSet. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is RecordSet; /** * The name of the zone in which this record set will * reside. */ readonly managedZone: pulumi.Output; /** * The DNS name this record set will apply to. */ readonly name: pulumi.Output; /** * The ID of the project in which the resource belongs. If it * is not provided, the provider project is used. */ readonly project: pulumi.Output; /** * The configuration for steering traffic based on query. * Now you can specify either Weighted Round Robin(WRR) type or Geolocation(GEO) type. * Structure is documented below. */ readonly routingPolicy: pulumi.Output; /** * The string data for the records in this record set * whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding `\"` if you don't want your string to get split on spaces. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add `\" \"` inside the Terraform configuration string (e.g. `"first255characters\" \"morecharacters"`). */ readonly rrdatas: pulumi.Output; /** * The time-to-live of this record set (seconds). */ readonly ttl: pulumi.Output; /** * The DNS record set type. * * - - - */ readonly type: pulumi.Output; /** * Create a RecordSet resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: RecordSetArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering RecordSet resources. */ export interface RecordSetState { /** * The name of the zone in which this record set will * reside. */ managedZone?: pulumi.Input; /** * The DNS name this record set will apply to. */ name?: pulumi.Input; /** * The ID of the project in which the resource belongs. If it * is not provided, the provider project is used. */ project?: pulumi.Input; /** * The configuration for steering traffic based on query. * Now you can specify either Weighted Round Robin(WRR) type or Geolocation(GEO) type. * Structure is documented below. */ routingPolicy?: pulumi.Input; /** * The string data for the records in this record set * whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding `\"` if you don't want your string to get split on spaces. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add `\" \"` inside the Terraform configuration string (e.g. `"first255characters\" \"morecharacters"`). */ rrdatas?: pulumi.Input[]>; /** * The time-to-live of this record set (seconds). */ ttl?: pulumi.Input; /** * The DNS record set type. * * - - - */ type?: pulumi.Input; } /** * The set of arguments for constructing a RecordSet resource. */ export interface RecordSetArgs { /** * The name of the zone in which this record set will * reside. */ managedZone: pulumi.Input; /** * The DNS name this record set will apply to. */ name: pulumi.Input; /** * The ID of the project in which the resource belongs. If it * is not provided, the provider project is used. */ project?: pulumi.Input; /** * The configuration for steering traffic based on query. * Now you can specify either Weighted Round Robin(WRR) type or Geolocation(GEO) type. * Structure is documented below. */ routingPolicy?: pulumi.Input; /** * The string data for the records in this record set * whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding `\"` if you don't want your string to get split on spaces. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add `\" \"` inside the Terraform configuration string (e.g. `"first255characters\" \"morecharacters"`). */ rrdatas?: pulumi.Input[]>; /** * The time-to-live of this record set (seconds). */ ttl?: pulumi.Input; /** * The DNS record set type. * * - - - */ type: pulumi.Input; }