Class Bucket
An S3 bucket with associated policy objects.
Inherited Members
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 |
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. |
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 |
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
BucketArn
The ARN of the bucket.
public override string BucketArn { get; }
Property Value
System.String
Overrides
BucketDomainName
The IPv4 DNS name of the specified bucket.
public override string BucketDomainName { get; }
Property Value
System.String
Overrides
BucketDualStackDomainName
The IPv6 DNS name of the specified bucket.
public override string BucketDualStackDomainName { get; }
Property Value
System.String
Overrides
BucketName
The name of the bucket.
public override string BucketName { get; }
Property Value
System.String
Overrides
BucketRegionalDomainName
The regional domain name of the specified bucket.
public override string BucketRegionalDomainName { get; }
Property Value
System.String
Overrides
BucketWebsiteDomainName
The Domain name of the static website.
public override string BucketWebsiteDomainName { get; }
Property Value
System.String
Overrides
BucketWebsiteUrl
The URL of the static website.
public override string BucketWebsiteUrl { get; }
Property Value
System.String
Overrides
DisallowPublicAccess
Whether to disallow public access.
protected override Nullable<bool> DisallowPublicAccess { get; set; }
Property Value
System.Nullable<System.Boolean>
Overrides
EncryptionKey
Optional KMS encryption key associated with this bucket.
public override IKey EncryptionKey { get; }
Property Value
Overrides
IsWebsite
If this bucket has been configured for static website hosting.
public override Nullable<bool> IsWebsite { get; }
Property Value
System.Nullable<System.Boolean>
Overrides
Policy
The resource policy associated with this bucket.
public override BucketPolicy Policy { get; set; }
Property Value
Overrides
Remarks
If autoCreatePolicy
is true, a BucketPolicy
will be created upon the
first call to addToResourcePolicy(s).
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
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
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
FromCfnBucket(CfnBucket)
Create a mutable IBucket
based on a low-level CfnBucket
.
public static IBucket FromCfnBucket(CfnBucket cfnBucket)
Parameters
- cfnBucket CfnBucket
Returns
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.