@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
235 lines • 9.71 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, Object.assign(Object.assign({}, 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 ? state.alternativeDomainNames : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["bundleId"] = state ? state.bundleId : undefined;
resourceInputs["cacheBehaviorSettings"] = state ? state.cacheBehaviorSettings : undefined;
resourceInputs["cacheBehaviors"] = state ? state.cacheBehaviors : undefined;
resourceInputs["certificateName"] = state ? state.certificateName : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["defaultCacheBehavior"] = state ? state.defaultCacheBehavior : undefined;
resourceInputs["domainName"] = state ? state.domainName : undefined;
resourceInputs["ipAddressType"] = state ? state.ipAddressType : undefined;
resourceInputs["isEnabled"] = state ? state.isEnabled : undefined;
resourceInputs["locations"] = state ? state.locations : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["origin"] = state ? state.origin : undefined;
resourceInputs["originPublicDns"] = state ? state.originPublicDns : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["resourceType"] = state ? state.resourceType : undefined;
resourceInputs["status"] = state ? state.status : undefined;
resourceInputs["supportCode"] = state ? state.supportCode : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
}
else {
const args = argsOrState;
if ((!args || args.bundleId === undefined) && !opts.urn) {
throw new Error("Missing required property 'bundleId'");
}
if ((!args || args.defaultCacheBehavior === undefined) && !opts.urn) {
throw new Error("Missing required property 'defaultCacheBehavior'");
}
if ((!args || args.origin === undefined) && !opts.urn) {
throw new Error("Missing required property 'origin'");
}
resourceInputs["bundleId"] = args ? args.bundleId : undefined;
resourceInputs["cacheBehaviorSettings"] = args ? args.cacheBehaviorSettings : undefined;
resourceInputs["cacheBehaviors"] = args ? args.cacheBehaviors : undefined;
resourceInputs["certificateName"] = args ? args.certificateName : undefined;
resourceInputs["defaultCacheBehavior"] = args ? args.defaultCacheBehavior : undefined;
resourceInputs["ipAddressType"] = args ? args.ipAddressType : undefined;
resourceInputs["isEnabled"] = args ? args.isEnabled : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["origin"] = args ? args.origin : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
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