@pulumi/fastly
Version:
A Pulumi package for creating and managing fastly cloud resources.. Based on terraform-provider-fastly: version v4
132 lines • 6.03 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.TlsCertificate = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Uploads a custom TLS certificate to Fastly to be used to terminate TLS traffic.
*
* > Each TLS certificate **must** have its corresponding private key uploaded _prior_ to uploading the certificate. This
* can be achieved in Pulumi using `dependsOn`
*
* ## Example Usage
*
* Basic usage:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as fastly from "@pulumi/fastly";
* import * as tls from "@pulumi/tls";
*
* const key = new tls.index.PrivateKey("key", {algorithm: "RSA"});
* const cert = new tls.index.SelfSignedCert("cert", {
* keyAlgorithm: key.algorithm,
* privateKeyPem: key.privateKeyPem,
* subject: [{
* commonName: "example.com",
* }],
* isCaCertificate: true,
* validityPeriodHours: 360,
* allowedUses: [
* "cert_signing",
* "server_auth",
* ],
* dnsNames: ["example.com"],
* });
* const keyTlsPrivateKey = new fastly.TlsPrivateKey("key", {
* keyPem: key.privateKeyPem,
* name: "tf-demo",
* });
* const example = new fastly.TlsCertificate("example", {
* name: "tf-demo",
* certificateBody: cert.certPem,
* }, {
* dependsOn: [keyTlsPrivateKey],
* });
* ```
*
* ## Updating certificates
*
* There are three scenarios for updating a certificate:
*
* 1. The certificate is about to expire but the private key stays the same.
* 2. The certificate is about to expire but the private key is changing.
* 3. The domains on the certificate are changing.
*
* In the first scenario you only need to update the `certificateBody` attribute of the `fastly.TlsCertificate` resource, while the other scenarios require a new private key (`fastly.TlsPrivateKey`) and certificate (`fastly.TlsCertificate`) to be generated.
*
* When updating both the `fastly.TlsPrivateKey` and `fastly.TlsCertificate` resources, they should be done in multiple plan/apply steps to avoid potential downtime. The new certificate and associated private key must first be created so they exist alongside the currently active resources. Once the new resources have been created, then the `fastly.TlsActivation` can be updated to point to the new certificate. Finally, the original key/certificate resources can be deleted.
*
* ## Import
*
* A certificate can be imported using its Fastly certificate ID, e.g.
*
* ```sh
* $ pulumi import fastly:index/tlsCertificate:TlsCertificate demo xxxxxxxxxxx
* ```
*/
class TlsCertificate extends pulumi.CustomResource {
/**
* Get an existing TlsCertificate 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 TlsCertificate(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of TlsCertificate. 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'] === TlsCertificate.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["certificateBody"] = state ? state.certificateBody : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["domains"] = state ? state.domains : undefined;
resourceInputs["issuedTo"] = state ? state.issuedTo : undefined;
resourceInputs["issuer"] = state ? state.issuer : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["replace"] = state ? state.replace : undefined;
resourceInputs["serialNumber"] = state ? state.serialNumber : undefined;
resourceInputs["signatureAlgorithm"] = state ? state.signatureAlgorithm : undefined;
resourceInputs["updatedAt"] = state ? state.updatedAt : undefined;
}
else {
const args = argsOrState;
if ((!args || args.certificateBody === undefined) && !opts.urn) {
throw new Error("Missing required property 'certificateBody'");
}
resourceInputs["certificateBody"] = args ? args.certificateBody : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["domains"] = undefined /*out*/;
resourceInputs["issuedTo"] = undefined /*out*/;
resourceInputs["issuer"] = undefined /*out*/;
resourceInputs["replace"] = undefined /*out*/;
resourceInputs["serialNumber"] = undefined /*out*/;
resourceInputs["signatureAlgorithm"] = undefined /*out*/;
resourceInputs["updatedAt"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(TlsCertificate.__pulumiType, name, resourceInputs, opts);
}
}
exports.TlsCertificate = TlsCertificate;
/** @internal */
TlsCertificate.__pulumiType = 'fastly:index/tlsCertificate:TlsCertificate';
//# sourceMappingURL=tlsCertificate.js.map