@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
151 lines • 6.21 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, Object.assign(Object.assign({}, 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 ? state.certificateChain : undefined;
resourceInputs["domains"] = state ? state.domains : undefined;
resourceInputs["leafCertificate"] = state ? state.leafCertificate : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["notAfter"] = state ? state.notAfter : undefined;
resourceInputs["privateKey"] = state ? state.privateKey : undefined;
resourceInputs["sha1Fingerprint"] = state ? state.sha1Fingerprint : undefined;
resourceInputs["state"] = state ? state.state : undefined;
resourceInputs["type"] = state ? state.type : undefined;
resourceInputs["uuid"] = state ? state.uuid : undefined;
}
else {
const args = argsOrState;
resourceInputs["certificateChain"] = args ? args.certificateChain : undefined;
resourceInputs["domains"] = args ? args.domains : undefined;
resourceInputs["leafCertificate"] = args ? args.leafCertificate : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["privateKey"] = (args === null || args === void 0 ? void 0 : args.privateKey) ? pulumi.secret(args.privateKey) : undefined;
resourceInputs["type"] = args ? args.type : undefined;
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