@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
279 lines • 10.7 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectBucketPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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.
*
* ## Example Usage
*
* ### Example Usage with an IAM user
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumi/scaleway";
* 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 "@pulumi/scaleway";
* 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 "@pulumi/scaleway";
* 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 AWS provider
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as scaleway from "@pulumi/scaleway";
* import * as scaleway from "@pulumiverse/scaleway";
*
* // Scaleway project ID
* const _default = scaleway.account.getProject({
* name: "default",
* });
* // Object storage configuration
* const bucket = new scaleway.object.Bucket("bucket", {name: "some-unique-name"});
* // AWS data source
* const policy = aws.iam.getPolicyDocumentOutput({
* version: "2012-10-17",
* statements: [{
* sid: "Delegate access",
* effect: "Allow",
* principals: [{
* type: "SCW",
* identifiers: [_default.then(_default => `project_id:${_default.id}`)],
* }],
* actions: ["s3:ListBucket"],
* resources: [
* bucket.name,
* pulumi.interpolate`${bucket.name}/*`,
* ],
* }],
* });
* const main = new scaleway.object.BucketPolicy("main", {
* bucket: bucket.id,
* policy: policy.apply(policy => policy.json),
* });
* ```
*
* ### Example with deprecated version 2012-10-17
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumi/scaleway";
* 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:
*
* bash
*
* ```sh
* $ pulumi import scaleway:index/objectBucketPolicy:ObjectBucketPolicy some_bucket fr-par/some-bucket
* ```
*
* ~> **Important:** The `project_id` 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.
*
* bash
*
* ```sh
* $ pulumi import scaleway:index/objectBucketPolicy:ObjectBucketPolicy some_bucket fr-par/some-bucket@xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
* ```
*
* @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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.bucket : undefined;
resourceInputs["policy"] = state ? state.policy : undefined;
resourceInputs["projectId"] = state ? state.projectId : undefined;
resourceInputs["region"] = state ? state.region : undefined;
}
else {
const args = argsOrState;
if ((!args || args.bucket === undefined) && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
if ((!args || args.policy === undefined) && !opts.urn) {
throw new Error("Missing required property 'policy'");
}
resourceInputs["bucket"] = args ? args.bucket : undefined;
resourceInputs["policy"] = args ? args.policy : undefined;
resourceInputs["projectId"] = args ? args.projectId : undefined;
resourceInputs["region"] = args ? args.region : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ObjectBucketPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.ObjectBucketPolicy = ObjectBucketPolicy;
/** @internal */
ObjectBucketPolicy.__pulumiType = 'scaleway:index/objectBucketPolicy:ObjectBucketPolicy';
//# sourceMappingURL=objectBucketPolicy.js.map