@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
235 lines • 9.05 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.Distribution = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages a Lightsail content delivery network (CDN) distribution. Use this resource to cache content at edge locations and reduce latency for users accessing your content.
*
* ## Example Usage
*
* ### Basic Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lightsail.Bucket("example", {
* name: "example-bucket",
* bundleId: "small_1_0",
* });
* const exampleDistribution = new aws.lightsail.Distribution("example", {
* name: "example-distribution",
* bundleId: "small_1_0",
* origin: {
* name: example.name,
* regionName: example.region,
* },
* defaultCacheBehavior: {
* behavior: "cache",
* },
* cacheBehaviorSettings: {
* allowedHttpMethods: "GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE",
* cachedHttpMethods: "GET,HEAD",
* defaultTtl: 86400,
* maximumTtl: 31536000,
* minimumTtl: 0,
* forwardedCookies: {
* option: "none",
* },
* forwardedHeaders: {
* option: "default",
* },
* forwardedQueryStrings: {
* option: false,
* },
* },
* });
* ```
*
* ### Instance Origin
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const available = aws.getAvailabilityZones({
* state: "available",
* filters: [{
* name: "opt-in-status",
* values: ["opt-in-not-required"],
* }],
* });
* const exampleStaticIp = new aws.lightsail.StaticIp("example", {name: "example-static-ip"});
* const exampleInstance = new aws.lightsail.Instance("example", {
* name: "example-instance",
* availabilityZone: available.then(available => available.names?.[0]),
* blueprintId: "amazon_linux_2",
* bundleId: "micro_1_0",
* });
* const example = new aws.lightsail.StaticIpAttachment("example", {
* staticIpName: exampleStaticIp.name,
* instanceName: exampleInstance.name,
* });
* const exampleDistribution = new aws.lightsail.Distribution("example", {
* name: "example-distribution",
* bundleId: "small_1_0",
* origin: {
* name: exampleInstance.name,
* regionName: available.then(available => available.id),
* },
* defaultCacheBehavior: {
* behavior: "cache",
* },
* }, {
* dependsOn: [example],
* });
* ```
*
* ### Load Balancer Origin
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const available = aws.getAvailabilityZones({
* state: "available",
* filters: [{
* name: "opt-in-status",
* values: ["opt-in-not-required"],
* }],
* });
* const example = new aws.lightsail.Lb("example", {
* name: "example-load-balancer",
* healthCheckPath: "/",
* instancePort: 80,
* tags: {
* foo: "bar",
* },
* });
* const exampleInstance = new aws.lightsail.Instance("example", {
* name: "example-instance",
* availabilityZone: available.then(available => available.names?.[0]),
* blueprintId: "amazon_linux_2",
* bundleId: "nano_3_0",
* });
* const exampleLbAttachment = new aws.lightsail.LbAttachment("example", {
* lbName: example.name,
* instanceName: exampleInstance.name,
* });
* const exampleDistribution = new aws.lightsail.Distribution("example", {
* name: "example-distribution",
* bundleId: "small_1_0",
* origin: {
* name: example.name,
* regionName: available.then(available => available.id),
* },
* defaultCacheBehavior: {
* behavior: "cache",
* },
* }, {
* dependsOn: [exampleLbAttachment],
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import Lightsail Distribution using the `name`. For example:
*
* ```sh
* $ pulumi import aws:lightsail/distribution:Distribution example example-distribution
* ```
*/
class Distribution extends pulumi.CustomResource {
/**
* Get an existing Distribution 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 Distribution(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Distribution. 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'] === Distribution.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["alternativeDomainNames"] = state?.alternativeDomainNames;
resourceInputs["arn"] = state?.arn;
resourceInputs["bundleId"] = state?.bundleId;
resourceInputs["cacheBehaviorSettings"] = state?.cacheBehaviorSettings;
resourceInputs["cacheBehaviors"] = state?.cacheBehaviors;
resourceInputs["certificateName"] = state?.certificateName;
resourceInputs["createdAt"] = state?.createdAt;
resourceInputs["defaultCacheBehavior"] = state?.defaultCacheBehavior;
resourceInputs["domainName"] = state?.domainName;
resourceInputs["ipAddressType"] = state?.ipAddressType;
resourceInputs["isEnabled"] = state?.isEnabled;
resourceInputs["locations"] = state?.locations;
resourceInputs["name"] = state?.name;
resourceInputs["origin"] = state?.origin;
resourceInputs["originPublicDns"] = state?.originPublicDns;
resourceInputs["region"] = state?.region;
resourceInputs["resourceType"] = state?.resourceType;
resourceInputs["status"] = state?.status;
resourceInputs["supportCode"] = state?.supportCode;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
}
else {
const args = argsOrState;
if (args?.bundleId === undefined && !opts.urn) {
throw new Error("Missing required property 'bundleId'");
}
if (args?.defaultCacheBehavior === undefined && !opts.urn) {
throw new Error("Missing required property 'defaultCacheBehavior'");
}
if (args?.origin === undefined && !opts.urn) {
throw new Error("Missing required property 'origin'");
}
resourceInputs["bundleId"] = args?.bundleId;
resourceInputs["cacheBehaviorSettings"] = args?.cacheBehaviorSettings;
resourceInputs["cacheBehaviors"] = args?.cacheBehaviors;
resourceInputs["certificateName"] = args?.certificateName;
resourceInputs["defaultCacheBehavior"] = args?.defaultCacheBehavior;
resourceInputs["ipAddressType"] = args?.ipAddressType;
resourceInputs["isEnabled"] = args?.isEnabled;
resourceInputs["name"] = args?.name;
resourceInputs["origin"] = args?.origin;
resourceInputs["region"] = args?.region;
resourceInputs["tags"] = args?.tags;
resourceInputs["alternativeDomainNames"] = undefined /*out*/;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["domainName"] = undefined /*out*/;
resourceInputs["locations"] = undefined /*out*/;
resourceInputs["originPublicDns"] = undefined /*out*/;
resourceInputs["resourceType"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["supportCode"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Distribution.__pulumiType, name, resourceInputs, opts);
}
}
exports.Distribution = Distribution;
/** @internal */
Distribution.__pulumiType = 'aws:lightsail/distribution:Distribution';
//# sourceMappingURL=distribution.js.map