opentelekomcloud.S3BucketPolicy
Explore with Pulumi AI
Attaches a policy to an S3 bucket resource within OpenTelekomCloud.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as opentelekomcloud from "@pulumi/opentelekomcloud";
const s3Bucket = new opentelekomcloud.S3Bucket("s3Bucket", {bucket: "my-tf-test-bucket"});
const s3BucketPolicy = new opentelekomcloud.S3BucketPolicy("s3BucketPolicy", {
bucket: s3Bucket.s3BucketId,
policy: pulumi.interpolate` {
"Id": "MYBUCKETPOLICY",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::${s3Bucket.bucket}/*",
"Condition": {
"IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
}
}
]}
`,
});
import pulumi
import pulumi_opentelekomcloud as opentelekomcloud
s3_bucket = opentelekomcloud.S3Bucket("s3Bucket", bucket="my-tf-test-bucket")
s3_bucket_policy = opentelekomcloud.S3BucketPolicy("s3BucketPolicy",
bucket=s3_bucket.s3_bucket_id,
policy=s3_bucket.bucket.apply(lambda bucket: f""" {{
"Id": "MYBUCKETPOLICY",
"Statement": [
{{
"Sid": "IPAllow",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::{bucket}/*",
"Condition": {{
"IpAddress": {{"aws:SourceIp": "8.8.8.8/32"}}
}}
}}
]}}
"""))
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 {
s3Bucket, err := opentelekomcloud.NewS3Bucket(ctx, "s3Bucket", &opentelekomcloud.S3BucketArgs{
Bucket: pulumi.String("my-tf-test-bucket"),
})
if err != nil {
return err
}
_, err = opentelekomcloud.NewS3BucketPolicy(ctx, "s3BucketPolicy", &opentelekomcloud.S3BucketPolicyArgs{
Bucket: s3Bucket.S3BucketId,
Policy: s3Bucket.Bucket.ApplyT(func(bucket string) (string, error) {
return fmt.Sprintf(` {
"Id": "MYBUCKETPOLICY",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::%v/*",
"Condition": {
"IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
}
}
]}
`, 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 s3Bucket = new Opentelekomcloud.S3Bucket("s3Bucket", new()
{
Bucket = "my-tf-test-bucket",
});
var s3BucketPolicy = new Opentelekomcloud.S3BucketPolicy("s3BucketPolicy", new()
{
Bucket = s3Bucket.S3BucketId,
Policy = s3Bucket.Bucket.Apply(bucket => @$" {{
""Id"": ""MYBUCKETPOLICY"",
""Statement"": [
{{
""Sid"": ""IPAllow"",
""Effect"": ""Deny"",
""Principal"": ""*"",
""Action"": ""s3:*"",
""Resource"": ""arn:aws:s3:::{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.opentelekomcloud.S3Bucket;
import com.pulumi.opentelekomcloud.S3BucketArgs;
import com.pulumi.opentelekomcloud.S3BucketPolicy;
import com.pulumi.opentelekomcloud.S3BucketPolicyArgs;
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 s3Bucket = new S3Bucket("s3Bucket", S3BucketArgs.builder()
.bucket("my-tf-test-bucket")
.build());
var s3BucketPolicy = new S3BucketPolicy("s3BucketPolicy", S3BucketPolicyArgs.builder()
.bucket(s3Bucket.s3BucketId())
.policy(s3Bucket.bucket().applyValue(bucket -> """
{
"Id": "MYBUCKETPOLICY",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::%s/*",
"Condition": {
"IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
}
}
]}
", bucket)))
.build());
}
}
resources:
s3Bucket:
type: opentelekomcloud:S3Bucket
properties:
bucket: my-tf-test-bucket
s3BucketPolicy:
type: opentelekomcloud:S3BucketPolicy
properties:
bucket: ${s3Bucket.s3BucketId}
policy: |2
{
"Id": "MYBUCKETPOLICY",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::${s3Bucket.bucket}/*",
"Condition": {
"IpAddress": {"aws:SourceIp": "8.8.8.8/32"}
}
}
]}
Create S3BucketPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new S3BucketPolicy(name: string, args: S3BucketPolicyArgs, opts?: CustomResourceOptions);
@overload
def S3BucketPolicy(resource_name: str,
args: S3BucketPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def S3BucketPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
policy: Optional[str] = None,
s3_bucket_policy_id: Optional[str] = None)
func NewS3BucketPolicy(ctx *Context, name string, args S3BucketPolicyArgs, opts ...ResourceOption) (*S3BucketPolicy, error)
public S3BucketPolicy(string name, S3BucketPolicyArgs args, CustomResourceOptions? opts = null)
public S3BucketPolicy(String name, S3BucketPolicyArgs args)
public S3BucketPolicy(String name, S3BucketPolicyArgs args, CustomResourceOptions options)
type: opentelekomcloud:S3BucketPolicy
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 S3BucketPolicyArgs
- 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 S3BucketPolicyArgs
- 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 S3BucketPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args S3BucketPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args S3BucketPolicyArgs
- 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 s3bucketPolicyResource = new Opentelekomcloud.S3BucketPolicy("s3bucketPolicyResource", new()
{
Bucket = "string",
Policy = "string",
S3BucketPolicyId = "string",
});
example, err := opentelekomcloud.NewS3BucketPolicy(ctx, "s3bucketPolicyResource", &opentelekomcloud.S3BucketPolicyArgs{
Bucket: pulumi.String("string"),
Policy: pulumi.String("string"),
S3BucketPolicyId: pulumi.String("string"),
})
var s3bucketPolicyResource = new S3BucketPolicy("s3bucketPolicyResource", S3BucketPolicyArgs.builder()
.bucket("string")
.policy("string")
.s3BucketPolicyId("string")
.build());
s3bucket_policy_resource = opentelekomcloud.S3BucketPolicy("s3bucketPolicyResource",
bucket="string",
policy="string",
s3_bucket_policy_id="string")
const s3bucketPolicyResource = new opentelekomcloud.S3BucketPolicy("s3bucketPolicyResource", {
bucket: "string",
policy: "string",
s3BucketPolicyId: "string",
});
type: opentelekomcloud:S3BucketPolicy
properties:
bucket: string
policy: string
s3BucketPolicyId: string
S3BucketPolicy 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 S3BucketPolicy 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.
- S3Bucket
Policy stringId
- Bucket string
- The name of the bucket to which to apply the policy.
- Policy string
- The text of the policy.
- S3Bucket
Policy stringId
- bucket String
- The name of the bucket to which to apply the policy.
- policy String
- The text of the policy.
- s3Bucket
Policy StringId
- bucket string
- The name of the bucket to which to apply the policy.
- policy string
- The text of the policy.
- s3Bucket
Policy stringId
- bucket str
- The name of the bucket to which to apply the policy.
- policy str
- The text of the policy.
- s3_
bucket_ strpolicy_ id
- bucket String
- The name of the bucket to which to apply the policy.
- policy String
- The text of the policy.
- s3Bucket
Policy StringId
Outputs
All input properties are implicitly available as output properties. Additionally, the S3BucketPolicy 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 S3BucketPolicy Resource
Get an existing S3BucketPolicy 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?: S3BucketPolicyState, opts?: CustomResourceOptions): S3BucketPolicy
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
policy: Optional[str] = None,
s3_bucket_policy_id: Optional[str] = None) -> S3BucketPolicy
func GetS3BucketPolicy(ctx *Context, name string, id IDInput, state *S3BucketPolicyState, opts ...ResourceOption) (*S3BucketPolicy, error)
public static S3BucketPolicy Get(string name, Input<string> id, S3BucketPolicyState? state, CustomResourceOptions? opts = null)
public static S3BucketPolicy get(String name, Output<String> id, S3BucketPolicyState state, CustomResourceOptions options)
resources: _: type: opentelekomcloud:S3BucketPolicy 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.
- Policy string
- The text of the policy.
- S3Bucket
Policy stringId
- Bucket string
- The name of the bucket to which to apply the policy.
- Policy string
- The text of the policy.
- S3Bucket
Policy stringId
- bucket String
- The name of the bucket to which to apply the policy.
- policy String
- The text of the policy.
- s3Bucket
Policy StringId
- bucket string
- The name of the bucket to which to apply the policy.
- policy string
- The text of the policy.
- s3Bucket
Policy stringId
- bucket str
- The name of the bucket to which to apply the policy.
- policy str
- The text of the policy.
- s3_
bucket_ strpolicy_ id
- bucket String
- The name of the bucket to which to apply the policy.
- policy String
- The text of the policy.
- s3Bucket
Policy StringId
Package Details
- Repository
- opentelekomcloud opentelekomcloud/terraform-provider-opentelekomcloud
- License
- Notes
- This Pulumi package is based on the
opentelekomcloud
Terraform Provider.