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/*"
}
]
}
`,
});
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/*"
}
]
}
""")
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
})
}
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/*""
}
]
}
",
});
});
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());
}
}
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/*"
}
]
}
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"}
}
}
]
}
`,
});
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"}
}
}
]
}
""")
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
})
}
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""}
}
}
]
}
",
});
});
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());
}
}
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"}
}
}
]
}
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 string
- The unique name of the resource.
- args ObsBucketPolicyArgs
- 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 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 string
- The unique name of the resource.
- args ObsBucketPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ObsBucketPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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",
});
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"),
})
var obsBucketPolicyResource = new ObsBucketPolicy("obsBucketPolicyResource", ObsBucketPolicyArgs.builder()
.bucket("string")
.policy("string")
.obsBucketPolicyId("string")
.policyFormat("string")
.region("string")
.build());
obs_bucket_policy_resource = flexibleengine.ObsBucketPolicy("obsBucketPolicyResource",
bucket="string",
policy="string",
obs_bucket_policy_id="string",
policy_format="string",
region="string")
const obsBucketPolicyResource = new flexibleengine.ObsBucketPolicy("obsBucketPolicyResource", {
bucket: "string",
policy: "string",
obsBucketPolicyId: "string",
policyFormat: "string",
region: "string",
});
type: flexibleengine:ObsBucketPolicy
properties:
bucket: string
obsBucketPolicyId: string
policy: string
policyFormat: string
region: string
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 string
- Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
- Policy string
- Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
- Obs
Bucket stringPolicy Id - Specifies a resource ID in UUID format.
- Policy
Format 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.
- Policy string
- Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
- Obs
Bucket stringPolicy Id - Specifies a resource ID in UUID format.
- Policy
Format 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.
- policy String
- Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
- obs
Bucket StringPolicy Id - Specifies a resource ID in UUID format.
- policy
Format 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.
- policy string
- Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
- obs
Bucket stringPolicy Id - Specifies a resource ID in UUID format.
- policy
Format 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.
- policy 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_ strpolicy_ id - 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 String
- Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
- policy String
- Specifies the text of the bucket policy in JSON format. For more information about obs format bucket policy, see the Developer Guide.
- obs
Bucket StringPolicy Id - Specifies a resource ID in UUID format.
- policy
Format 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
- 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
- Specifies the name of the bucket to which to apply the policy. Changing this creates a new obs bucket policy resource.
- Obs
Bucket stringPolicy Id - 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.
- Policy
Format 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.
- Obs
Bucket stringPolicy Id - 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.
- Policy
Format 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.
- obs
Bucket StringPolicy Id - 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.
- policy
Format 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.
- obs
Bucket stringPolicy Id - 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.
- policy
Format 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_ strpolicy_ id - 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.
- obs
Bucket StringPolicy Id - 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.
- policy
Format 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>
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
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.