@aws-blocks/bb-file-bucket 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cdk.d.ts +2 -2
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +4 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -3
- package/src/index.cdk.ts +4 -3
- package/src/version.ts +1 -1
package/dist/index.cdk.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildingBlockScope } from '@aws-blocks/core/cdk';
|
|
2
2
|
import type { ScopeParent } from '@aws-blocks/core';
|
|
3
3
|
import type { FileBucketOptions, ExternalBucketRef } from './types.js';
|
|
4
4
|
export { FileBucketErrors } from './errors.js';
|
|
5
5
|
export type { FileBucketOptions, PutOptions, GetUrlOptions, PutUrlOptions, ScanOptions, FileContent, FileInfo, CorsRule, LifecycleRule, ExternalBucketRef } from './types.js';
|
|
6
|
-
export declare class FileBucket<O extends FileBucketOptions = FileBucketOptions> extends
|
|
6
|
+
export declare class FileBucket<O extends FileBucketOptions = FileBucketOptions> extends BuildingBlockScope {
|
|
7
7
|
private bucket;
|
|
8
8
|
/**
|
|
9
9
|
* Reference an existing S3 bucket instead of provisioning a new one.
|
package/dist/index.cdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cdk.d.ts","sourceRoot":"","sources":["../src/index.cdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cdk.d.ts","sourceRoot":"","sources":["../src/index.cdk.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAA2B,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAgB9K,qBAAa,UAAU,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,CAAE,SAAQ,kBAAkB;IAClG,OAAO,CAAC,MAAM,CAAa;IAE3B;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB;gBAI9C,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CAwJvD"}
|
package/dist/index.cdk.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
4
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
4
5
|
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
|
|
5
6
|
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
6
|
-
import {
|
|
7
|
+
import { BuildingBlockScope } from '@aws-blocks/core/cdk';
|
|
7
8
|
import { validateBucketName } from './bucket-name.js';
|
|
8
9
|
export { FileBucketErrors } from './errors.js';
|
|
9
10
|
const httpMethodMap = {
|
|
@@ -17,7 +18,7 @@ const httpMethodMap = {
|
|
|
17
18
|
const DEFAULT_NONCURRENT_VERSION_EXPIRATION_DAYS = 90;
|
|
18
19
|
/** HTTP methods that mutate bucket state; unsafe to expose to wildcard origins. */
|
|
19
20
|
const MUTATING_CORS_METHODS = ['PUT', 'POST', 'DELETE'];
|
|
20
|
-
export class FileBucket extends
|
|
21
|
+
export class FileBucket extends BuildingBlockScope {
|
|
21
22
|
bucket;
|
|
22
23
|
/**
|
|
23
24
|
* Reference an existing S3 bucket instead of provisioning a new one.
|
|
@@ -28,7 +29,7 @@ export class FileBucket extends Scope {
|
|
|
28
29
|
return { __brand: 'ExternalBucketRef', bucketName };
|
|
29
30
|
}
|
|
30
31
|
constructor(scope, id, options) {
|
|
31
|
-
super(id, { parent: scope });
|
|
32
|
+
super(id, { parent: scope, vpc: { gatewayEndpoints: [ec2.GatewayVpcEndpointAwsService.S3] } });
|
|
32
33
|
if (options?.bucket) {
|
|
33
34
|
// `fromExisting`: don't provision; bind to the pre-existing bucket and
|
|
34
35
|
// grant read/write to the Blocks runtime Lambda.
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-blocks/bb-file-bucket",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"aws-blocks",
|
|
6
|
+
"storage",
|
|
7
|
+
"s3",
|
|
8
|
+
"file-upload"
|
|
9
|
+
],
|
|
4
10
|
"repository": {
|
|
5
11
|
"type": "git",
|
|
6
12
|
"url": "git+https://github.com/aws-devtools-labs/aws-blocks.git",
|
|
@@ -50,8 +56,8 @@
|
|
|
50
56
|
"test": "node --test dist/index.test.js dist/index.cdk.test.js dist/scan.test.js dist/file-server.test.js dist/url-encoding.test.js dist/path-containment.test.js dist/bucket-name.test.js"
|
|
51
57
|
},
|
|
52
58
|
"dependencies": {
|
|
53
|
-
"@aws-blocks/bb-logger": "^0.
|
|
54
|
-
"@aws-blocks/core": "^0.
|
|
59
|
+
"@aws-blocks/bb-logger": "^0.2.0",
|
|
60
|
+
"@aws-blocks/core": "^0.5.0",
|
|
55
61
|
"@aws-sdk/client-s3": "^3.0.0",
|
|
56
62
|
"@aws-sdk/s3-request-presigner": "^3.0.0"
|
|
57
63
|
},
|
package/src/index.cdk.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
5
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
5
6
|
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
|
|
6
7
|
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
7
|
-
import {
|
|
8
|
+
import { BuildingBlockScope } from '@aws-blocks/core/cdk';
|
|
8
9
|
import type { ScopeParent } from '@aws-blocks/core';
|
|
9
10
|
import type { FileBucketOptions, CorsRule, LifecycleRule, ExternalBucketRef } from './types.js';
|
|
10
11
|
import { validateBucketName } from './bucket-name.js';
|
|
@@ -26,7 +27,7 @@ const DEFAULT_NONCURRENT_VERSION_EXPIRATION_DAYS = 90;
|
|
|
26
27
|
/** HTTP methods that mutate bucket state; unsafe to expose to wildcard origins. */
|
|
27
28
|
const MUTATING_CORS_METHODS: ReadonlyArray<CorsRule['allowedMethods'][number]> = ['PUT', 'POST', 'DELETE'];
|
|
28
29
|
|
|
29
|
-
export class FileBucket<O extends FileBucketOptions = FileBucketOptions> extends
|
|
30
|
+
export class FileBucket<O extends FileBucketOptions = FileBucketOptions> extends BuildingBlockScope {
|
|
30
31
|
private bucket: s3.IBucket;
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -39,7 +40,7 @@ export class FileBucket<O extends FileBucketOptions = FileBucketOptions> extends
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
constructor(scope: ScopeParent, id: string, options?: O) {
|
|
42
|
-
super(id, { parent: scope });
|
|
43
|
+
super(id, { parent: scope, vpc: { gatewayEndpoints: [ec2.GatewayVpcEndpointAwsService.S3] } });
|
|
43
44
|
|
|
44
45
|
if (options?.bucket) {
|
|
45
46
|
// `fromExisting`: don't provision; bind to the pre-existing bucket and
|
package/src/version.ts
CHANGED