opentelekomcloud.ObsBucketPolicy
Explore with Pulumi AI
Up-to-date reference of API arguments for OBS bucket policy you can get at documentation portal
Attaches a policy to an OBS bucket resource within OpenTelekomCloud. Now respects HTTP_PROXY, HTTPS_PROXY environment variables.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as opentelekomcloud from "@pulumi/opentelekomcloud";
const bucket = new opentelekomcloud.ObsBucket("bucket", {bucket: "my-tf-test-bucket"});
const policy = new opentelekomcloud.ObsBucketPolicy("policy", {
bucket: bucket.obsBucketId,
policy: pulumi.interpolate`{
"Statement": [{
"Effect": "Allow",
"Principal": {
"ID": ["*"]
},
"Action": [
"GetObject",
"PutObject"
],
"Resource": [
"${bucket.bucket}/*"
]
}]
}
`,
});
import pulumi
import pulumi_opentelekomcloud as opentelekomcloud
bucket = opentelekomcloud.ObsBucket("bucket", bucket="my-tf-test-bucket")
policy = opentelekomcloud.ObsBucketPolicy("policy",
bucket=bucket.obs_bucket_id,
policy=bucket.bucket.apply(lambda bucket: f"""{{
"Statement": [{{
"Effect": "Allow",
"Principal": {{
"ID": ["*"]
}},
"Action": [
"GetObject",
"PutObject"
],
"Resource": [
"{bucket}/*"
]
}}]
}}
"""))
package main
import (
"fmt"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/opentelekomcloud/opentelekomcloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bucket, err := opentelekomcloud.NewObsBucket(ctx, "bucket", &opentelekomcloud.ObsBucketArgs{
Bucket: pulumi.String("my-tf-test-bucket"),
})
if err != nil {
return err
}
_, err = opentelekomcloud.NewObsBucketPolicy(ctx, "policy", &opentelekomcloud.ObsBucketPolicyArgs{
Bucket: bucket.ObsBucketId,
Policy: bucket.Bucket.ApplyT(func(bucket string) (string, error) {
return fmt.Sprintf(`{
"Statement": [{
"Effect": "Allow",
"Principal": {
"ID": ["*"]
},
"Action": [
"GetObject",
"PutObject"
],
"Resource": [
"%v/*"
]
}]
}
`, bucket), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Opentelekomcloud = Pulumi.Opentelekomcloud;
return await Deployment.RunAsync(() =>
{
var bucket = new Opentelekomcloud.ObsBucket("bucket", new()
{
Bucket = "my-tf-test-bucket",
});
var policy = new Opentelekomcloud.ObsBucketPolicy("policy", new()
{
Bucket = bucket.ObsBucketId,
Policy = bucket.Bucket.Apply(bucket => @$"{{
""Statement"": [{{
""Effect"": ""Allow"",
""Principal"": {{
""ID"": [""*""]
}},
""Action"": [
""GetObject"",
""PutObject""
],
""Resource"": [
""{bucket}/*""
]
}}]
}}
"),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.opentelekomcloud.ObsBucket;
import com.pulumi.opentelekomcloud.ObsBucketArgs;
import com.pulumi.opentelekomcloud.ObsBucketPolicy;
import com.pulumi.opentelekomcloud.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-tf-test-bucket")
.build());
var policy = new ObsBucketPolicy("policy", ObsBucketPolicyArgs.builder()
.bucket(bucket.obsBucketId())
.policy(bucket.bucket().applyValue(bucket -> """
{
"Statement": [{
"Effect": "Allow",
"Principal": {
"ID": ["*"]
},
"Action": [
"GetObject",
"PutObject"
],
"Resource": [
"%s/*"
]
}]
}
", bucket)))
.build());
}
}
resources:
bucket:
type: opentelekomcloud:ObsBucket
properties:
bucket: my-tf-test-bucket
policy:
type: opentelekomcloud:ObsBucketPolicy
properties:
bucket: ${bucket.obsBucketId}
policy: |
{
"Statement": [{
"Effect": "Allow",
"Principal": {
"ID": ["*"]
},
"Action": [
"GetObject",
"PutObject"
],
"Resource": [
"${bucket.bucket}/*"
]
}]
}
~>
Please note that used policy syntax is OBS-specific. For s3-compatible policies check
opentelekomcloud.S3BucketPolicy
resource.
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)
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: opentelekomcloud: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 Opentelekomcloud.ObsBucketPolicy("obsBucketPolicyResource", new()
{
Bucket = "string",
Policy = "string",
ObsBucketPolicyId = "string",
});
example, err := opentelekomcloud.NewObsBucketPolicy(ctx, "obsBucketPolicyResource", &opentelekomcloud.ObsBucketPolicyArgs{
Bucket: pulumi.String("string"),
Policy: pulumi.String("string"),
ObsBucketPolicyId: pulumi.String("string"),
})
var obsBucketPolicyResource = new ObsBucketPolicy("obsBucketPolicyResource", ObsBucketPolicyArgs.builder()
.bucket("string")
.policy("string")
.obsBucketPolicyId("string")
.build());
obs_bucket_policy_resource = opentelekomcloud.ObsBucketPolicy("obsBucketPolicyResource",
bucket="string",
policy="string",
obs_bucket_policy_id="string")
const obsBucketPolicyResource = new opentelekomcloud.ObsBucketPolicy("obsBucketPolicyResource", {
bucket: "string",
policy: "string",
obsBucketPolicyId: "string",
});
type: opentelekomcloud:ObsBucketPolicy
properties:
bucket: string
obsBucketPolicyId: string
policy: 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
- The name of the bucket to which to apply the policy.
- Policy string
- The text of the policy.
- Obs
Bucket stringPolicy Id
- Bucket string
- The name of the bucket to which to apply the policy.
- Policy string
- The text of the policy.
- Obs
Bucket stringPolicy Id
- bucket String
- The name of the bucket to which to apply the policy.
- policy String
- The text of the policy.
- obs
Bucket StringPolicy Id
- bucket string
- The name of the bucket to which to apply the policy.
- policy string
- The text of the policy.
- obs
Bucket stringPolicy Id
- bucket str
- The name of the bucket to which to apply the policy.
- policy str
- The text of the policy.
- obs_
bucket_ strpolicy_ id
- bucket String
- The name of the bucket to which to apply the policy.
- policy String
- The text of the policy.
- obs
Bucket StringPolicy Id
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) -> 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: opentelekomcloud: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
- The name of the bucket to which to apply the policy.
- Obs
Bucket stringPolicy Id - Policy string
- The text of the policy.
- Bucket string
- The name of the bucket to which to apply the policy.
- Obs
Bucket stringPolicy Id - Policy string
- The text of the policy.
- bucket String
- The name of the bucket to which to apply the policy.
- obs
Bucket StringPolicy Id - policy String
- The text of the policy.
- bucket string
- The name of the bucket to which to apply the policy.
- obs
Bucket stringPolicy Id - policy string
- The text of the policy.
- bucket str
- The name of the bucket to which to apply the policy.
- obs_
bucket_ strpolicy_ id - policy str
- The text of the policy.
- bucket String
- The name of the bucket to which to apply the policy.
- obs
Bucket StringPolicy Id - policy String
- The text of the policy.
Package Details
- Repository
- opentelekomcloud opentelekomcloud/terraform-provider-opentelekomcloud
- License
- Notes
- This Pulumi package is based on the
opentelekomcloud
Terraform Provider.