Show / Hide Table of Contents

Class Bucket

An S3 bucket with associated policy objects.

Inheritance
System.Object
Resource
BucketBase
Bucket
Implements
IBucket
IResource
Constructs.IConstruct
Constructs.IDependable
Inherited Members
BucketBase.AddEventNotification(EventType, IBucketNotificationDestination, INotificationKeyFilter[])
BucketBase.AddObjectCreatedNotification(IBucketNotificationDestination, INotificationKeyFilter[])
BucketBase.AddObjectRemovedNotification(IBucketNotificationDestination, INotificationKeyFilter[])
BucketBase.AddReplicationPolicy(String, Nullable<Boolean>, String)
BucketBase.AddToResourcePolicy(PolicyStatement)
BucketBase.ArnForObjects(String)
BucketBase.EnableEventBridgeNotification()
BucketBase.GrantDelete(IGrantable, Object)
BucketBase.GrantPublicAccess(String, String[])
BucketBase.GrantPut(IGrantable, Object)
BucketBase.GrantPutAcl(IGrantable, String)
BucketBase.GrantRead(IGrantable, Object)
BucketBase.GrantReadWrite(IGrantable, Object)
BucketBase.GrantWrite(IGrantable, Object, String[])
BucketBase.OnCloudTrailEvent(String, IOnCloudTrailBucketEventOptions)
BucketBase.OnCloudTrailPutObject(String, IOnCloudTrailBucketEventOptions)
BucketBase.OnCloudTrailWriteObject(String, IOnCloudTrailBucketEventOptions)
BucketBase.S3UrlForObject(String)
BucketBase.TransferAccelerationUrlForObject(String, ITransferAccelerationUrlOptions)
BucketBase.UrlForObject(String)
BucketBase.VirtualHostedUrlForObject(String, IVirtualHostedStyleUrlOptions)
BucketBase.NotificationsHandlerRole
BucketBase.NotificationsSkipDestinationValidation
BucketBase.ObjectOwnership
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(String, IArnComponents)
Resource.GetResourceNameAttribute(String)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.S3
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Bucket : BucketBase, IBucket, IResource
Syntax (vb)
Public Class Bucket
    Inherits BucketBase
    Implements IBucket, IResource
Remarks

This bucket does not yet have all features that exposed by the underlying BucketResource.

Examples
using Amazon.CDK;


new Bucket(scope, "Bucket", new BucketProps {
    BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
    Encryption = BucketEncryption.S3_MANAGED,
    EnforceSSL = true,
    Versioned = true,
    RemovalPolicy = RemovalPolicy.RETAIN
});

Synopsis

Constructors

