@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
157 lines • 6.58 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.SpacesBucketPolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* Provides a bucket policy resource for Spaces, DigitalOcean's object storage product.
* The `digitalocean.SpacesBucketPolicy` resource allows Terraform to attach bucket
* policy 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
*
* ### Limiting access to specific IP addresses
*
* ```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 foobarSpacesBucketPolicy = new digitalocean.SpacesBucketPolicy("foobar", {
* region: foobar.region,
* bucket: foobar.name,
* policy: pulumi.jsonStringify({
* Version: "2012-10-17",
* Statement: [{
* Sid: "IPAllow",
* Effect: "Deny",
* Principal: "*",
* Action: "s3:*",
* Resource: [
* pulumi.interpolate`arn:aws:s3:::${foobar.name}`,
* pulumi.interpolate`arn:aws:s3:::${foobar.name}/*`,
* ],
* Condition: {
* NotIpAddress: {
* "aws:SourceIp": "54.240.143.0/24",
* },
* },
* }],
* }),
* });
* ```
*
* !> **Warning:** Before using this policy, replace the 54.240.143.0/24 IP address range in this example with an appropriate value for your use case. Otherwise, you will lose the ability to access your bucket.
*
* ## Import
*
* Bucket policies can be imported using the `region` and `bucket` attributes (delimited by a comma):
*
* ```sh
* $ pulumi import digitalocean:index/spacesBucketPolicy:SpacesBucketPolicy foobar `region`,`bucket`
* ```
*/
class SpacesBucketPolicy extends pulumi.CustomResource {
/**
* Get an existing SpacesBucketPolicy 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 SpacesBucketPolicy(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'digitalocean:index/spacesBucketPolicy:SpacesBucketPolicy';
/**
* Returns true if the given object is an instance of SpacesBucketPolicy. 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'] === SpacesBucketPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["policy"] = state?.policy;
resourceInputs["region"] = state?.region;
}
else {
const args = argsOrState;
if (args?.bucket === undefined && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
if (args?.policy === undefined && !opts.urn) {
throw new Error("Missing required property 'policy'");
}
if (args?.region === undefined && !opts.urn) {
throw new Error("Missing required property 'region'");
}
resourceInputs["bucket"] = args?.bucket;
resourceInputs["policy"] = args?.policy;
resourceInputs["region"] = args?.region;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(SpacesBucketPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.SpacesBucketPolicy = SpacesBucketPolicy;
//# sourceMappingURL=spacesBucketPolicy.js.map