@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
146 lines • 6.23 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! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpacesBucketCorsConfiguration = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* Provides a CORS configuration resource for Spaces, DigitalOcean's object storage product.
* The `digitalocean.SpacesBucketCorsConfiguration` resource allows Terraform to to attach CORS configuration to Spaces.
*
* The [Spaces API](https://docs.digitalocean.com/reference/api/spaces-api/) was
* designed to be interoperable with Amazon's AWS S3 API. This allows users to
* interact with the service while using the tools they already know. Spaces
* mirrors S3's authentication framework and requests to Spaces require a key pair
* similar to Amazon's Access ID and Secret Key.
*
* The authentication requirement can be met by either setting the
* `SPACES_ACCESS_KEY_ID` and `SPACES_SECRET_ACCESS_KEY` environment variables or
* the provider's `spacesAccessId` and `spacesSecretKey` arguments to the
* access ID and secret you generate via the DigitalOcean control panel. For
* example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const static_assets = new digitalocean.SpacesBucket("static-assets", {});
* ```
*
* For more information, See [An Introduction to DigitalOcean Spaces](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-spaces)
*
* ## Example Usage
*
* ### Create a Key in a Spaces Bucket
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const foobar = new digitalocean.SpacesBucket("foobar", {
* name: "foobar",
* region: digitalocean.Region.NYC3,
* });
* const test = new digitalocean.SpacesBucketCorsConfiguration("test", {
* bucket: foobar.id,
* region: "nyc3",
* corsRules: [{
* allowedHeaders: ["*"],
* allowedMethods: [
* "PUT",
* "POST",
* ],
* allowedOrigins: ["https://s3-website-test.hashicorp.com"],
* exposeHeaders: ["ETag"],
* maxAgeSeconds: 3000,
* }],
* });
* ```
*
* ## Import
*
* Bucket policies can be imported using the `region` and `bucket` attributes (delimited by a comma):
*
* ```sh
* $ pulumi import digitalocean:index/spacesBucketCorsConfiguration:SpacesBucketCorsConfiguration foobar `region`,`bucket`
* ```
*/
class SpacesBucketCorsConfiguration extends pulumi.CustomResource {
/**
* Get an existing SpacesBucketCorsConfiguration 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 SpacesBucketCorsConfiguration(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'digitalocean:index/spacesBucketCorsConfiguration:SpacesBucketCorsConfiguration';
/**
* Returns true if the given object is an instance of SpacesBucketCorsConfiguration. 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'] === SpacesBucketCorsConfiguration.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["corsRules"] = state?.corsRules;
resourceInputs["region"] = state?.region;
}
else {
const args = argsOrState;
if (args?.bucket === undefined && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
if (args?.corsRules === undefined && !opts.urn) {
throw new Error("Missing required property 'corsRules'");
}
if (args?.region === undefined && !opts.urn) {
throw new Error("Missing required property 'region'");
}
resourceInputs["bucket"] = args?.bucket;
resourceInputs["corsRules"] = args?.corsRules;
resourceInputs["region"] = args?.region;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(SpacesBucketCorsConfiguration.__pulumiType, name, resourceInputs, opts);
}
}
exports.SpacesBucketCorsConfiguration = SpacesBucketCorsConfiguration;
//# sourceMappingURL=spacesBucketCorsConfiguration.js.map