@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
301 lines (300 loc) • 10.2 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
/**
* 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
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: ObjectBucketPolicyState, opts?: pulumi.CustomResourceOptions): 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: any): obj is ObjectBucketPolicy;
/**
* The bucket's name or regional ID.
*/
readonly bucket: pulumi.Output<string>;
/**
* The text of the policy.
*/
readonly policy: pulumi.Output<string>;
/**
* The projectId you want to attach the resource to
*/
readonly projectId: pulumi.Output<string>;
/**
* The Scaleway region this bucket resides in.
*/
readonly region: pulumi.Output<string>;
/**
* Create a ObjectBucketPolicy resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
/** @deprecated scaleway.index/objectbucketpolicy.ObjectBucketPolicy has been deprecated in favor of scaleway.object/bucketpolicy.BucketPolicy */
constructor(name: string, args: ObjectBucketPolicyArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering ObjectBucketPolicy resources.
*/
export interface ObjectBucketPolicyState {
/**
* The bucket's name or regional ID.
*/
bucket?: pulumi.Input<string>;
/**
* The text of the policy.
*/
policy?: pulumi.Input<string>;
/**
* The projectId you want to attach the resource to
*/
projectId?: pulumi.Input<string>;
/**
* The Scaleway region this bucket resides in.
*/
region?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a ObjectBucketPolicy resource.
*/
export interface ObjectBucketPolicyArgs {
/**
* The bucket's name or regional ID.
*/
bucket: pulumi.Input<string>;
/**
* The text of the policy.
*/
policy: pulumi.Input<string>;
/**
* The projectId you want to attach the resource to
*/
projectId?: pulumi.Input<string>;
/**
* The Scaleway region this bucket resides in.
*/
region?: pulumi.Input<string>;
}