UNPKG

@lbrlabs/pulumi-scaleway

Version:

A Pulumi package for creating and managing scaleway cloud resources.

255 lines 8.86 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.DomainRecord = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Creates and manages Scaleway Domain record.\ * For more information, see [the documentation](https://www.scaleway.com/en/docs/network/domains-and-dns/how-to/manage-dns-records/). * * ## Examples * * ### Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const www = new scaleway.DomainRecord("www", { * data: "1.2.3.4", * dnsZone: "domain.tld", * ttl: 3600, * type: "A", * }); * const www2 = new scaleway.DomainRecord("www2", { * data: "1.2.3.5", * dnsZone: "domain.tld", * ttl: 3600, * type: "A", * }); * const mx = new scaleway.DomainRecord("mx", { * data: "mx.online.net.", * dnsZone: "domain.tld", * priority: 10, * ttl: 3600, * type: "MX", * }); * const mx2 = new scaleway.DomainRecord("mx2", { * data: "mx-cache.online.net.", * dnsZone: "domain.tld", * priority: 20, * ttl: 3600, * type: "MX", * }); * ``` * * ### With dynamic records * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const geoIp = new scaleway.DomainRecord("geoIp", { * data: "1.2.3.4", * dnsZone: "domain.tld", * geoIp: { * matches: [ * { * continents: ["EU"], * countries: ["FR"], * data: "1.2.3.5", * }, * { * continents: ["NA"], * data: "4.3.2.1", * }, * ], * }, * ttl: 3600, * type: "A", * }); * const httpService = new scaleway.DomainRecord("httpService", { * data: "1.2.3.4", * dnsZone: "domain.tld", * httpService: { * ips: [ * "1.2.3.5", * "1.2.3.6", * ], * mustContain: "up", * strategy: "hashed", * url: "http://mywebsite.com/health", * userAgent: "scw_service_up", * }, * ttl: 3600, * type: "A", * }); * const view = new scaleway.DomainRecord("view", { * data: "1.2.3.4", * dnsZone: "domain.tld", * ttl: 3600, * type: "A", * views: [ * { * data: "1.2.3.5", * subnet: "100.0.0.0/16", * }, * { * data: "1.2.3.6", * subnet: "100.1.0.0/16", * }, * ], * }); * const weighted = new scaleway.DomainRecord("weighted", { * data: "1.2.3.4", * dnsZone: "domain.tld", * ttl: 3600, * type: "A", * weighteds: [ * { * ip: "1.2.3.5", * weight: 1, * }, * { * ip: "1.2.3.6", * weight: 2, * }, * ], * }); * ``` * * ### Create an instance and add records with the new instance IP * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const config = new pulumi.Config(); * const projectId = config.require("projectId"); * const dnsZone = config.require("dnsZone"); * const publicIp = new scaleway.InstanceIp("publicIp", {projectId: projectId}); * const web = new scaleway.InstanceServer("web", { * projectId: projectId, * type: "DEV1-S", * image: "ubuntu_jammy", * tags: [ * "front", * "web", * ], * ipId: publicIp.id, * rootVolume: { * sizeInGb: 20, * }, * }); * const webA = new scaleway.DomainRecord("webA", { * dnsZone: dnsZone, * type: "A", * data: web.publicIp, * ttl: 3600, * }); * const webCname = new scaleway.DomainRecord("webCname", { * dnsZone: dnsZone, * type: "CNAME", * data: `web.${dnsZone}.`, * ttl: 3600, * }); * const webAlias = new scaleway.DomainRecord("webAlias", { * dnsZone: dnsZone, * type: "ALIAS", * data: `web.${dnsZone}.`, * ttl: 3600, * }); * ``` * * ## Multiple records * * Some record types can have multiple `data` with the same `name` (eg: `A`, `AAAA`, `MX`, `NS`...).\ * You can duplicate a resource `scaleway.DomainRecord` with the same `name`, the records will be added. * * Please note, some record (eg: `CNAME`, Multiple dynamic records of different types...) has to be unique. * * ## Import * * Record can be imported using the `{dns_zone}/{id}`, e.g. bash * * ```sh * $ pulumi import scaleway:index/domainRecord:DomainRecord www subdomain.domain.tld/11111111-1111-1111-1111-111111111111 * ``` */ class DomainRecord extends pulumi.CustomResource { /** * Get an existing DomainRecord 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 DomainRecord(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of DomainRecord. 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'] === DomainRecord.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["data"] = state ? state.data : undefined; resourceInputs["dnsZone"] = state ? state.dnsZone : undefined; resourceInputs["geoIp"] = state ? state.geoIp : undefined; resourceInputs["httpService"] = state ? state.httpService : undefined; resourceInputs["keepEmptyZone"] = state ? state.keepEmptyZone : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["priority"] = state ? state.priority : undefined; resourceInputs["projectId"] = state ? state.projectId : undefined; resourceInputs["rootZone"] = state ? state.rootZone : undefined; resourceInputs["ttl"] = state ? state.ttl : undefined; resourceInputs["type"] = state ? state.type : undefined; resourceInputs["views"] = state ? state.views : undefined; resourceInputs["weighteds"] = state ? state.weighteds : undefined; } else { const args = argsOrState; if ((!args || args.data === undefined) && !opts.urn) { throw new Error("Missing required property 'data'"); } if ((!args || args.dnsZone === undefined) && !opts.urn) { throw new Error("Missing required property 'dnsZone'"); } if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["data"] = args ? args.data : undefined; resourceInputs["dnsZone"] = args ? args.dnsZone : undefined; resourceInputs["geoIp"] = args ? args.geoIp : undefined; resourceInputs["httpService"] = args ? args.httpService : undefined; resourceInputs["keepEmptyZone"] = args ? args.keepEmptyZone : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["priority"] = args ? args.priority : undefined; resourceInputs["projectId"] = args ? args.projectId : undefined; resourceInputs["ttl"] = args ? args.ttl : undefined; resourceInputs["type"] = args ? args.type : undefined; resourceInputs["views"] = args ? args.views : undefined; resourceInputs["weighteds"] = args ? args.weighteds : undefined; resourceInputs["rootZone"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(DomainRecord.__pulumiType, name, resourceInputs, opts); } } exports.DomainRecord = DomainRecord; /** @internal */ DomainRecord.__pulumiType = 'scaleway:index/domainRecord:DomainRecord'; //# sourceMappingURL=domainRecord.js.map