pub struct BucketPolicyBuilder { /* private fields */ }Expand description
Builder for S3 bucket policies.
Creates a policy document that controls access to an S3 bucket.
§Example
use serde_json::Value;
use rusty_cdk_core::stack::StackBuilder;
use rusty_cdk_core::s3::BucketPolicyBuilder;
use rusty_cdk_core::iam::{PolicyDocumentBuilder, StatementBuilder, Effect, PrincipalBuilder};
use rusty_cdk_core::wrappers::*;
use rusty_cdk_core::s3::BucketBuilder;
use rusty_cdk_macros::iam_action;
let mut stack_builder = StackBuilder::new();
let bucket = unimplemented!("create a bucket");
let resources = vec![Value::String("*".to_string())];
let statement = StatementBuilder::new(
vec![iam_action!("s3:GetObject")],
Effect::Allow
)
.principal(PrincipalBuilder::new().normal("*").build())
.resources(resources)
.build();
let policy_doc = PolicyDocumentBuilder::new(vec![statement]).build();
let policy = BucketPolicyBuilder::new("bucket-policy", &bucket, policy_doc)
.build(&mut stack_builder);See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucketpolicy.html
Implementations§
Source§impl BucketPolicyBuilder
impl BucketPolicyBuilder
Sourcepub fn new(
id: &str,
bucket: &BucketRef,
policy_document: PolicyDocument,
) -> BucketPolicyBuilder
pub fn new( id: &str, bucket: &BucketRef, policy_document: PolicyDocument, ) -> BucketPolicyBuilder
Creates a new S3 bucket policy builder.
§Arguments
id- Unique identifier for the bucket policybucket- Reference to the S3 bucketpolicy_document- IAM policy document controlling access
pub fn build(self, stack_builder: &mut StackBuilder) -> BucketPolicyRef
Auto Trait Implementations§
impl Freeze for BucketPolicyBuilder
impl RefUnwindSafe for BucketPolicyBuilder
impl Send for BucketPolicyBuilder
impl Sync for BucketPolicyBuilder
impl Unpin for BucketPolicyBuilder
impl UnwindSafe for BucketPolicyBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.