UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

194 lines • 10 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.DomainName = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Registers a custom domain name for use with AWS API Gateway. Additional information about this functionality * can be found in the [API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html). * * This resource just establishes ownership of and the TLS settings for * a particular domain name. An API can be attached to a particular path * under the registered domain name using * the `aws.apigateway.BasePathMapping` resource. * * API Gateway domains can be defined as either 'edge-optimized' or 'regional'. In an edge-optimized configuration, * API Gateway internally creates and manages a CloudFront distribution to route requests on the given hostname. In * addition to this resource it's necessary to create a DNS record corresponding to the given domain name which is an alias * (either Route53 alias or traditional CNAME) to the Cloudfront domain name exported in the `cloudfrontDomainName` * attribute. * * In a regional configuration, API Gateway does not create a CloudFront distribution to route requests to the API, though * a distribution can be created if needed. In either case, it is necessary to create a DNS record corresponding to the * given domain name which is an alias (either Route53 alias or traditional CNAME) to the regional domain name exported in * the `regionalDomainName` attribute. * * > **Note:** API Gateway requires the use of AWS Certificate Manager (ACM) certificates instead of Identity and Access Management (IAM) certificates in regions that support ACM. Regions that support ACM can be found in the [Regions and Endpoints Documentation](https://docs.aws.amazon.com/general/latest/gr/rande.html#acm_region). To import an existing private key and certificate into ACM or request an ACM certificate, see the `aws.acm.Certificate` resource. * * > **Note:** The `aws.apigateway.DomainName` resource expects dependency on the `aws.acm.CertificateValidation` as * only verified certificates can be used. This can be made either explicitly by adding the * `dependsOn = [aws_acm_certificate_validation.cert]` attribute. Or implicitly by referring certificate ARN * from the validation resource where it will be available after the resource creation: * `regionalCertificateArn = aws_acm_certificate_validation.cert.certificate_arn`. * * ## Example Usage * * ### Edge Optimized (ACM Certificate) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.apigateway.DomainName("example", { * certificateArn: exampleAwsAcmCertificateValidation.certificateArn, * domainName: "api.example.com", * }); * // Example DNS record using Route53. * // Route53 is not specifically required; any DNS host can be used. * const exampleRecord = new aws.route53.Record("example", { * name: example.domainName, * type: aws.route53.RecordType.A, * zoneId: exampleAwsRoute53Zone.id, * aliases: [{ * evaluateTargetHealth: true, * name: example.cloudfrontDomainName, * zoneId: example.cloudfrontZoneId, * }], * }); * ``` * * ### Regional (ACM Certificate) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.apigateway.DomainName("example", { * domainName: "api.example.com", * regionalCertificateArn: exampleAwsAcmCertificateValidation.certificateArn, * endpointConfiguration: { * types: "REGIONAL", * }, * }); * // Example DNS record using Route53. * // Route53 is not specifically required; any DNS host can be used. * const exampleRecord = new aws.route53.Record("example", { * name: example.domainName, * type: aws.route53.RecordType.A, * zoneId: exampleAwsRoute53Zone.id, * aliases: [{ * evaluateTargetHealth: true, * name: example.regionalDomainName, * zoneId: example.regionalZoneId, * }], * }); * ``` * * ## Import * * For a private custom domain name: * * Using `pulumi import`, import API Gateway domain names using their `name` or `name` and `domain_name_id` (for private custom domain names). For example: * * ```sh * $ pulumi import aws:apigateway/domainName:DomainName example dev.example.com * ``` * For a private custom domain name: * * ```sh * $ pulumi import aws:apigateway/domainName:DomainName example dev.api.internal.example.com/abcde12345 * ``` */ class DomainName extends pulumi.CustomResource { /** * Get an existing DomainName 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 DomainName(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of DomainName. 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'] === DomainName.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["arn"] = state?.arn; resourceInputs["certificateArn"] = state?.certificateArn; resourceInputs["certificateBody"] = state?.certificateBody; resourceInputs["certificateChain"] = state?.certificateChain; resourceInputs["certificateName"] = state?.certificateName; resourceInputs["certificatePrivateKey"] = state?.certificatePrivateKey; resourceInputs["certificateUploadDate"] = state?.certificateUploadDate; resourceInputs["cloudfrontDomainName"] = state?.cloudfrontDomainName; resourceInputs["cloudfrontZoneId"] = state?.cloudfrontZoneId; resourceInputs["domainName"] = state?.domainName; resourceInputs["domainNameId"] = state?.domainNameId; resourceInputs["endpointConfiguration"] = state?.endpointConfiguration; resourceInputs["mutualTlsAuthentication"] = state?.mutualTlsAuthentication; resourceInputs["ownershipVerificationCertificateArn"] = state?.ownershipVerificationCertificateArn; resourceInputs["policy"] = state?.policy; resourceInputs["region"] = state?.region; resourceInputs["regionalCertificateArn"] = state?.regionalCertificateArn; resourceInputs["regionalCertificateName"] = state?.regionalCertificateName; resourceInputs["regionalDomainName"] = state?.regionalDomainName; resourceInputs["regionalZoneId"] = state?.regionalZoneId; resourceInputs["securityPolicy"] = state?.securityPolicy; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; } else { const args = argsOrState; if (args?.domainName === undefined && !opts.urn) { throw new Error("Missing required property 'domainName'"); } resourceInputs["certificateArn"] = args?.certificateArn; resourceInputs["certificateBody"] = args?.certificateBody; resourceInputs["certificateChain"] = args?.certificateChain; resourceInputs["certificateName"] = args?.certificateName; resourceInputs["certificatePrivateKey"] = args?.certificatePrivateKey ? pulumi.secret(args.certificatePrivateKey) : undefined; resourceInputs["domainName"] = args?.domainName; resourceInputs["endpointConfiguration"] = args?.endpointConfiguration; resourceInputs["mutualTlsAuthentication"] = args?.mutualTlsAuthentication; resourceInputs["ownershipVerificationCertificateArn"] = args?.ownershipVerificationCertificateArn; resourceInputs["policy"] = args?.policy; resourceInputs["region"] = args?.region; resourceInputs["regionalCertificateArn"] = args?.regionalCertificateArn; resourceInputs["regionalCertificateName"] = args?.regionalCertificateName; resourceInputs["securityPolicy"] = args?.securityPolicy; resourceInputs["tags"] = args?.tags; resourceInputs["arn"] = undefined /*out*/; resourceInputs["certificateUploadDate"] = undefined /*out*/; resourceInputs["cloudfrontDomainName"] = undefined /*out*/; resourceInputs["cloudfrontZoneId"] = undefined /*out*/; resourceInputs["domainNameId"] = undefined /*out*/; resourceInputs["regionalDomainName"] = undefined /*out*/; resourceInputs["regionalZoneId"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["certificatePrivateKey"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(DomainName.__pulumiType, name, resourceInputs, opts); } } exports.DomainName = DomainName; /** @internal */ DomainName.__pulumiType = 'aws:apigateway/domainName:DomainName'; //# sourceMappingURL=domainName.js.map