Bucket(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

Bucket(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Bucket(Construct, String, IBucketProps)

Properties

AutoCreatePolicy

Indicates if a bucket resource policy should automatically created upon the first call to addToResourcePolicy.

BucketArn

The ARN of the bucket.

BucketDomainName

The IPv4 DNS name of the specified bucket.

BucketDualStackDomainName

The IPv6 DNS name of the specified bucket.

BucketName

The name of the bucket.

BucketRegionalDomainName

The regional domain name of the specified bucket.

BucketWebsiteDomainName

The Domain name of the static website.

BucketWebsiteUrl

The URL of the static website.

DisallowPublicAccess

Whether to disallow public access.

EncryptionKey

Optional KMS encryption key associated with this bucket.

IsWebsite

If this bucket has been configured for static website hosting.

Policy

The resource policy associated with this bucket.

ReplicationRoleArn

Role used to set up permissions on this bucket for replication.

Methods

AddCorsRule(ICorsRule)

Adds a cross-origin access configuration for objects in an Amazon S3 bucket.

AddInventory(IInventory)

Add an inventory configuration.

AddLifecycleRule(ILifecycleRule)

Add a lifecycle rule to the bucket.

AddMetric(IBucketMetrics)

Adds a metrics configuration for the CloudWatch request metrics from the bucket.

FromBucketArn(Construct, String, String)
FromBucketAttributes(Construct, String, IBucketAttributes)

Creates a Bucket construct that represents an external bucket.

FromBucketName(Construct, String, String)
FromCfnBucket(CfnBucket)

Create a mutable IBucket based on a low-level CfnBucket.

ValidateBucketName(String, Nullable<Boolean>)

Thrown an exception if the given bucket name is not valid.

Constructors

Bucket(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected Bucket(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

Bucket(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected Bucket(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Bucket(Construct, String, IBucketProps)

public Bucket(Construct scope, string id, IBucketProps props = null)
Parameters
scope Constructs.Construct
id System.String
props IBucketProps

Properties

AutoCreatePolicy

Indicates if a bucket resource policy should automatically created upon the first call to addToResourcePolicy.

protected override bool AutoCreatePolicy { get; set; }
Property Value

System.Boolean

Overrides
BucketBase.AutoCreatePolicy

BucketArn

The ARN of the bucket.

public override string BucketArn { get; }
Property Value

System.String

Overrides
BucketBase.BucketArn

BucketDomainName

The IPv4 DNS name of the specified bucket.

public override string BucketDomainName { get; }
Property Value

System.String

Overrides
BucketBase.BucketDomainName

BucketDualStackDomainName

The IPv6 DNS name of the specified bucket.

public override string BucketDualStackDomainName { get; }
Property Value

System.String

Overrides
BucketBase.BucketDualStackDomainName

BucketName

The name of the bucket.

public override string BucketName { get; }
Property Value

System.String

Overrides
BucketBase.BucketName

BucketRegionalDomainName

The regional domain name of the specified bucket.

public override string BucketRegionalDomainName { get; }
Property Value

System.String

Overrides
BucketBase.BucketRegionalDomainName

BucketWebsiteDomainName

The Domain name of the static website.

public override string BucketWebsiteDomainName { get; }
Property Value

System.String

Overrides
BucketBase.BucketWebsiteDomainName

BucketWebsiteUrl

The URL of the static website.

public override string BucketWebsiteUrl { get; }
Property Value

System.String

Overrides
BucketBase.BucketWebsiteUrl

DisallowPublicAccess

Whether to disallow public access.

protected override Nullable<bool> DisallowPublicAccess { get; set; }
Property Value

System.Nullable<System.Boolean>

Overrides
BucketBase.DisallowPublicAccess

EncryptionKey

Optional KMS encryption key associated with this bucket.

public override IKey EncryptionKey { get; }
Property Value

IKey

Overrides
BucketBase.EncryptionKey

IsWebsite

If this bucket has been configured for static website hosting.

public override Nullable<bool> IsWebsite { get; }
Property Value

System.Nullable<System.Boolean>

Overrides
BucketBase.IsWebsite

Policy

The resource policy associated with this bucket.

public override BucketPolicy Policy { get; set; }
Property Value

BucketPolicy

Overrides
BucketBase.Policy
Remarks

If autoCreatePolicy is true, a BucketPolicy will be created upon the first call to addToResourcePolicy(s).

ReplicationRoleArn

Role used to set up permissions on this bucket for replication.

public override string ReplicationRoleArn { get; set; }
Property Value

System.String

Overrides
BucketBase.ReplicationRoleArn

Methods

AddCorsRule(ICorsRule)

Adds a cross-origin access configuration for objects in an Amazon S3 bucket.

public virtual void AddCorsRule(ICorsRule rule)
Parameters
rule ICorsRule

The CORS configuration rule to add.

AddInventory(IInventory)

Add an inventory configuration.

public virtual void AddInventory(IInventory inventory)
Parameters
inventory IInventory

configuration to add.

AddLifecycleRule(ILifecycleRule)

Add a lifecycle rule to the bucket.

public virtual void AddLifecycleRule(ILifecycleRule rule)
Parameters
rule ILifecycleRule

The rule to add.

AddMetric(IBucketMetrics)

Adds a metrics configuration for the CloudWatch request metrics from the bucket.

public virtual void AddMetric(IBucketMetrics metric)
Parameters
metric IBucketMetrics

The metric configuration to add.

FromBucketArn(Construct, String, String)

public static IBucket FromBucketArn(Construct scope, string id, string bucketArn)
Parameters
scope Constructs.Construct
id System.String
bucketArn System.String
Returns

IBucket

FromBucketAttributes(Construct, String, IBucketAttributes)

Creates a Bucket construct that represents an external bucket.

public static IBucket FromBucketAttributes(Construct scope, string id, IBucketAttributes attrs)
Parameters
scope Constructs.Construct

The parent creating construct (usually this).

id System.String

The construct's name.

attrs IBucketAttributes

A BucketAttributes object.

Returns

IBucket

FromBucketName(Construct, String, String)

public static IBucket FromBucketName(Construct scope, string id, string bucketName)
Parameters
scope Constructs.Construct
id System.String
bucketName System.String
Returns

IBucket

FromCfnBucket(CfnBucket)

Create a mutable IBucket based on a low-level CfnBucket.

public static IBucket FromCfnBucket(CfnBucket cfnBucket)
Parameters
cfnBucket CfnBucket
Returns

IBucket

ValidateBucketName(String, Nullable<Boolean>)

Thrown an exception if the given bucket name is not valid.

public static void ValidateBucketName(string physicalName, Nullable<bool> allowLegacyBucketNaming = null)
Parameters
physicalName System.String

name of the bucket.

allowLegacyBucketNaming System.Nullable<System.Boolean>

allow legacy bucket naming style, default is false.

Implements

IBucket
IResource
Constructs.IConstruct
Constructs.IDependable
Back to top Generated by DocFX