UNPKG

@pulumi/fastly

Version:

A Pulumi package for creating and managing fastly cloud resources.. Based on terraform-provider-fastly: version v4

143 lines 7.03 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.TlsSubscriptionValidation = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * This resource represents a successful validation of a Fastly TLS Subscription in concert with other resources. * * Most commonly, this resource is used together with a resource for a DNS record and `fastly.TlsSubscription` to request a DNS validated certificate, deploy the required validation records and wait for validation to complete. * * > **Warning:** This resource implements a part of the validation workflow. It does not represent a real-world entity in Fastly, therefore changing or deleting this resource on its own has no immediate effect. * * ## Example Usage * * DNS Validation with AWS Route53: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as fastly from "@pulumi/fastly"; * import * as std from "@pulumi/std"; * * // NOTE: Creating a hosted zone will automatically create SOA/NS records. * const production = new aws.index.Route53Zone("production", {name: "example.com"}); * const example = new aws.index.Route53domainsRegisteredDomain("example", { * nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({ * name: entry.value, * })), * domainName: "example.com", * }); * const subdomains = [ * "a.example.com", * "b.example.com", * ]; * const exampleServiceVcl = new fastly.ServiceVcl("example", { * domains: subdomains.map((v, k) => ({key: k, value: v})).map(entry => ({ * name: entry.value, * })), * name: "example-service", * backends: [{ * address: "127.0.0.1", * name: "localhost", * }], * forceDestroy: true, * }); * const exampleTlsSubscription = new fastly.TlsSubscription("example", { * domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))), * certificateAuthority: "lets-encrypt", * }); * const domainValidation: aws.index.Route53Record[] = []; * exampleTlsSubscription.domains.apply(domains => { * for (const range of Object.entries(domains.reduce((__obj, domain) => ({ ...__obj, [domain]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${domain}`).map(obj => (obj)))[0] }))).map(([k, v]) => ({key: k, value: v}))) { * domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, { * name: range.value.recordName, * type: range.value.recordType, * zoneId: production.zoneId, * allowOverwrite: true, * records: [range.value.recordValue], * ttl: 60, * }, { * dependsOn: [exampleTlsSubscription], * })); * } * }); * // This is a resource that other resources can depend on if they require the certificate to be issued. * // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached). * const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, { * dependsOn: [domainValidation], * }); * // This data source lists all available configuration objects. * // It uses a `default` attribute to narrow down the list to just one configuration object. * // If the filtered list has a length that is not exactly one element, you'll see an error returned. * // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below). * // * // IMPORTANT: Not all customers will have a 'default' configuration. * // If you have issues filtering with `default = true`, then you may need another attribute. * // Refer to the fastly_tls_configuration documentation for available attributes: * // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional * const defaultTls = fastly.getTlsConfiguration({ * "default": true, * }); * // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple subdomain records. * const subdomain: aws.index.Route53Record[] = []; * for (const range = {value: 0}; range.value < std.index.toset({ * input: subdomains, * }).result; range.value++) { * subdomain.push(new aws.index.Route53Record(`subdomain-${range.value}`, { * name: range.value, * records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)), * ttl: 300, * type: "CNAME", * zoneId: production.zoneId, * })); * } * ``` */ class TlsSubscriptionValidation extends pulumi.CustomResource { /** * Get an existing TlsSubscriptionValidation 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 TlsSubscriptionValidation(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of TlsSubscriptionValidation. 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'] === TlsSubscriptionValidation.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["subscriptionId"] = state?.subscriptionId; } else { const args = argsOrState; if (args?.subscriptionId === undefined && !opts.urn) { throw new Error("Missing required property 'subscriptionId'"); } resourceInputs["subscriptionId"] = args?.subscriptionId; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(TlsSubscriptionValidation.__pulumiType, name, resourceInputs, opts); } } exports.TlsSubscriptionValidation = TlsSubscriptionValidation; /** @internal */ TlsSubscriptionValidation.__pulumiType = 'fastly:index/tlsSubscriptionValidation:TlsSubscriptionValidation'; //# sourceMappingURL=tlsSubscriptionValidation.js.map