UNPKG

@pulumi/digitalocean

Version:

A Pulumi package for creating and managing DigitalOcean cloud resources.

184 lines 6.75 kB
"use strict"; // *** 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.DatabaseFirewall = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * Provides a DigitalOcean database firewall resource allowing you to restrict * connections to your database to trusted sources. You may limit connections to * specific Droplets, Kubernetes clusters, or IP addresses. * * ## Example Usage * * ### Create a new database firewall allowing multiple IP addresses * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const postgres_example = new digitalocean.DatabaseCluster("postgres-example", { * name: "example-postgres-cluster", * engine: "pg", * version: "15", * size: digitalocean.DatabaseSlug.DB_1VPCU1GB, * region: digitalocean.Region.NYC1, * nodeCount: 1, * }); * const example_fw = new digitalocean.DatabaseFirewall("example-fw", { * clusterId: postgres_example.id, * rules: [ * { * type: "ip_addr", * value: "192.168.1.1", * }, * { * type: "ip_addr", * value: "192.0.2.0", * }, * ], * }); * ``` * * ### Create a new database firewall allowing a Droplet * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const web = new digitalocean.Droplet("web", { * name: "web-01", * size: digitalocean.DropletSlug.DropletS1VCPU1GB, * image: "ubuntu-22-04-x64", * region: digitalocean.Region.NYC3, * }); * const postgres_example = new digitalocean.DatabaseCluster("postgres-example", { * name: "example-postgres-cluster", * engine: "pg", * version: "15", * size: digitalocean.DatabaseSlug.DB_1VPCU1GB, * region: digitalocean.Region.NYC1, * nodeCount: 1, * }); * const example_fw = new digitalocean.DatabaseFirewall("example-fw", { * clusterId: postgres_example.id, * rules: [{ * type: "droplet", * value: web.id, * }], * }); * ``` * * ### Create a new database firewall for a database replica * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const postgres_example = new digitalocean.DatabaseCluster("postgres-example", { * name: "example-postgres-cluster", * engine: "pg", * version: "15", * size: digitalocean.DatabaseSlug.DB_1VPCU1GB, * region: digitalocean.Region.NYC1, * nodeCount: 1, * }); * const replica_example = new digitalocean.DatabaseReplica("replica-example", { * clusterId: postgres_example.id, * name: "replica-example", * size: digitalocean.DatabaseSlug.DB_1VPCU1GB, * region: digitalocean.Region.NYC1, * }); * // Create firewall rule for database replica * const example_fw = new digitalocean.DatabaseFirewall("example-fw", { * clusterId: replica_example.uuid, * rules: [{ * type: "ip_addr", * value: "192.168.1.1", * }], * }); * ``` * * ## Import * * Database firewalls can be imported using the `id` of the target database cluster * For example: * * ```sh * $ pulumi import digitalocean:index/databaseFirewall:DatabaseFirewall example-fw 5f55c6cd-863b-4907-99b8-7e09b0275d54 * ``` */ class DatabaseFirewall extends pulumi.CustomResource { /** * Get an existing DatabaseFirewall 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 DatabaseFirewall(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'digitalocean:index/databaseFirewall:DatabaseFirewall'; /** * Returns true if the given object is an instance of DatabaseFirewall. 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'] === DatabaseFirewall.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["clusterId"] = state?.clusterId; resourceInputs["rules"] = state?.rules; } else { const args = argsOrState; if (args?.clusterId === undefined && !opts.urn) { throw new Error("Missing required property 'clusterId'"); } if (args?.rules === undefined && !opts.urn) { throw new Error("Missing required property 'rules'"); } resourceInputs["clusterId"] = args?.clusterId; resourceInputs["rules"] = args?.rules; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(DatabaseFirewall.__pulumiType, name, resourceInputs, opts); } } exports.DatabaseFirewall = DatabaseFirewall; //# sourceMappingURL=databaseFirewall.js.map