scaleway.ObjectBucketPolicy
Explore with Pulumi AI
Creates and manages Scaleway object storage bucket policy. For more information, see the documentation.
Example with aws provider
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.ObjectBucket;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.scaleway.ObjectBucketPolicy;
import com.pulumi.scaleway.ObjectBucketPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var bucket = new ObjectBucket("bucket");
final var policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.version("2023-04-17")
.id("MyBucketPolicy")
.statements(GetPolicyDocumentStatementArgs.builder()
.sid("Delegate access")
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("SCW")
.identifiers("application_id:<APPLICATION_ID>")
.build())
.actions("s3:ListBucket")
.resources(
bucket.name(),
bucket.name().applyValue(name -> String.format("%s/*", name)))
.build())
.build());
var main = new ObjectBucketPolicy("main", ObjectBucketPolicyArgs.builder()
.bucket(bucket.name())
.policy(policy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(policy -> policy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
}
}
resources:
bucket:
type: scaleway:ObjectBucket
main:
type: scaleway:ObjectBucketPolicy
properties:
bucket: ${bucket.name}
policy: ${policy.json}
variables:
policy:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
version: 2023-04-17
id: MyBucketPolicy
statements:
- sid: Delegate access
effect: Allow
principals:
- type: SCW
identifiers:
- application_id:<APPLICATION_ID>
actions:
- s3:ListBucket
resources:
- ${bucket.name}
- ${bucket.name}/*
Example Usage
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Scaleway = Lbrlabs.PulumiPackage.Scaleway;
return await Deployment.RunAsync(() =>
{
var bucket = new Scaleway.ObjectBucket("bucket");
var policy = new Scaleway.ObjectBucketPolicy("policy", new()
{
Bucket = bucket.Name,
Policy = Output.Tuple(bucket.Name, bucket.Name).Apply(values =>
{
var bucketName = values.Item1;
var bucketName1 = values.Item2;
return JsonSerializer.Serialize(new Dictionary<string, object?>
{
["Version"] = "2023-04-17",
["Id"] = "MyBucketPolicy",
["Statement"] = new[]
{
new Dictionary<string, object?>
{
["Sid"] = "Delegate access",
["Effect"] = "Allow",
["Principal"] = new Dictionary<string, object?>
{
["SCW"] = "application_id:<APPLICATION_ID>",
},
["Action"] = "s3:ListBucket",
["Resources"] = new[]
{
bucketName,
$"{bucketName1}/*",
},
},
},
});
}),
});
});
package main
import (
"encoding/json"
"fmt"
"github.com/lbrlabs/pulumi-scaleway/sdk/go/scaleway"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bucket, err := scaleway.NewObjectBucket(ctx, "bucket", nil)
if err != nil {
return err
}
_, err = scaleway.NewObjectBucketPolicy(ctx, "policy", &scaleway.ObjectBucketPolicyArgs{
Bucket: bucket.Name,
Policy: pulumi.All(bucket.Name, bucket.Name).ApplyT(func(_args []interface{}) (string, error) {
bucketName := _args[0].(string)
bucketName1 := _args[1].(string)
var _zero string
tmpJSON0, err := json.Marshal(map[string]interface{}{
"Version": "2023-04-17",
"Id": "MyBucketPolicy",
"Statement": []map[string]interface{}{
map[string]interface{}{
"Sid": "Delegate access",
"Effect": "Allow",
"Principal": map[string]interface{}{
"SCW": "application_id:<APPLICATION_ID>",
},
"Action": "s3:ListBucket",
"Resources": []string{
bucketName,
fmt.Sprintf("%v/*", bucketName1),
},
},
},
})
if err != nil {
return _zero, err
}
json0 := string(tmpJSON0)
return json0, nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.ObjectBucket;
import com.pulumi.scaleway.ObjectBucketPolicy;
import com.pulumi.scaleway.ObjectBucketPolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var bucket = new ObjectBucket("bucket");
var policy = new ObjectBucketPolicy("policy", ObjectBucketPolicyArgs.builder()
.bucket(bucket.name())
.policy(Output.tuple(bucket.name(), bucket.name()).applyValue(values -> {
var bucketName = values.t1;
var bucketName1 = values.t2;
return serializeJson(
jsonObject(
jsonProperty("Version", "2023-04-17"),
jsonProperty("Id", "MyBucketPolicy"),
jsonProperty("Statement", jsonArray(jsonObject(
jsonProperty("Sid", "Delegate access"),
jsonProperty("Effect", "Allow"),
jsonProperty("Principal", jsonObject(
jsonProperty("SCW", "application_id:<APPLICATION_ID>")
)),
jsonProperty("Action", "s3:ListBucket"),
jsonProperty("Resources", jsonArray(
bucketName,
String.format("%s/*", bucketName1)
))
)))
));
}))
.build());
}
}
import pulumi
import json
import lbrlabs_pulumi_scaleway as scaleway
bucket = scaleway.ObjectBucket("bucket")
policy = scaleway.ObjectBucketPolicy("policy",
bucket=bucket.name,
policy=pulumi.Output.all(bucket.name, bucket.name).apply(lambda bucketName, bucketName1: json.dumps({
"Version": "2023-04-17",
"Id": "MyBucketPolicy",
"Statement": [{
"Sid": "Delegate access",
"Effect": "Allow",
"Principal": {
"SCW": "application_id:<APPLICATION_ID>",
},
"Action": "s3:ListBucket",
"Resources": [
bucket_name,
f"{bucket_name1}/*",
],
}],
})))
import * as pulumi from "@pulumi/pulumi";
import * as scaleway from "@lbrlabs/pulumi-scaleway";
const bucket = new scaleway.ObjectBucket("bucket", {});
const policy = new scaleway.ObjectBucketPolicy("policy", {
bucket: bucket.name,
policy: pulumi.all([bucket.name, bucket.name]).apply(([bucketName, bucketName1]) => JSON.stringify({
Version: "2023-04-17",
Id: "MyBucketPolicy",
Statement: [{
Sid: "Delegate access",
Effect: "Allow",
Principal: {
SCW: "application_id:<APPLICATION_ID>",
},
Action: "s3:ListBucket",
Resources: [
bucketName,
`${bucketName1}/*`,
],
}],
})),
});
resources:
bucket:
type: scaleway:ObjectBucket
policy:
type: scaleway:ObjectBucketPolicy
properties:
bucket: ${bucket.name}
policy:
fn::toJSON:
Version: 2023-04-17
Id: MyBucketPolicy
Statement:
- Sid: Delegate access
Effect: Allow
Principal:
SCW: application_id:<APPLICATION_ID>
Action: s3:ListBucket
Resources:
- ${bucket.name}
- ${bucket.name}/*
Coming soon!
Coming soon!
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.ObjectBucket;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.scaleway.ObjectBucketPolicy;
import com.pulumi.scaleway.ObjectBucketPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var bucket = new ObjectBucket("bucket");
final var policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.version("2023-04-17")
.id("MyBucketPolicy")
.statements(GetPolicyDocumentStatementArgs.builder()
.sid("Delegate access")
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("SCW")
.identifiers("application_id:<APPLICATION_ID>")
.build())
.actions("s3:ListBucket")
.resources(
bucket.name(),
bucket.name().applyValue(name -> String.format("%s/*", name)))
.build())
.build());
var main = new ObjectBucketPolicy("main", ObjectBucketPolicyArgs.builder()
.bucket(bucket.name())
.policy(policy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(policy -> policy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
}
}
Coming soon!
Coming soon!
resources:
bucket:
type: scaleway:ObjectBucket
main:
type: scaleway:ObjectBucketPolicy
properties:
bucket: ${bucket.name}
policy: ${policy.json}
variables:
policy:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
version: 2023-04-17
id: MyBucketPolicy
statements:
- sid: Delegate access
effect: Allow
principals:
- type: SCW
identifiers:
- application_id:<APPLICATION_ID>
actions:
- s3:ListBucket
resources:
- ${bucket.name}
- ${bucket.name}/*
Create ObjectBucketPolicy Resource
new ObjectBucketPolicy(name: string, args: ObjectBucketPolicyArgs, opts?: CustomResourceOptions);
@overload
def ObjectBucketPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
policy: Optional[str] = None,
project_id: Optional[str] = None,
region: Optional[str] = None)
@overload
def ObjectBucketPolicy(resource_name: str,
args: ObjectBucketPolicyArgs,
opts: Optional[ResourceOptions] = None)
func NewObjectBucketPolicy(ctx *Context, name string, args ObjectBucketPolicyArgs, opts ...ResourceOption) (*ObjectBucketPolicy, error)
public ObjectBucketPolicy(string name, ObjectBucketPolicyArgs args, CustomResourceOptions? opts = null)
public ObjectBucketPolicy(String name, ObjectBucketPolicyArgs args)
public ObjectBucketPolicy(String name, ObjectBucketPolicyArgs args, CustomResourceOptions options)
type: scaleway:ObjectBucketPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ObjectBucketPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args ObjectBucketPolicyArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ObjectBucketPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ObjectBucketPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ObjectBucketPolicyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ObjectBucketPolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The ObjectBucketPolicy resource accepts the following input properties:
- Bucket string
The name of the bucket.
- Policy string
The text of the policy.
- Project
Id string project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- Region string
The Scaleway region this bucket resides in.
- Bucket string
The name of the bucket.
- Policy string
The text of the policy.
- Project
Id string project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- Region string
The Scaleway region this bucket resides in.
- bucket String
The name of the bucket.
- policy String
The text of the policy.
- project
Id String project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region String
The Scaleway region this bucket resides in.
- bucket string
The name of the bucket.
- policy string
The text of the policy.
- project
Id string project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region string
The Scaleway region this bucket resides in.
- bucket str
The name of the bucket.
- policy str
The text of the policy.
- project_
id str project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region str
The Scaleway region this bucket resides in.
- bucket String
The name of the bucket.
- policy String
The text of the policy.
- project
Id String project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region String
The Scaleway region this bucket resides in.
Outputs
All input properties are implicitly available as output properties. Additionally, the ObjectBucketPolicy resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing ObjectBucketPolicy Resource
Get an existing ObjectBucketPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: ObjectBucketPolicyState, opts?: CustomResourceOptions): ObjectBucketPolicy
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
policy: Optional[str] = None,
project_id: Optional[str] = None,
region: Optional[str] = None) -> ObjectBucketPolicy
func GetObjectBucketPolicy(ctx *Context, name string, id IDInput, state *ObjectBucketPolicyState, opts ...ResourceOption) (*ObjectBucketPolicy, error)
public static ObjectBucketPolicy Get(string name, Input<string> id, ObjectBucketPolicyState? state, CustomResourceOptions? opts = null)
public static ObjectBucketPolicy get(String name, Output<String> id, ObjectBucketPolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Bucket string
The name of the bucket.
- Policy string
The text of the policy.
- Project
Id string project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- Region string
The Scaleway region this bucket resides in.
- Bucket string
The name of the bucket.
- Policy string
The text of the policy.
- Project
Id string project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- Region string
The Scaleway region this bucket resides in.
- bucket String
The name of the bucket.
- policy String
The text of the policy.
- project
Id String project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region String
The Scaleway region this bucket resides in.
- bucket string
The name of the bucket.
- policy string
The text of the policy.
- project
Id string project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region string
The Scaleway region this bucket resides in.
- bucket str
The name of the bucket.
- policy str
The text of the policy.
- project_
id str project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region str
The Scaleway region this bucket resides in.
- bucket String
The name of the bucket.
- policy String
The text of the policy.
- project
Id String project_id
) The ID of the project the bucket is associated with.Important: The aws_iam_policy_document data source may be used, so long as it specifies a principal.
- region String
The Scaleway region this bucket resides in.
Import
Buckets can be imported using the {region}/{bucketName}
identifier, e.g. bash
$ pulumi import scaleway:index/objectBucketPolicy:ObjectBucketPolicy some_bucket fr-par/some-bucket
Package Details
- Repository
- scaleway lbrlabs/pulumi-scaleway
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
scaleway
Terraform Provider.