UNPKG

@pulumi/digitalocean

Version:

A Pulumi package for creating and managing DigitalOcean cloud resources.

174 lines 6.96 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.Certificate = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * Provides a DigitalOcean Certificate resource that allows you to manage * certificates for configuring TLS termination in Load Balancers. * Certificates created with this resource can be referenced in your * Load Balancer configuration via their ID. The certificate can either * be a custom one provided by you or automatically generated one with * Let's Encrypt. * * ## Example Usage * * ### Custom Certificate * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * import * as std from "@pulumi/std"; * * const cert = new digitalocean.Certificate("cert", { * name: "custom-terraform-example", * type: digitalocean.CertificateType.Custom, * privateKey: std.file({ * input: "/Users/terraform/certs/privkey.pem", * }).then(invoke => invoke.result), * leafCertificate: std.file({ * input: "/Users/terraform/certs/cert.pem", * }).then(invoke => invoke.result), * certificateChain: std.file({ * input: "/Users/terraform/certs/fullchain.pem", * }).then(invoke => invoke.result), * }); * ``` * * ### Let's Encrypt Certificate * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const cert = new digitalocean.Certificate("cert", { * name: "le-terraform-example", * type: digitalocean.CertificateType.LetsEncrypt, * domains: ["example.com"], * }); * ``` * * ### Use with Other Resources * * Both custom and Let's Encrypt certificates can be used with other resources * including the `digitalocean.LoadBalancer` and `digitalocean.Cdn` resources. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const cert = new digitalocean.Certificate("cert", { * name: "le-terraform-example", * type: digitalocean.CertificateType.LetsEncrypt, * domains: ["example.com"], * }); * // Create a new Load Balancer with TLS termination * const _public = new digitalocean.LoadBalancer("public", { * name: "secure-loadbalancer-1", * region: digitalocean.Region.NYC3, * dropletTag: "backend", * forwardingRules: [{ * entryPort: 443, * entryProtocol: "https", * targetPort: 80, * targetProtocol: "http", * certificateName: cert.name, * }], * }); * ``` * * ## Import * * Certificates can be imported using the certificate `name`, e.g. * * ```sh * $ pulumi import digitalocean:index/certificate:Certificate mycertificate cert-01 * ``` */ class Certificate extends pulumi.CustomResource { /** * Get an existing Certificate 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 Certificate(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'digitalocean:index/certificate:Certificate'; /** * Returns true if the given object is an instance of Certificate. 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'] === Certificate.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["certificateChain"] = state?.certificateChain; resourceInputs["domains"] = state?.domains; resourceInputs["leafCertificate"] = state?.leafCertificate; resourceInputs["name"] = state?.name; resourceInputs["notAfter"] = state?.notAfter; resourceInputs["privateKey"] = state?.privateKey; resourceInputs["sha1Fingerprint"] = state?.sha1Fingerprint; resourceInputs["state"] = state?.state; resourceInputs["type"] = state?.type; resourceInputs["uuid"] = state?.uuid; } else { const args = argsOrState; resourceInputs["certificateChain"] = args?.certificateChain; resourceInputs["domains"] = args?.domains; resourceInputs["leafCertificate"] = args?.leafCertificate; resourceInputs["name"] = args?.name; resourceInputs["privateKey"] = args?.privateKey ? pulumi.secret(args.privateKey) : undefined; resourceInputs["type"] = args?.type; resourceInputs["notAfter"] = undefined /*out*/; resourceInputs["sha1Fingerprint"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["uuid"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["privateKey"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Certificate.__pulumiType, name, resourceInputs, opts); } } exports.Certificate = Certificate; //# sourceMappingURL=certificate.js.map