class Bucket (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.S3.Bucket |
Java | software.amazon.awscdk.services.s3.Bucket |
Python | aws_cdk.aws_s3.Bucket |
TypeScript (source) | @aws-cdk/aws-s3 » Bucket |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IBucket
An S3 bucket with associated policy objects.
This bucket does not yet have all features that exposed by the underlying BucketResource.
Example
declare const ecrRepository: ecr.Repository;
new codebuild.Project(this, 'Project', {
environment: {
buildImage: codebuild.WindowsBuildImage.fromEcrRepository(ecrRepository, 'v1.0', codebuild.WindowsImageType.SERVER_2019),
// optional certificate to include in the build image
certificate: {
bucket: s3.Bucket.fromBucketName(this, 'Bucket', 'my-bucket'),
objectKey: 'path/to/cert.pem',
},
},
// ...
})
Initializer
new Bucket(scope: Construct, id: string, props?: BucketProps)
Parameters
- scope
Construct
- id
string
- props
Bucket
Props
Construct Props
Name | Type | Description |
---|---|---|
access | Bucket | Specifies a canned ACL that grants predefined permissions to the bucket. |
auto | boolean | Whether all objects should be automatically deleted when the bucket is removed from the stack or when the stack is deleted. |
block | Block | The block public access configuration of this bucket. |
bucket | boolean | Specifies whether Amazon S3 should use an S3 Bucket Key with server-side encryption using KMS (SSE-KMS) for new objects in the bucket. |
bucket | string | Physical name of this bucket. |
cors? | Cors [] | The CORS configuration of this bucket. |
encryption? | Bucket | The kind of server-side encryption to apply to this bucket. |
encryption | IKey | External KMS key to use for bucket encryption. |
enforce | boolean | Enforces SSL for requests. |
event | boolean | Whether this bucket should send notifications to Amazon EventBridge or not. |
intelligent | Intelligent [] | Inteligent Tiering Configurations. |
inventories? | Inventory [] | The inventory configuration of the bucket. |
lifecycle | Lifecycle [] | Rules that define how Amazon S3 manages objects during their lifetime. |
metrics? | Bucket [] | The metrics configuration of this bucket. |
notifications | IRole | The role to be used by the notifications handler. |
object | Object | The objectOwnership of the bucket. |
public | boolean | Grants public read access to all objects in the bucket. |
removal | Removal | Policy to apply when the bucket is removed from this stack. |
server | IBucket | Destination bucket for the server access logs. |
server | string | Optional log file prefix to use for the bucket's access logs. |
transfer | boolean | Whether this bucket should have transfer acceleration turned on or not. |
versioned? | boolean | Whether this bucket should have versioning turned on or not. |
website | string | The name of the error document (e.g. "404.html") for the website. websiteIndexDocument must also be set if this is set. |
website | string | The name of the index document (e.g. "index.html") for the website. Enables static website hosting for this bucket. |
website | Redirect | Specifies the redirect behavior of all requests to a website endpoint of a bucket. |
website | Routing [] | Rules that define when a redirect is applied and the redirect behavior. |
accessControl?
Type:
Bucket
(optional, default: BucketAccessControl.PRIVATE)
Specifies a canned ACL that grants predefined permissions to the bucket.
autoDeleteObjects?
Type:
boolean
(optional, default: false)
Whether all objects should be automatically deleted when the bucket is removed from the stack or when the stack is deleted.
Requires the removalPolicy
to be set to RemovalPolicy.DESTROY
.
Warning if you have deployed a bucket with autoDeleteObjects: true
,
switching this to false
in a CDK version before 1.126.0
will lead to
all objects in the bucket being deleted. Be sure to update your bucket resources
by deploying with CDK version 1.126.0
or later before switching this value to false
.
blockPublicAccess?
Type:
Block
(optional, default: CloudFormation defaults will apply. New buckets and objects don't allow public access, but users can modify bucket policies or object permissions to allow public access)
The block public access configuration of this bucket.
bucketKeyEnabled?
Type:
boolean
(optional, default: false)
Specifies whether Amazon S3 should use an S3 Bucket Key with server-side encryption using KMS (SSE-KMS) for new objects in the bucket.
Only relevant, when Encryption is set to {@link BucketEncryption.KMS}
bucketName?
Type:
string
(optional, default: Assigned by CloudFormation (recommended).)
Physical name of this bucket.
cors?
Type:
Cors
[]
(optional, default: No CORS configuration.)
The CORS configuration of this bucket.
encryption?
Type:
Bucket
(optional, default: Kms
if encryptionKey
is specified, or Unencrypted
otherwise.)
The kind of server-side encryption to apply to this bucket.
If you choose KMS, you can specify a KMS key via encryptionKey
. If
encryption key is not specified, a key will automatically be created.
encryptionKey?
Type:
IKey
(optional, default: If encryption is set to "Kms" and this property is undefined,
a new KMS key will be created and associated with this bucket.)
External KMS key to use for bucket encryption.
The 'encryption' property must be either not specified or set to "Kms". An error will be emitted if encryption is set to "Unencrypted" or "Managed".
enforceSSL?
Type:
boolean
(optional, default: false)
Enforces SSL for requests.
S3.5 of the AWS Foundational Security Best Practices Regarding S3.
eventBridgeEnabled?
Type:
boolean
(optional, default: false)
Whether this bucket should send notifications to Amazon EventBridge or not.
intelligentTieringConfigurations?
Type:
Intelligent
[]
(optional, default: No Intelligent Tiiering Configurations.)
Inteligent Tiering Configurations.
See also: https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html
inventories?
Type:
Inventory
[]
(optional, default: No inventory configuration)
The inventory configuration of the bucket.
See also: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html
lifecycleRules?
Type:
Lifecycle
[]
(optional, default: No lifecycle rules.)
Rules that define how Amazon S3 manages objects during their lifetime.
metrics?
Type:
Bucket
[]
(optional, default: No metrics configuration.)
The metrics configuration of this bucket.
notificationsHandlerRole?
Type:
IRole
(optional, default: a new role will be created.)
The role to be used by the notifications handler.
objectOwnership?
Type:
Object
(optional, default: No ObjectOwnership configuration, uploading account will own the object.)
The objectOwnership of the bucket.
See also: https://docs.aws.amazon.com/AmazonS3/latest/dev/about-object-ownership.html
publicReadAccess?
Type:
boolean
(optional, default: false)
Grants public read access to all objects in the bucket.
Similar to calling bucket.grantPublicAccess()
removalPolicy?
Type:
Removal
(optional, default: The bucket will be orphaned.)
Policy to apply when the bucket is removed from this stack.
serverAccessLogsBucket?
Type:
IBucket
(optional, default: If "serverAccessLogsPrefix" undefined - access logs disabled, otherwise - log to current bucket.)
Destination bucket for the server access logs.
serverAccessLogsPrefix?
Type:
string
(optional, default: No log file prefix)
Optional log file prefix to use for the bucket's access logs.
If defined without "serverAccessLogsBucket", enables access logs to current bucket with this prefix.
transferAcceleration?
Type:
boolean
(optional, default: false)
Whether this bucket should have transfer acceleration turned on or not.
versioned?
Type:
boolean
(optional, default: false)
Whether this bucket should have versioning turned on or not.
websiteErrorDocument?
Type:
string
(optional, default: No error document.)
The name of the error document (e.g. "404.html") for the website. websiteIndexDocument
must also be set if this is set.
websiteIndexDocument?
Type:
string
(optional, default: No index document.)
The name of the index document (e.g. "index.html") for the website. Enables static website hosting for this bucket.
websiteRedirect?
Type:
Redirect
(optional, default: No redirection.)
Specifies the redirect behavior of all requests to a website endpoint of a bucket.
If you specify this property, you can't specify "websiteIndexDocument", "websiteErrorDocument" nor , "websiteRoutingRules".
websiteRoutingRules?
Type:
Routing
[]
(optional, default: No redirection rules.)
Rules that define when a redirect is applied and the redirect behavior.
Properties
Name | Type | Description |
---|---|---|
auto | boolean | Indicates if a bucket resource policy should automatically created upon the first call to addToResourcePolicy . |
bucket | string | The ARN of the bucket. |
bucket | string | The IPv4 DNS name of the specified bucket. |
bucket | string | The IPv6 DNS name of the specified bucket. |
bucket | string | The name of the bucket. |
bucket | string | The regional domain name of the specified bucket. |
bucket | string | The Domain name of the static website. |
bucket | string | The URL of the static website. |
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
disallow | boolean | Whether to disallow public access. |
encryption | IKey | Optional KMS encryption key associated with this bucket. |
is | boolean | If this bucket has been configured for static website hosting. |
policy? | Bucket | The resource policy associated with this bucket. |
autoCreatePolicy
Type:
boolean
Indicates if a bucket resource policy should automatically created upon the first call to addToResourcePolicy
.
bucketArn
Type:
string
The ARN of the bucket.
bucketDomainName
Type:
string
The IPv4 DNS name of the specified bucket.
bucketDualStackDomainName
Type:
string
The IPv6 DNS name of the specified bucket.
bucketName
Type:
string
The name of the bucket.
bucketRegionalDomainName
Type:
string
The regional domain name of the specified bucket.
bucketWebsiteDomainName
Type:
string
The Domain name of the static website.
bucketWebsiteUrl
Type:
string
The URL of the static website.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
disallowPublicAccess?
Type:
boolean
(optional)
Whether to disallow public access.
encryptionKey?
Type:
IKey
(optional)
Optional KMS encryption key associated with this bucket.
isWebsite?
Type:
boolean
(optional)
If this bucket has been configured for static website hosting.
policy?
Type:
Bucket
(optional)
The resource policy associated with this bucket.
If autoCreatePolicy
is true, a BucketPolicy
will be created upon the
first call to addToResourcePolicy(s).
Methods
Name | Description |
---|---|
add | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
add | Adds a bucket notification event destination. |
add | Add an inventory configuration. |
add | Add a lifecycle rule to the bucket. |
add | Adds a metrics configuration for the CloudWatch request metrics from the bucket. |
add | Subscribes a destination to receive notifications when an object is created in the bucket. |
add | Subscribes a destination to receive notifications when an object is removed from the bucket. |
add | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use bucketArn and arnForObjects(keys) to obtain ARNs for this bucket or objects. |
apply | Apply the given removal policy to this resource. |
arn | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
grant | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
grant | Allows unrestricted access to objects from this bucket. |
grant | Grants s3:PutObject* and s3:Abort* permissions for this bucket to an IAM principal. |
grant | Grant the given IAM identity permissions to modify the ACLs of objects in the given Bucket. |
grant | Grant read permissions for this bucket and it's contents to an IAM principal (Role/Group/User). |
grant | Grants read/write permissions for this bucket and it's contents to an IAM principal (Role/Group/User). |
grant | Grant write permissions to this bucket to an IAM principal. |
on | Define a CloudWatch event that triggers when something happens to this repository. |
on | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
on | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
s3 | The S3 URL of an S3 object. For example:. |
to | Returns a string representation of this construct. |
transfer | The https Transfer Acceleration URL of an S3 object. |
url | The https URL of an S3 object. Specify regional: false at the options for non-regional URLs. For example:. |
virtual | The virtual hosted-style URL of an S3 object. Specify regional: false at the options for non-regional URL. For example:. |
static from | |
static from | Creates a Bucket construct that represents an external bucket. |
static from | |
static validate | Thrown an exception if the given bucket name is not valid. |
CorsRule(rule)
addpublic addCorsRule(rule: CorsRule): void
Parameters
- rule
Cors
— The CORS configuration rule to add.Rule
Adds a cross-origin access configuration for objects in an Amazon S3 bucket.
EventNotification(event, dest, ...filters)
addpublic addEventNotification(event: EventType, dest: IBucketNotificationDestination, ...filters: NotificationKeyFilter[]): void
Parameters
- event
Event
— The event to trigger the notification.Type - dest
IBucket
— The notification destination (Lambda, SNS Topic or SQS Queue).Notification Destination - filters
Notification
— S3 object key filter rules to determine which objects trigger this event.Key Filter
Adds a bucket notification event destination.
See also: https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html Example
declare const myLambda: lambda.Function;
const bucket = new s3.Bucket(this, 'MyBucket');
bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
Inventory(inventory)
addpublic addInventory(inventory: Inventory): void
Parameters
- inventory
Inventory
— configuration to add.
Add an inventory configuration.
LifecycleRule(rule)
addpublic addLifecycleRule(rule: LifecycleRule): void
Parameters
- rule
Lifecycle
— The rule to add.Rule
Add a lifecycle rule to the bucket.
Metric(metric)
addpublic addMetric(metric: BucketMetrics): void
Parameters
- metric
Bucket
— The metric configuration to add.Metrics
Adds a metrics configuration for the CloudWatch request metrics from the bucket.
ObjectCreatedNotification(dest, ...filters)
addpublic addObjectCreatedNotification(dest: IBucketNotificationDestination, ...filters: NotificationKeyFilter[]): void
Parameters
- dest
IBucket
— The notification destination (see onEvent).Notification Destination - filters
Notification
— Filters (see onEvent).Key Filter
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
onEvent(EventType.OBJECT_CREATED)
.
ObjectRemovedNotification(dest, ...filters)
addpublic addObjectRemovedNotification(dest: IBucketNotificationDestination, ...filters: NotificationKeyFilter[]): void
Parameters
- dest
IBucket
— The notification destination (see onEvent).Notification Destination - filters
Notification
— Filters (see onEvent).Key Filter
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
onEvent(EventType.OBJECT_REMOVED)
.
ToResourcePolicy(permission)
addpublic addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
Parameters
- permission
Policy
— the policy statement to be added to the bucket's policy.Statement
Returns
Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use bucketArn
and arnForObjects(keys)
to obtain ARNs for this bucket or objects.
Note that the policy statement may or may not be added to the policy.
For example, when an IBucket
is created from an existing bucket,
it's not possible to tell whether the bucket already has a policy
attached, let alone to re-use that policy to add more statements to it.
So it's safest to do nothing in these cases.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
ForObjects(keyPattern)
arnpublic arnForObjects(keyPattern: string): string
Parameters
- keyPattern
string
Returns
string
Returns an ARN that represents all objects within the bucket that match the key pattern specified.
To represent all keys, specify "*"
.
If you need to specify a keyPattern with multiple components, concatenate them into a single string, e.g.:
arnForObjects(home/${team}/${user}/*
)
Delete(identity, objectsKeyPattern?)
grantpublic grantDelete(identity: IGrantable, objectsKeyPattern?: any): Grant
Parameters
- identity
IGrantable
— The principal. - objectsKeyPattern
any
— Restrict the permission to a certain key pattern (default '*').
Returns
Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket.
PublicAccess(keyPrefix?, ...allowedActions)
grantpublic grantPublicAccess(keyPrefix?: string, ...allowedActions: string[]): Grant
Parameters
- keyPrefix
string
— the prefix of S3 object keys (e.g.home/*
). Default is "*". - allowedActions
string
— the set of S3 actions to allow.
Returns
Allows unrestricted access to objects from this bucket.
IMPORTANT: This permission allows anyone to perform actions on S3 objects in this bucket, which is useful for when you configure your bucket as a website and want everyone to be able to read objects in the bucket without needing to authenticate.
Without arguments, this method will grant read ("s3:GetObject") access to all objects ("*") in the bucket.
The method returns the iam.Grant
object, which can then be modified
as needed. For example, you can add a condition that will restrict access only
to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(‘IpAddress’, { “aws:SourceIp”: “54.240.143.0/24” });
Note that if this IBucket
refers to an existing bucket, possibly not
managed by CloudFormation, this method will have no effect, since it's
impossible to modify the policy of an existing bucket.
Put(identity, objectsKeyPattern?)
grantpublic grantPut(identity: IGrantable, objectsKeyPattern?: any): Grant
Parameters
- identity
IGrantable
— The principal. - objectsKeyPattern
any
— Restrict the permission to a certain key pattern (default '*').
Returns
Grants s3:PutObject* and s3:Abort* permissions for this bucket to an IAM principal.
If encryption is used, permission to use the key to encrypt the contents of written files will also be granted to the same principal.
PutAcl(identity, objectsKeyPattern?)
grantpublic grantPutAcl(identity: IGrantable, objectsKeyPattern?: string): Grant
Parameters
- identity
IGrantable
- objectsKeyPattern
string
Returns
Grant the given IAM identity permissions to modify the ACLs of objects in the given Bucket.
If your application has the '@aws-cdk/aws-s3:grantWriteWithoutAcl' feature flag set, calling {@link grantWrite} or {@link grantReadWrite} no longer grants permissions to modify the ACLs of the objects; in this case, if you need to modify object ACLs, call this method explicitly.
Read(identity, objectsKeyPattern?)
grantpublic grantRead(identity: IGrantable, objectsKeyPattern?: any): Grant
Parameters
- identity
IGrantable
— The principal. - objectsKeyPattern
any
— Restrict the permission to a certain key pattern (default '*').
Returns
Grant read permissions for this bucket and it's contents to an IAM principal (Role/Group/User).
If encryption is used, permission to use the key to decrypt the contents of the bucket will also be granted to the same principal.
ReadWrite(identity, objectsKeyPattern?)
grantpublic grantReadWrite(identity: IGrantable, objectsKeyPattern?: any): Grant
Parameters
- identity
IGrantable
- objectsKeyPattern
any
Returns
Grants read/write permissions for this bucket and it's contents to an IAM principal (Role/Group/User).
If an encryption key is used, permission to use the key for encrypt/decrypt will also be granted.
Before CDK version 1.85.0, this method granted the s3:PutObject*
permission that included s3:PutObjectAcl
,
which could be used to grant read/write object access to IAM principals in other accounts.
If you want to get rid of that behavior, update your CDK version to 1.85.0 or later,
and make sure the @aws-cdk/aws-s3:grantWriteWithoutAcl
feature flag is set to true
in the context
key of your cdk.json file.
If you've already updated, but still need the principal to have permissions to modify the ACLs,
use the {@link grantPutAcl} method.
Write(identity, objectsKeyPattern?)
grantpublic grantWrite(identity: IGrantable, objectsKeyPattern?: any): Grant
Parameters
- identity
IGrantable
- objectsKeyPattern
any
Returns
Grant write permissions to this bucket to an IAM principal.
If encryption is used, permission to use the key to encrypt the contents of written files will also be granted to the same principal.
Before CDK version 1.85.0, this method granted the s3:PutObject*
permission that included s3:PutObjectAcl
,
which could be used to grant read/write object access to IAM principals in other accounts.
If you want to get rid of that behavior, update your CDK version to 1.85.0 or later,
and make sure the @aws-cdk/aws-s3:grantWriteWithoutAcl
feature flag is set to true
in the context
key of your cdk.json file.
If you've already updated, but still need the principal to have permissions to modify the ACLs,
use the {@link grantPutAcl} method.
CloudTrailEvent(id, options?)
onpublic onCloudTrailEvent(id: string, options?: OnCloudTrailBucketEventOptions): Rule
Parameters
- id
string
— The id of the rule. - options
On
— Options for adding the rule.Cloud Trail Bucket Event Options
Returns
Define a CloudWatch event that triggers when something happens to this repository.
Requires that there exists at least one CloudTrail Trail in your account that captures the event. This method will not create the Trail.
CloudTrailPutObject(id, options?)
onpublic onCloudTrailPutObject(id: string, options?: OnCloudTrailBucketEventOptions): Rule
Parameters
- id
string
— The id of the rule. - options
On
— Options for adding the rule.Cloud Trail Bucket Event Options
Returns
Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call.
Note that some tools like aws s3 cp
will automatically use either
PutObject or the multipart upload API depending on the file size,
so using onCloudTrailWriteObject
may be preferable.
Requires that there exists at least one CloudTrail Trail in your account that captures the event. This method will not create the Trail.
CloudTrailWriteObject(id, options?)
onpublic onCloudTrailWriteObject(id: string, options?: OnCloudTrailBucketEventOptions): Rule
Parameters
- id
string
— The id of the rule. - options
On
— Options for adding the rule.Cloud Trail Bucket Event Options
Returns
Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to.
This includes the events PutObject, CopyObject, and CompleteMultipartUpload.
Note that some tools like aws s3 cp
will automatically use either
PutObject or the multipart upload API depending on the file size,
so using this method may be preferable to onCloudTrailPutObject
.
Requires that there exists at least one CloudTrail Trail in your account that captures the event. This method will not create the Trail.
UrlForObject(key?)
s3public s3UrlForObject(key?: string): string
Parameters
- key
string
— The S3 key of the object.
Returns
string
The S3 URL of an S3 object. For example:.
s3://onlybucket
s3://bucket/key
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
AccelerationUrlForObject(key?, options?)
transferpublic transferAccelerationUrlForObject(key?: string, options?: TransferAccelerationUrlOptions): string
Parameters
- key
string
— The S3 key of the object. - options
Transfer
— Options for generating URL.Acceleration Url Options
Returns
string
The https Transfer Acceleration URL of an S3 object.
Specify dualStack: true
at the options
for dual-stack endpoint (connect to the bucket over IPv6). For example:
https://bucket.s3-accelerate.amazonaws.com
https://bucket.s3-accelerate.amazonaws.com/key
ForObject(key?)
urlpublic urlForObject(key?: string): string
Parameters
- key
string
— The S3 key of the object.
Returns
string
The https URL of an S3 object. Specify regional: false
at the options for non-regional URLs. For example:.
https://s3.us-west-1.amazonaws.com/onlybucket
https://s3.us-west-1.amazonaws.com/bucket/key
https://s3---cn-north-1.amazonaws.com.rproxy.goskope.com.cn/china-bucket/mykey
HostedUrlForObject(key?, options?)
virtualpublic virtualHostedUrlForObject(key?: string, options?: VirtualHostedStyleUrlOptions): string
Parameters
- key
string
— The S3 key of the object. - options
Virtual
— Options for generating URL.Hosted Style Url Options
Returns
string
The virtual hosted-style URL of an S3 object. Specify regional: false
at the options for non-regional URL. For example:.
https://only-bucket.s3.us-west-1.amazonaws.com
https://bucket.s3.us-west-1.amazonaws.com/key
https://bucket.s3.amazonaws.com/key
https://china-bucket---s3---cn-north-1.amazonaws.com.rproxy.goskope.com.cn/mykey
BucketArn(scope, id, bucketArn)
static frompublic static fromBucketArn(scope: Construct, id: string, bucketArn: string): IBucket
Parameters
- scope
Construct
- id
string
- bucketArn
string
Returns
BucketAttributes(scope, id, attrs)
static frompublic static fromBucketAttributes(scope: Construct, id: string, attrs: BucketAttributes): IBucket
Parameters
- scope
Construct
— The parent creating construct (usuallythis
). - id
string
— The construct's name. - attrs
Bucket
— AAttributes BucketAttributes
object.
Returns
Creates a Bucket construct that represents an external bucket.
BucketName(scope, id, bucketName)
static frompublic static fromBucketName(scope: Construct, id: string, bucketName: string): IBucket
Parameters
- scope
Construct
- id
string
- bucketName
string
Returns
BucketName(physicalName)
static validatepublic static validateBucketName(physicalName: string): void
Parameters
- physicalName
string
— name of the bucket.
Thrown an exception if the given bucket name is not valid.