Socket
Socket
Sign inDemoInstall

@aws-cdk/aws-s3

Package Overview
Dependencies
Maintainers
5
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-s3 - npm Package Compare versions

Comparing version 0.39.0 to 1.0.0

30

package.json
{
"name": "@aws-cdk/aws-s3",
"version": "0.39.0",
"version": "1.0.0",
"description": "CDK Constructs for AWS S3",

@@ -68,20 +68,20 @@ "main": "lib/index.js",

"devDependencies": {
"@aws-cdk/assert": "^0.39.0",
"cdk-build-tools": "^0.39.0",
"cdk-integ-tools": "^0.39.0",
"cfn2ts": "^0.39.0",
"pkglint": "^0.39.0"
"@aws-cdk/assert": "^1.0.0",
"cdk-build-tools": "^1.0.0",
"cdk-integ-tools": "^1.0.0",
"cfn2ts": "^1.0.0",
"pkglint": "^1.0.0"
},
"dependencies": {
"@aws-cdk/aws-events": "^0.39.0",
"@aws-cdk/aws-iam": "^0.39.0",
"@aws-cdk/aws-kms": "^0.39.0",
"@aws-cdk/core": "^0.39.0"
"@aws-cdk/aws-events": "^1.0.0",
"@aws-cdk/aws-iam": "^1.0.0",
"@aws-cdk/aws-kms": "^1.0.0",
"@aws-cdk/core": "^1.0.0"
},
"homepage": "https://github.com/awslabs/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-events": "^0.39.0",
"@aws-cdk/aws-iam": "^0.39.0",
"@aws-cdk/aws-kms": "^0.39.0",
"@aws-cdk/core": "^0.39.0"
"@aws-cdk/aws-events": "^1.0.0",
"@aws-cdk/aws-iam": "^1.0.0",
"@aws-cdk/aws-kms": "^1.0.0",
"@aws-cdk/core": "^1.0.0"
},

@@ -98,2 +98,2 @@ "engines": {

"stability": "stable"
}
}

@@ -8,4 +8,2 @@ ## Amazon S3 Construct Library

> **This is a _developer preview_ (public beta) module. Releases might lack important features and might have
> future breaking changes.**

@@ -25,8 +23,12 @@ ---

* `bucketName` - the name of the bucket (i.e. `bucket_name`)
* `bucketUrl` - the URL of the bucket (i.e.
`https://s3.us-west-1.amazonaws.com/onlybucket`)
* `arnForObjects(...pattern)` - the ARN of an object or objects within the
bucket (i.e.
`arn:aws:s3:::my_corporate_bucket/exampleobject.png` or
`arn:aws:s3:::my_corporate_bucket/Development/*`)
* `bucketWebsiteUrl` - the Website URL of the bucket (i.e.
`http://bucket_name.s3-website-us-west-1.amazonaws.com`)
* `bucketDomainName` - the URL of the bucket (i.e. `bucket_name.s3.amazonaws.com`)
* `bucketDualStackDomainName` - the dual-stack URL of the bucket (i.e.
`bucket_name.s3.dualstack.eu-west-1.amazonaws.com`)
* `bucketRegionalDomainName` - the regional URL of the bucket (i.e.
`bucket_name.s3.eu-west-1.amazonaws.com`)
* `arnForObjects(pattern)` - the ARN of an object or objects within the bucket (i.e.
`arn:aws:s3:::bucket_name/exampleobject.png` or
`arn:aws:s3:::bucket_name/Development/*`)
* `urlForObject(key)` - the URL of an object within the bucket (i.e.

@@ -41,3 +43,3 @@ `https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey`)

const bucket = new Bucket(this, 'MyUnencryptedBucket', {
encryption: BucketEncryption.Kms
encryption: BucketEncryption.KMS
});

@@ -55,3 +57,3 @@

const bucket = new Bucket(this, 'MyEncryptedBucket', {
encryption: BucketEncryption.Kms,
encryption: BucketEncryption.KMS,
encryptionKey: myKmsKey

@@ -67,3 +69,3 @@ });

