Class BucketPolicy
Attaches a policy to an S3 bucket resource.
Example Usage
Basic Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var bucket = new Aws.S3.Bucket("bucket", new Aws.S3.BucketArgs
{
});
var bucketPolicy = new Aws.S3.BucketPolicy("bucketPolicy", new Aws.S3.BucketPolicyArgs
{
Bucket = bucket.Id,
Policy = @"{
""Version"": ""2012-10-17"",
""Id"": ""MYBUCKETPOLICY"",
""Statement"": [
{
""Sid"": ""IPAllow"",
""Effect"": ""Deny"",
""Principal"": ""*"",
""Action"": ""s3:*"",
""Resource"": ""arn:aws:s3:::my_tf_test_bucket/*"",
""Condition"": {
""IpAddress"": {""aws:SourceIp"": ""8.8.8.8/32""}
}
}
]
}
",
});
}
}
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.S3
Assembly: Pulumi.Aws.dll
Syntax
public class BucketPolicy : CustomResource
Constructors
View SourceBucketPolicy(String, BucketPolicyArgs, CustomResourceOptions)
Create a BucketPolicy resource with the given unique name, arguments, and options.
Declaration
public BucketPolicy(string name, BucketPolicyArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| BucketPolicyArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceBucket
The name of the bucket to which to apply the policy.
Declaration
public Output<string> Bucket { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Policy
The text of the policy.
Declaration
public Output<string> Policy { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, BucketPolicyState, CustomResourceOptions)
Get an existing BucketPolicy resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static BucketPolicy Get(string name, Input<string> id, BucketPolicyState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| BucketPolicyState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| BucketPolicy |