@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
151 lines • 5.86 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.Certificate = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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-example",
* type: digitalocean.CertificateType.Custom,
* privateKey: std.file({
* input: "/Users/myuser/certs/privkey.pem",
* }).then(invoke => invoke.result),
* leafCertificate: std.file({
* input: "/Users/myuser/certs/cert.pem",
* }).then(invoke => invoke.result),
* certificateChain: std.file({
* input: "/Users/myuser/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-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-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 });
}
/**
* 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;
/** @internal */
Certificate.__pulumiType = 'digitalocean:index/certificate:Certificate';
//# sourceMappingURL=certificate.js.map