const bucket = new Bucket(this, 'Buck', {
encryption: BucketEncryption.ManagedKms
encryption: BucketEncryption.KMS_MANAGED
});

@@ -81,6 +83,7 @@

const bucket = new Bucket(this, 'MyBucket');
bucket.addToResourcePolicy(new iam.PolicyStatement()
.addActions('s3:GetObject')
.addResources(bucket.arnForObjects('file.txt'))
.addAccountRootPrincipal());
bucket.addToResourcePolicy(new iam.PolicyStatement({
actions: ['s3:GetObject'],
resources: [bucket.arnForObjects('file.txt')],
principals: [new iam.AccountRootPrincipal()],
}));
```

@@ -96,3 +99,3 @@

const bucket = new Bucket(this, 'MyBucket');
bucket.grantReadWrite(lambda.role);
bucket.grantReadWrite(lambda);
```

@@ -111,7 +114,8 @@

To import an existing bucket into your CDK application, use the `Bucket.import` factory method. This method accepts a
`BucketImportProps` which describes the properties of the already existing bucket:
To import an existing bucket into your CDK application, use the `Bucket.fromBucketAttributes`
factory method. This method accepts `BucketAttributes` which describes the properties of an already
existing bucket:
```ts
const bucket = Bucket.import(this, {
const bucket = Bucket.fromBucketAttributes(this, 'ImportedBucket', {
bucketArn: 'arn:aws:s3:::my-bucket'

@@ -124,2 +128,11 @@ });

Alternatively, short-hand factories are available as `Bucket.fromBucketName` and
`Bucket.fromBucketArn`, which will derive all bucket attributes from the bucket
name or ARN respectively:
```ts
const byName = Bucket.fromBucketName(this, 'BucketByName', 'my-bucket');
const byArn = Bucket.fromBucketArn(this, 'BucketByArn', 'arn:aws:s3:::my-bucket');
```
### Bucket Notifications

@@ -131,12 +144,13 @@

To subscribe for bucket notifications, use the `bucket.onEvent` method. The
`bucket.onObjectCreated` and `bucket.onObjectRemoved` can also be used for these
common use cases.
To subscribe for bucket notifications, use the `bucket.addEventNotification` method. The
`bucket.addObjectCreatedNotification` and `bucket.addObjectRemovedNotification` can also be used for
these common use cases.
The following example will subscribe an SNS topic to be notified of all
``s3:ObjectCreated:*` events:
The following example will subscribe an SNS topic to be notified of all `s3:ObjectCreated:*` events:
```ts
import s3n = require('@aws-cdk/aws-s3-notifications');
const myTopic = new sns.Topic(this, 'MyTopic');
bucket.onEvent(s3.EventType.ObjectCreated, myTopic);
bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.SnsDestination(topic));
```

@@ -147,8 +161,4 @@

The following destinations are currently supported:
Supported S3 notification targets are exposed by the `@aws-cdk/aws-s3-notifications` package.
* `sns.Topic`
* `sqs.Queue`
* `lambda.Function`
It is also possible to specify S3 object key filters when subscribing. The

@@ -159,3 +169,5 @@ following example will notify `myQueue` when objects prefixed with `foo/` and

```ts
bucket.onEvent(s3.EventType.ObjectRemoved, myQueue, { prefix: 'foo/', suffix: '.jpg' });
bucket.addEventNotification(s3.EventType.OBJECT_REMOVED,
new s3n.SqsDestination(myQueue),
{ prefix: 'foo/', suffix: '.jpg' });
```

@@ -173,3 +185,3 @@

const bucket = new Bucket(this, 'MyBlockedBucket', {
blockPublicAccess: BlockPublicAccess.BlockAll
blockPublicAccess: BlockPublicAccess.BLOCK_ALL
});

@@ -181,3 +193,3 @@ ```

const bucket = new Bucket(this, 'MyBlockedBucket', {
blockPublicAccess: BlockPublicAccess.BlockAcls
blockPublicAccess: BlockPublicAccess.BLOCK_ACLS
});

@@ -184,0 +196,0 @@ ```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc