@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
370 lines • 13 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecordSet = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* 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.
*/
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, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:dns/recordSet: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) {
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["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["managedZone"] = state?.managedZone;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["routingPolicy"] = state?.routingPolicy;
resourceInputs["rrdatas"] = state?.rrdatas;
resourceInputs["ttl"] = state?.ttl;
resourceInputs["type"] = state?.type;
}
else {
const args = argsOrState;
if (args?.managedZone === undefined && !opts.urn) {
throw new Error("Missing required property 'managedZone'");
}
if (args?.name === undefined && !opts.urn) {
throw new Error("Missing required property 'name'");
}
if (args?.type === undefined && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["managedZone"] = args?.managedZone;
resourceInputs["name"] = args?.name;
resourceInputs["project"] = args?.project;
resourceInputs["routingPolicy"] = args?.routingPolicy;
resourceInputs["rrdatas"] = args?.rrdatas;
resourceInputs["ttl"] = args?.ttl;
resourceInputs["type"] = args?.type;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(RecordSet.__pulumiType, name, resourceInputs, opts);
}
}
exports.RecordSet = RecordSet;
//# sourceMappingURL=recordSet.js.map