@pulumi/ns1
Version: 
A Pulumi package for creating and managing ns1 cloud resources.
224 lines • 7.85 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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Record = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
 * Provides a NS1 Record resource. This can be used to create, modify, and delete records.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as external from "@pulumi/external";
 * import * as ns1 from "@pulumi/ns1";
 * import * as std from "@pulumi/std";
 *
 * const example = new ns1.Zone("example", {zone: "terraform.example.io"});
 * const ns1 = new ns1.DataSource("ns1", {
 *     name: "ns1_source",
 *     sourcetype: "nsone_v1",
 * });
 * const foo = new ns1.DataFeed("foo", {
 *     name: "foo_feed",
 *     sourceId: ns1.id,
 *     config: {
 *         label: "foo",
 *     },
 * });
 * const bar = new ns1.DataFeed("bar", {
 *     name: "bar_feed",
 *     sourceId: ns1.id,
 *     config: {
 *         label: "bar",
 *     },
 * });
 * const www = new ns1.Record("www", {
 *     zone: tld.zone,
 *     domain: `www.${tld.zone}`,
 *     type: "CNAME",
 *     ttl: 60,
 *     meta: {
 *         up: "true",
 *     },
 *     regions: [
 *         {
 *             name: "east",
 *             meta: {
 *                 georegion: "US-EAST",
 *             },
 *         },
 *         {
 *             name: "usa",
 *             meta: {
 *                 country: "US",
 *             },
 *         },
 *     ],
 *     answers: [
 *         {
 *             answer: `sub1.${tld.zone}`,
 *             region: "east",
 *             meta: {
 *                 up: pulumi.interpolate`{"feed":"${foo.id}"}`,
 *             },
 *         },
 *         {
 *             answer: `sub2.${tld.zone}`,
 *             meta: {
 *                 up: pulumi.interpolate`{"feed":"${bar.id}"}`,
 *                 connections: "3",
 *             },
 *         },
 *         {
 *             answer: `sub3.${tld.zone}`,
 *             meta: {
 *                 pulsar: JSON.stringify([{
 *                     job_id: "abcdef",
 *                     bias: "*0.55",
 *                     a5m_cutoff: 0.9,
 *                 }]),
 *                 subdivisions: JSON.stringify({
 *                     BR: [
 *                         "SP",
 *                         "SC",
 *                     ],
 *                     DZ: [
 *                         "01",
 *                         "02",
 *                         "03",
 *                     ],
 *                 }),
 *             },
 *         },
 *     ],
 *     filters: [{
 *         filter: "select_first_n",
 *         config: {
 *             N: "1",
 *         },
 *     }],
 * });
 * // Some other non-NS1 provider that returns a zone with a trailing dot and a domain with a leading dot.
 * const baz = new external.index.Source("baz", {
 *     zone: "terraform.example.io.",
 *     domain: ".www.terraform.example.io",
 * });
 * // Basic record showing how to clean a zone or domain field that comes from
 * // another non-NS1 resource. DNS names often end in '.' characters to signify
 * // the root of the DNS tree, but the NS1 provider does not support this.
 * //
 * // In other cases, a domain or zone may be passed in with a preceding dot ('.')
 * // character which would likewise lead the system to fail.
 * const external = new ns1.Record("external", {
 *     zone: std.replace({
 *         text: zone,
 *         search: "/(^\\.)|(\\.$)/",
 *         replace: "",
 *     }).then(invoke => invoke.result),
 *     domain: std.replace({
 *         text: domain,
 *         search: "/(^\\.)|(\\.$)/",
 *         replace: "",
 *     }).then(invoke => invoke.result),
 *     type: "CNAME",
 * });
 * ```
 *
 * ## NS1 Documentation
 *
 * [Record Api Doc](https://ns1.com/api#records)
 *
 * ## Import
 *
 * ```sh
 * $ pulumi import ns1:index/record:Record <name> <zone>/<domain>/<type>`
 * ```
 *
 * So for the example above:
 *
 * ```sh
 * $ pulumi import ns1:index/record:Record www terraform.example.io/www.terraform.example.io/CNAME`
 * ```
 */
class Record extends pulumi.CustomResource {
    /**
     * Get an existing Record 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 Record(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Record.  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'] === Record.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["answers"] = state?.answers;
            resourceInputs["blockedTags"] = state?.blockedTags;
            resourceInputs["domain"] = state?.domain;
            resourceInputs["filters"] = state?.filters;
            resourceInputs["link"] = state?.link;
            resourceInputs["meta"] = state?.meta;
            resourceInputs["overrideAddressRecords"] = state?.overrideAddressRecords;
            resourceInputs["overrideTtl"] = state?.overrideTtl;
            resourceInputs["regions"] = state?.regions;
            resourceInputs["shortAnswers"] = state?.shortAnswers;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["ttl"] = state?.ttl;
            resourceInputs["type"] = state?.type;
            resourceInputs["useClientSubnet"] = state?.useClientSubnet;
            resourceInputs["zone"] = state?.zone;
        }
        else {
            const args = argsOrState;
            if (args?.domain === undefined && !opts.urn) {
                throw new Error("Missing required property 'domain'");
            }
            if (args?.type === undefined && !opts.urn) {
                throw new Error("Missing required property 'type'");
            }
            if (args?.zone === undefined && !opts.urn) {
                throw new Error("Missing required property 'zone'");
            }
            resourceInputs["answers"] = args?.answers;
            resourceInputs["blockedTags"] = args?.blockedTags;
            resourceInputs["domain"] = args?.domain;
            resourceInputs["filters"] = args?.filters;
            resourceInputs["link"] = args?.link;
            resourceInputs["meta"] = args?.meta;
            resourceInputs["overrideAddressRecords"] = args?.overrideAddressRecords;
            resourceInputs["overrideTtl"] = args?.overrideTtl;
            resourceInputs["regions"] = args?.regions;
            resourceInputs["shortAnswers"] = args?.shortAnswers;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["ttl"] = args?.ttl;
            resourceInputs["type"] = args?.type;
            resourceInputs["useClientSubnet"] = args?.useClientSubnet;
            resourceInputs["zone"] = args?.zone;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Record.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Record = Record;
/** @internal */
Record.__pulumiType = 'ns1:index/record:Record';
//# sourceMappingURL=record.js.map