UNPKG

@pulumi/gcp

Version:

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

347 lines • 11.4 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.RecordSet = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * ## 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. */ 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, id, state, opts) { return new RecordSet(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === RecordSet.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["managedZone"] = state ? state.managedZone : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["routingPolicy"] = state ? state.routingPolicy : undefined; resourceInputs["rrdatas"] = state ? state.rrdatas : undefined; resourceInputs["ttl"] = state ? state.ttl : undefined; resourceInputs["type"] = state ? state.type : undefined; } else { const args = argsOrState; if ((!args || args.managedZone === undefined) && !opts.urn) { throw new Error("Missing required property 'managedZone'"); } if ((!args || args.name === undefined) && !opts.urn) { throw new Error("Missing required property 'name'"); } if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["managedZone"] = args ? args.managedZone : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["routingPolicy"] = args ? args.routingPolicy : undefined; resourceInputs["rrdatas"] = args ? args.rrdatas : undefined; resourceInputs["ttl"] = args ? args.ttl : undefined; resourceInputs["type"] = args ? args.type : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(RecordSet.__pulumiType, name, resourceInputs, opts); } } exports.RecordSet = RecordSet; /** @internal */ RecordSet.__pulumiType = 'gcp:dns/recordSet:RecordSet'; //# sourceMappingURL=recordSet.js.map