@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
267 lines • 10.6 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.ObjectBucketPolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* The `scaleway.object.BucketPolicy` resource allows you to create and manage
* bucket policies for [Scaleway Object storage](https://www.scaleway.com/en/docs/object-storage/).
*
* Refer to the [dedicated documentation](https://www.scaleway.com/en/docs/object-storage/api-cli/bucket-policy/) for more information on Object Storage
* bucket policies.
*
* > **Warning:** The `awsIamPolicyDocument` resource is only compatible with
* the deprecated `2012-10-17` version. Use the Scaleway-specific `2023-04-17`
* recommended version, with a `jsonencode` bloc instead. See examples below.
*
* ## Example Usage
*
* ### Example Usage with an IAM user
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* // Project ID
* const _default = scaleway.account.getProject({
* name: "default",
* });
* // IAM configuration
* const user = scaleway.iam.getUser({
* email: "user@scaleway.com",
* });
* const policy = new scaleway.iam.Policy("policy", {
* name: "object-storage-policy",
* userId: user.then(user => user.id),
* rules: [{
* projectIds: [_default.then(_default => _default.id)],
* permissionSetNames: ["ObjectStorageFullAccess"],
* }],
* });
* // Object storage configuration
* const bucket = new scaleway.object.Bucket("bucket", {name: "some-unique-name"});
* const policyBucketPolicy = new scaleway.object.BucketPolicy("policy", {
* bucket: bucket.name,
* policy: pulumi.jsonStringify({
* Version: "2023-04-17",
* Id: "MyBucketPolicy",
* Statement: [{
* Effect: "Allow",
* Action: ["s3:*"],
* Principal: {
* SCW: user.then(user => `user_id:${user.id}`),
* },
* Resource: [
* bucket.name,
* pulumi.interpolate`${bucket.name}/*`,
* ],
* }],
* }),
* });
* ```
*
* ### Example with an IAM application
*
* ### Creating a bucket and delegating read access to an application
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* // Project ID
* const _default = scaleway.account.getProject({
* name: "default",
* });
* // IAM configuration
* const reading_app = new scaleway.iam.Application("reading-app", {name: "reading-app"});
* const policy = new scaleway.iam.Policy("policy", {
* name: "object-storage-policy",
* applicationId: reading_app.id,
* rules: [{
* projectIds: [_default.then(_default => _default.id)],
* permissionSetNames: ["ObjectStorageBucketsRead"],
* }],
* });
* // Object storage configuration
* const bucket = new scaleway.object.Bucket("bucket", {name: "some-unique-name"});
* const policyBucketPolicy = new scaleway.object.BucketPolicy("policy", {
* bucket: bucket.id,
* policy: pulumi.jsonStringify({
* Version: "2023-04-17",
* Statement: [{
* Sid: "Delegate read access",
* Effect: "Allow",
* Principal: {
* SCW: pulumi.interpolate`application_id:${reading_app.id}`,
* },
* Action: [
* "s3:ListBucket",
* "s3:GetObject",
* ],
* Resource: [
* bucket.name,
* pulumi.interpolate`${bucket.name}/*`,
* ],
* }],
* }),
* });
* ```
*
* ### Reading the bucket with the application
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const reading_app = scaleway.iam.getApplication({
* name: "reading-app",
* });
* const reading_api_key = new scaleway.iam.ApiKey("reading-api-key", {applicationId: reading_app.then(reading_app => reading_app.id)});
* const bucket = scaleway.object.getBucket({
* name: "some-unique-name",
* });
* ```
*
* ### Example with deprecated version 2012-10-17
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* // Project ID
* const _default = scaleway.account.getProject({
* name: "default",
* });
* // Object storage configuration
* const bucket = new scaleway.object.Bucket("bucket", {
* name: "mia-cross-crash-tests",
* region: "fr-par",
* });
* const policy = new scaleway.object.BucketPolicy("policy", {
* bucket: bucket.name,
* policy: pulumi.jsonStringify({
* Version: "2012-10-17",
* Statement: [{
* Effect: "Allow",
* Action: [
* "s3:ListBucket",
* "s3:GetObjectTagging",
* ],
* Principal: {
* SCW: _default.then(_default => `project_id:${_default.id}`),
* },
* Resource: [
* bucket.name,
* pulumi.interpolate`${bucket.name}/*`,
* ],
* }],
* }),
* });
* ```
*
* **NB:** To configure the AWS provider with Scaleway credentials, refer to the [dedicated documentation](https://www.scaleway.com/en/docs/object-storage/api-cli/object-storage-aws-cli/).
*
* ## Import
*
* Bucket policies can be imported using the `{region}/{bucketName}` identifier, as shown below:
*
* ```sh
* $ pulumi import scaleway:index/objectBucketPolicy:ObjectBucketPolicy some_bucket fr-par/some-bucket
* ```
*
* > **Important:** The `projectId` attribute has a particular behavior with s3 products because the s3 API is scoped by project.
* If you are using a project different from the default one, you have to specify the project ID at the end of the import command.
*
* ```sh
* $ pulumi import scaleway:index/objectBucketPolicy:ObjectBucketPolicy some_bucket fr-par/some-bucket@xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
* ```
*
* <!--- Links, invisible in the final document --->
*
* [1]: https://www.scaleway.com/en/docs/object-storage/
* [2]: https://www.scaleway.com/en/docs/object-storage/api-cli/bucket-policy/
*
* @deprecated scaleway.index/objectbucketpolicy.ObjectBucketPolicy has been deprecated in favor of scaleway.object/bucketpolicy.BucketPolicy
*/
class ObjectBucketPolicy extends pulumi.CustomResource {
/**
* Get an existing ObjectBucketPolicy 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) {
pulumi.log.warn("ObjectBucketPolicy is deprecated: scaleway.index/objectbucketpolicy.ObjectBucketPolicy has been deprecated in favor of scaleway.object/bucketpolicy.BucketPolicy");
return new ObjectBucketPolicy(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'scaleway:index/objectBucketPolicy:ObjectBucketPolicy';
/**
* Returns true if the given object is an instance of ObjectBucketPolicy. 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'] === ObjectBucketPolicy.__pulumiType;
}
/** @deprecated scaleway.index/objectbucketpolicy.ObjectBucketPolicy has been deprecated in favor of scaleway.object/bucketpolicy.BucketPolicy */
constructor(name, argsOrState, opts) {
pulumi.log.warn("ObjectBucketPolicy is deprecated: scaleway.index/objectbucketpolicy.ObjectBucketPolicy has been deprecated in favor of scaleway.object/bucketpolicy.BucketPolicy");
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["policy"] = state?.policy;
resourceInputs["projectId"] = state?.projectId;
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'");
}
resourceInputs["bucket"] = args?.bucket;
resourceInputs["policy"] = args?.policy;
resourceInputs["projectId"] = args?.projectId;
resourceInputs["region"] = args?.region;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ObjectBucketPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.ObjectBucketPolicy = ObjectBucketPolicy;
//# sourceMappingURL=objectBucketPolicy.js.map