1. Packages
  2. Flexibleengine Provider
  3. API Docs
  4. ObsBucketPolicy
flexibleengine 1.46.0 published on Monday, Apr 14, 2025 by flexibleenginecloud

flexibleengine.ObsBucketPolicy

Explore with Pulumi AI

Attaches a policy to an OBS bucket resource.

NOTE: When creating or updating the OBS bucket policy, the original policy will be overwritten.

Example Usage

Policy with OBS format

import * as pulumi from "@pulumi/pulumi";
import * as flexibleengine from "@pulumi/flexibleengine";

const bucket = new flexibleengine.ObsBucket("bucket", {bucket: "my-test-bucket"});
const policy = new flexibleengine.ObsBucketPolicy("policy", {
    bucket: bucket.obsBucketId,
    policy: `{
  "Statement": [
    {
      "Sid": "AddPerm",
      "Effect": "Allow",
      "Principal": {"ID": "*"},
      "Action": ["GetObject"],
      "Resource": "my-test-bucket/*"
    }
  ]
}
`,
});
Copy
import pulumi
import pulumi_flexibleengine as flexibleengine

bucket = flexibleengine.ObsBucket("bucket", bucket="my-test-bucket")
policy = flexibleengine.ObsBucketPolicy("policy",
    bucket=bucket.obs_bucket_id,
    policy="""{
  "Statement": [
    {
      "Sid": "AddPerm",
      "Effect": "Allow",
      "Principal": {"ID": "*"},
      "Action": ["GetObject"],
      "Resource": "my-test-bucket/*"
    }
  ]
}
""")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/flexibleengine/flexibleengine"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		bucket, err := flexibleengine.NewObsBucket(ctx, "bucket", &flexibleengine.ObsBucketArgs{
			Bucket: pulumi.String("my-test-bucket"),
		})
		if err != nil {
			return err
		}
		_, err = flexibleengine.NewObsBucketPolicy(ctx, "policy", &flexibleengine.ObsBucketPolicyArgs{
			Bucket: bucket.ObsBucketId,
			Policy: pulumi.String(`{
  "Statement": [
    {
      "Sid": "AddPerm",
      "Effect": "Allow",
      "Principal": {"ID": "*"},
      "Action": ["GetObject"],
      "Resource": "my-test-bucket/*"
    }
  ]
}
`),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Flexibleengine = Pulumi.Flexibleengine;

return await Deployment.RunAsync(() => 
{
    var bucket = new Flexibleengine.ObsBucket("bucket", new()
    {
        Bucket = "my-test-bucket",
    });

    var policy = new Flexibleengine.ObsBucketPolicy("policy", new()
    {
        Bucket = bucket.ObsBucketId,
        Policy = @"{
  ""Statement"": [
    {
      ""Sid"": ""AddPerm"",
      ""Effect"": ""Allow"",
      ""Principal"": {""ID"": ""*""},
      ""Action"": [""GetObject""],
      ""Resource"": ""my-test-bucket/*""
    }
  ]
}
",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.flexibleengine.ObsBucket;
import com.pulumi.flexibleengine.ObsBucketArgs;
import com.pulumi.flexibleengine.ObsBucketPolicy;
import com.pulumi.flexibleengine.ObsBucketPolicyArgs;
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 ObsBucket("bucket", ObsBucketArgs.builder()
            .bucket("my-test-bucket")
            .build());

        var policy = new ObsBucketPolicy("policy", ObsBucketPolicyArgs.builder()
            .bucket(bucket.obsBucketId())
            .policy("""
{
  "Statement": [
    {
      "Sid": "AddPerm",
      "Effect": "Allow",
      "Principal": {"ID": "*"},
      "Action": ["GetObject"],
      "Resource": "my-test-bucket/*"
    }
  ]
}
            """)
            .build());

    }
}
Copy
resources:
  bucket:
    type: flexibleengine:ObsBucket
    properties:
      bucket: my-test-bucket
  policy:
    type: flexibleengine:ObsBucketPolicy
    properties:
      bucket: ${bucket.obsBucketId}
      policy: |
        {
          "Statement": [
            {
              "Sid": "AddPerm",
              "Effect": "Allow",
              "Principal": {"ID": "*"},
              "Action": ["GetObject"],
              "Resource": "my-test-bucket/*"
            }
          ]
        }        
Copy

Policy with S3 format

import * as pulumi from "@pulumi/pulumi";
import * as flexibleengine from "@pulumi/flexibleengine";

const bucket = new flexibleengine.ObsBucket("bucket", {bucket: "my-test-bucket"});
const s3Policy = new flexibleengine.ObsBucketPolicy("s3Policy", {
    bucket: bucket.obsBucketId,
    policyFormat: "s3",
    policy: `{
  "Version": "2008-10-17",
  "Id": "MYBUCKETPOLICY",
  "Statement": [
    {
      "Sid": "IPAllow",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::my-test-bucket/*",
      "Condition": {
        "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
      }
    }
  ]
}
`,
});
Copy
import pulumi
import pulumi_flexibleengine as flexibleengine

bucket = flexibleengine.ObsBucket("bucket", bucket="my-test-bucket")
s3_policy = flexibleengine.ObsBucketPolicy("s3Policy",
    bucket=bucket.obs_bucket_id,
    policy_format="s3",
    policy="""{
  "Version": "2008-10-17",
  "Id": "MYBUCKETPOLICY",
  "Statement": [
    {
      "Sid": "IPAllow",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::my-test-bucket/*",
      "Condition": {
        "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
      }
    }
  ]
}
""")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/flexibleengine/flexibleengine"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		bucket, err := flexibleengine.NewObsBucket(ctx, "bucket", &flexibleengine.ObsBucketArgs{
			Bucket: pulumi.String("my-test-bucket"),
		})
		if err != nil {
			return err
		}
		_, err = flexibleengine.NewObsBucketPolicy(ctx, "s3Policy", &flexibleengine.ObsBucketPolicyArgs{
			Bucket:       bucket.ObsBucketId,
			PolicyFormat: pulumi.String("s3"),
			Policy: pulumi.String(`{
  "Version": "2008-10-17",
  "Id": "MYBUCKETPOLICY",
  "Statement": [
    {
      "Sid": "IPAllow",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::my-test-bucket/*",
      "Condition": {
        "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
      }
    }
  ]
}
`),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Flexibleengine = Pulumi.Flexibleengine;

return await Deployment.RunAsync(() => 
{
    var bucket = new Flexibleengine.ObsBucket("bucket", new()
    {
        Bucket = "my-test-bucket",
    });

    var s3Policy = new Flexibleengine.ObsBucketPolicy("s3Policy", new()
    {
        Bucket = bucket.ObsBucketId,
        PolicyFormat = "s3",
        Policy = @"{
  ""Version"": ""2008-10-17"",
  ""Id"": ""MYBUCKETPOLICY"",
  ""Statement"": [
    {
      ""Sid"": ""IPAllow"",
      ""Effect"": ""Allow"",
      ""Principal"": ""*"",
      ""Action"": ""s3:*"",
      ""Resource"": ""arn:aws:s3:::my-test-bucket/*"",
      ""Condition"": {
        ""IpAddress"": {""aws:SourceIp"": ""8.8.8.8/32""}
      }
    }
  ]
}
",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.flexibleengine.ObsBucket;
import com.pulumi.flexibleengine.ObsBucketArgs;
import com.pulumi.flexibleengine.ObsBucketPolicy;
import com.pulumi.flexibleengine.ObsBucketPolicyArgs;
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 ObsBucket("bucket", ObsBucketArgs.builder()
            .bucket("my-test-bucket")
            .build());

        var s3Policy = new ObsBucketPolicy("s3Policy", ObsBucketPolicyArgs.builder()
            .bucket(bucket.obsBucketId())
            .policyFormat("s3")
            .policy("""
{
  "Version": "2008-10-17",
  "Id": "MYBUCKETPOLICY",
  "Statement": [
    {
      "Sid": "IPAllow",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::my-test-bucket/*",
      "Condition": {
        "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
      }
    }
  ]
}
            """)
            .build());

    }
}
Copy
resources:
  bucket:
    type: flexibleengine:ObsBucket
    properties:
      bucket: my-test-bucket
  s3Policy:
    type: flexibleengine:ObsBucketPolicy
    properties:
      bucket: ${bucket.obsBucketId}
      policyFormat: s3
      policy: |
        {
          "Version": "2008-10-17",
          "Id": "MYBUCKETPOLICY",
          "Statement": [
            {
              "Sid": "IPAllow",
              "Effect": "Allow",
              "Principal": "*",
              "Action": "s3:*",
              "Resource": "arn:aws:s3:::my-test-bucket/*",
              "Condition": {
                "IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
              }
            }
          ]
        }        
Copy

Create ObsBucketPolicy Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ObsBucketPolicy(name: string, args: ObsBucketPolicyArgs, opts?: CustomResourceOptions);
@overload
def ObsBucketPolicy(resource_name: str,
                    args: ObsBucketPolicyArgs,
                    opts: Optional[ResourceOptions] = None)

@overload
def ObsBucketPolicy(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    bucket: Optional[str] = None,
                    policy: Optional[str] = None,
                    obs_bucket_policy_id: Optional[str] = None,
                    policy_format: Optional[str] = None,
                    region: Optional[str] = None)
func NewObsBucketPolicy(ctx *Context, name string, args ObsBucketPolicyArgs, opts ...ResourceOption) (*ObsBucketPolicy, error)
public ObsBucketPolicy(string name, ObsBucketPolicyArgs args, CustomResourceOptions? opts = null)
public ObsBucketPolicy(String name, ObsBucketPolicyArgs args)
public ObsBucketPolicy(String name, ObsBucketPolicyArgs args, CustomResourceOptions options)
type: flexibleengine:ObsBucketPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ObsBucketPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ObsBucketPolicyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ObsBucketPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ObsBucketPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ObsBucketPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var obsBucketPolicyResource = new Flexibleengine.ObsBucketPolicy("obsBucketPolicyResource", new()
{
    Bucket = "string",
    Policy = "string",
    ObsBucketPolicyId = "string",
    PolicyFormat = "string",
    Region = "string",
});
Copy
example, err := flexibleengine.NewObsBucketPolicy(ctx, "obsBucketPolicyResource", &flexibleengine.ObsBucketPolicyArgs{
Bucket: pulumi.String("string"),
Policy: pulumi.String("string"),
ObsBucketPolicyId: pulumi.String("string"),
PolicyFormat: pulumi.String("string"),
Region: pulumi.String("string"),
})
Copy
var obsBucketPolicyResource = new ObsBucketPolicy("obsBucketPolicyResource", ObsBucketPolicyArgs.builder()
    .bucket("string")
    .policy("string")
    .obsBucketPolicyId("string")
    .policyFormat("string")
    .region("string")
    .build());
Copy
obs_bucket_policy_resource = flexibleengine.ObsBucketPolicy("obsBucketPolicyResource",
    bucket="string",
    policy="string",
    obs_bucket_policy_id="string",
    policy_format="string",
    region="string")
Copy
const obsBucketPolicyResource = new flexibleengine.ObsBucketPolicy("obsBucketPolicyResource", {
    bucket: "string",
    policy: "string",
    obsBucketPolicyId: "string",
    policyFormat: "string",
    region: "string",
});
Copy
type: flexibleengine:ObsBucketPolicy
properties:
    bucket: string
    obsBucketPolicyId: string
    policy: string
    policyFormat: string
    region: string
Copy

ObsBucketPolicy Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ObsBucketPolicy resource accepts the following input properties:

Bucket This property is required. string
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
Policy This property is required. string
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
ObsBucketPolicyId string
Specifies a resource ID in UUID format.
PolicyFormat string
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
Region string
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
Bucket This property is required. string
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
Policy This property is required. string
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
ObsBucketPolicyId string
Specifies a resource ID in UUID format.
PolicyFormat string
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
Region string
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket This property is required. String
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
policy This property is required. String
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
obsBucketPolicyId String
Specifies a resource ID in UUID format.
policyFormat String
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region String
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket This property is required. string
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
policy This property is required. string
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
obsBucketPolicyId string
Specifies a resource ID in UUID format.
policyFormat string
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region string
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket This property is required. str
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
policy This property is required. str
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
obs_bucket_policy_id str
Specifies a resource ID in UUID format.
policy_format str
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region str
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket This property is required. String
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
policy This property is required. String
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
obsBucketPolicyId String
Specifies a resource ID in UUID format.
policyFormat String
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region String
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.

Outputs

All input properties are implicitly available as output properties. Additionally, the ObsBucketPolicy 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 ObsBucketPolicy Resource

Get an existing ObsBucketPolicy 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?: ObsBucketPolicyState, opts?: CustomResourceOptions): ObsBucketPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        bucket: Optional[str] = None,
        obs_bucket_policy_id: Optional[str] = None,
        policy: Optional[str] = None,
        policy_format: Optional[str] = None,
        region: Optional[str] = None) -> ObsBucketPolicy
func GetObsBucketPolicy(ctx *Context, name string, id IDInput, state *ObsBucketPolicyState, opts ...ResourceOption) (*ObsBucketPolicy, error)
public static ObsBucketPolicy Get(string name, Input<string> id, ObsBucketPolicyState? state, CustomResourceOptions? opts = null)
public static ObsBucketPolicy get(String name, Output<String> id, ObsBucketPolicyState state, CustomResourceOptions options)
resources:  _:    type: flexibleengine:ObsBucketPolicy    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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.
The following state arguments are supported:
Bucket string
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
ObsBucketPolicyId string
Specifies a resource ID in UUID format.
Policy string
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
PolicyFormat string
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
Region string
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
Bucket string
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
ObsBucketPolicyId string
Specifies a resource ID in UUID format.
Policy string
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
PolicyFormat string
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
Region string
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket String
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
obsBucketPolicyId String
Specifies a resource ID in UUID format.
policy String
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
policyFormat String
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region String
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket string
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
obsBucketPolicyId string
Specifies a resource ID in UUID format.
policy string
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
policyFormat string
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region string
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket str
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
obs_bucket_policy_id str
Specifies a resource ID in UUID format.
policy str
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
policy_format str
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region str
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.
bucket String
Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
obsBucketPolicyId String
Specifies a resource ID in UUID format.
policy String
Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
policyFormat String
Specifies the policy format, the supported values are obs and s3. Defaults to obs .
region String
The region in which to create the OBS bucket policy resource. If omitted, the provider-level region will be used. Changing this creates a new OBS bucket policy resource.

Import

OBS format bucket policy can be imported using the <bucket>, e.g.

bash

$ pulumi import flexibleengine:index/obsBucketPolicy:ObsBucketPolicy policy <bucket-name>
Copy

S3 foramt bucket policy can be imported using the <bucket> and “s3” by a slash, e.g.

bash

$ pulumi import flexibleengine:index/obsBucketPolicy:ObsBucketPolicy s3_policy <bucket-name>/s3
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
flexibleengine flexibleenginecloud/terraform-provider-flexibleengine
License
Notes
This Pulumi package is based on the flexibleengine Terraform Provider.