UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

409 lines (408 loc) • 12.6 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * ## 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.", * }); * 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}} * ``` * * ```sh * $ pulumi import gcp:dns/recordSet:RecordSet default {{project}}/{{zone}}/{{name}}/{{type}} * ``` * * ```sh * $ 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<pulumi.ID>, 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<string>; /** * The DNS name this record set will apply to. */ readonly name: pulumi.Output<string>; /** * The ID of the project in which the resource belongs. If it * is not provided, the provider project is used. */ readonly project: pulumi.Output<string>; /** * 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<outputs.dns.RecordSetRoutingPolicy | undefined>; readonly rrdatas: pulumi.Output<string[] | undefined>; /** * The time-to-live of this record set (seconds). */ readonly ttl: pulumi.Output<number | undefined>; /** * The DNS record set type. * * - - - */ readonly type: pulumi.Output<string>; /** * 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<string>; /** * The DNS name this record set will apply to. */ name?: pulumi.Input<string>; /** * The ID of the project in which the resource belongs. If it * is not provided, the provider project is used. */ project?: pulumi.Input<string>; /** * 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<inputs.dns.RecordSetRoutingPolicy>; rrdatas?: pulumi.Input<pulumi.Input<string>[]>; /** * The time-to-live of this record set (seconds). */ ttl?: pulumi.Input<number>; /** * The DNS record set type. * * - - - */ type?: pulumi.Input<string>; } /** * 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<string>; /** * The DNS name this record set will apply to. */ name: pulumi.Input<string>; /** * The ID of the project in which the resource belongs. If it * is not provided, the provider project is used. */ project?: pulumi.Input<string>; /** * 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<inputs.dns.RecordSetRoutingPolicy>; rrdatas?: pulumi.Input<pulumi.Input<string>[]>; /** * The time-to-live of this record set (seconds). */ ttl?: pulumi.Input<number>; /** * The DNS record set type. * * - - - */ type: pulumi.Input<string>; }