@composurecdk/s3 0.1.2 → 0.1.3

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.
@@ -1,30 +1,29 @@
1
- import { BucketDeployment, type BucketDeploymentProps, type ISource } from "aws-cdk-lib/aws-s3-deployment";
1
+ import { BucketDeployment } from "aws-cdk-lib/aws-s3-deployment";
2
2
  import { type IBucket } from "aws-cdk-lib/aws-s3";
3
3
  import { type IDistribution } from "aws-cdk-lib/aws-cloudfront";
4
+ import type { LogGroup } from "aws-cdk-lib/aws-logs";
4
5
  import { type IConstruct } from "constructs";
5
6
  import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
6
- /**
7
- * Configuration properties for the S3 bucket deployment builder.
8
- *
9
- * Extends the CDK {@link BucketDeploymentProps} but replaces
10
- * `destinationBucket` and `distribution` with builder-managed fields that
11
- * support {@link Resolvable} for cross-component wiring via {@link ref}.
12
- *
13
- * `sources` is set via the builder's fluent API rather than the constructor.
14
- */
15
- export interface BucketDeploymentBuilderProps extends Omit<BucketDeploymentProps, "sources" | "destinationBucket" | "distribution"> {
16
- /**
17
- * The sources from which to deploy content. Typically created with
18
- * `Source.asset("./path")` or `Source.data("key", "content")`.
19
- */
20
- sources?: ISource[];
21
- }
7
+ import { type BucketDeploymentBuilderProps } from "./bucket-deployment-props.js";
22
8
  /**
23
9
  * The build output of a {@link IBucketDeploymentBuilder}.
24
10
  */
25
11
  export interface BucketDeploymentBuilderResult {
26
12
  /** The CDK BucketDeployment construct created by the builder. */
27
13
  deployment: BucketDeployment;
14
+ /**
15
+ * The CloudWatch LogGroup created for the deployment's backing Lambda,
16
+ * or `undefined` if the user provided their own via the `logGroup`
17
+ * property.
18
+ *
19
+ * By default the builder creates a managed LogGroup using
20
+ * {@link createLogGroupBuilder} with well-architected defaults (retention
21
+ * policy, removal policy). This prevents the backing Lambda from
22
+ * creating an auto-managed log group with infinite retention.
23
+ *
24
+ * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_deployment.BucketDeploymentProps.html#loggroup
25
+ */
26
+ logGroup?: LogGroup;
28
27
  }
29
28
  /**
30
29
  * A fluent builder for configuring and creating an S3 BucketDeployment.
@@ -1 +1 @@
1
- {"version":3,"file":"bucket-deployment-builder.d.ts","sourceRoot":"","sources":["../src/bucket-deployment-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;GAQG;AACH,MAAM,WAAW,4BACf,SAAQ,IAAI,CAAC,qBAAqB,EAAE,SAAS,GAAG,mBAAmB,GAAG,cAAc,CAAC;IACrF;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,iEAAiE;IACjE,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,4BAA4B,EAC5B,uBAAuB,CACxB,CAAC;AAEF,cAAM,uBAAwB,YAAW,SAAS,CAAC,6BAA6B,CAAC;IAC/E,KAAK,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAM;IAClD,OAAO,CAAC,kBAAkB,CAAC,CAAsB;IACjD,OAAO,CAAC,aAAa,CAAC,CAA4B;IAElD;;;;;;;;OAQG;IACH,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,O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CAAC,CAAM;IAClD,OAAO,CAAC,kBAAkB,CAAC,CAAsB;IACjD,OAAO,CAAC,aAAa,CAAC,CAA4B;IAElD;;;;;;;;OAQG;IACH,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAKpD;;;;;;;;;OASG;IACH,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,aAAa,CAAC,GAAG,IAAI;IAK3D,KAAK,CACH,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,6BAA6B;CAiDjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,6BAA6B,IAAI,wBAAwB,CAExE"}
@@ -1,6 +1,7 @@
1
- import { BucketDeployment, } from "aws-cdk-lib/aws-s3-deployment";
1
+ import { BucketDeployment } from "aws-cdk-lib/aws-s3-deployment";
2
2
  import { Builder, resolve, } from "@composurecdk/core";
3
- import { BUCKET_DEPLOYMENT_DEFAULTS } from "./bucket-deployment-defaults.js";
3
+ import { createLogGroupBuilder } from "@composurecdk/logs";
4
+ import { effectiveDefaults } from "./bucket-deployment-defaults.js";
4
5
  class BucketDeploymentBuilder {
5
6
  props = {};
6
7
  _destinationBucket;
@@ -46,17 +47,18 @@ class BucketDeploymentBuilder {
46
47
  throw new Error(`BucketDeploymentBuilder "${id}" requires at least one source. ` +
47
48
  `Call .sources() with an array of ISource.`);
48
49
  }
49
- const resolvedDistribution = this._distribution
50
- ? resolve(this._distribution, ctx)
51
- : undefined;
52
- // Only apply distributionPaths default when a distribution is present;
53
- // CDK throws if distributionPaths is set without a distribution.
54
- const { distributionPaths: _distPaths, ...defaultsWithoutPaths } = BUCKET_DEPLOYMENT_DEFAULTS;
55
- const effectiveDefaults = resolvedDistribution
56
- ? BUCKET_DEPLOYMENT_DEFAULTS
57
- : defaultsWithoutPaths;
50
+ const resolvedDistribution = this._distribution ? resolve(this._distribution, ctx) : undefined;
51
+ // Auto-create a managed LogGroup for the deployment's backing Lambda
52
+ // unless the user supplied their own, matching the Lambda builder pattern.
53
+ let logGroup;
54
+ let logGroupProps = {};
55
+ if (!deployProps.logGroup) {
56
+ logGroup = createLogGroupBuilder().build(scope, `${id}LogGroup`).logGroup;
57
+ logGroupProps = { logGroup };
58
+ }
58
59
  const mergedProps = {
59
- ...effectiveDefaults,
60
+ ...effectiveDefaults(!!resolvedDistribution),
61
+ ...logGroupProps,
60
62
  ...deployProps,
61
63
  ...(resolvedDistribution ? { distribution: resolvedDistribution } : {}),
62
64
  sources,
@@ -64,6 +66,7 @@ class BucketDeploymentBuilder {
64
66
  };
65
67
  return {
66
68
  deployment: new BucketDeployment(scope, id, mergedProps),
69
+ logGroup,
67
70
  };
68
71
  }
69
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bucket-deployment-builder.js","sourceRoot":"","sources":["../src/bucket-deployment-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAGjB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EACL,OAAO,EAGP,OAAO,GAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAuD7E,MAAM,uBAAuB;IAC3B,KAAK,GAA0C,EAAE,CAAC;IAC1C,kBAAkB,CAAuB;IACzC,aAAa,CAA6B;IAElD;;;;;;;;OAQG;IACH,iBAAiB,CAAC,MAA2B;QAC3C,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;OASG;IACH,YAAY,CAAC,YAAuC;QAClD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CACH,KAAiB,EACjB,EAAU,EACV,OAAgC;QAEhC,MAAM,GAAG,GAAG,OAAO,IAAI,EAAE,CAAC;QAE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AI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CACb,4BAA4B,EAAE,kCAAkC;gBAC9D,2CAA2C,CAC9C,CAAC;QACJ,CAAC;QAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/F,qEAAqE;QACrE,2EAA2E;QAC3E,IAAI,QAA8B,CAAC;QACnC,IAAI,aAAa,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC1B,QAAQ,GAAG,qBAAqB,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC;YAC1E,aAAa,GAAG,EAAE,QAAQ,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,WAAW,GAAG;YAClB,GAAG,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,CAAC;YAC5C,GAAG,aAAa;YAChB,GAAG,WAAW;YACd,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,OAAO;YACP,iBAAiB,EAAE,cAAc;SACT,CAAC;QAE3B,OAAO;YACL,UAAU,EAAE,IAAI,gBAAgB,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC;YACxD,QAAQ;SACT,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,OAAO,CAAwD,uBAAuB,CAAC,CAAC;AACjG,CAAC"}
@@ -1,8 +1,51 @@
1
- import type { BucketDeploymentBuilderProps } from "./bucket-deployment-builder.js";
1
+ import type { BucketDeploymentBuilderProps } from "./bucket-deployment-props.js";
2
2
  /**
3
- * Sensible defaults applied to every S3 BucketDeployment built with
4
- * {@link createBucketDeploymentBuilder}. Each property can be individually
5
- * overridden via the builder's fluent API.
3
+ * Secure, AWS-recommended defaults applied to every S3 BucketDeployment
4
+ * built with {@link createBucketDeploymentBuilder}. Each property can be
5
+ * individually overridden via the builder's fluent API.
6
6
  */
7
- export declare const BUCKET_DEPLOYMENT_DEFAULTS: Partial<BucketDeploymentBuilderProps>;
7
+ export declare const BUCKET_DEPLOYMENT_DEFAULTS: {
8
+ sources?: import("aws-cdk-lib/aws-s3-deployment").ISource[];
9
+ accessControl?: import("aws-cdk-lib/aws-s3").BucketAccessControl;
10
+ destinationKeyPrefix?: string;
11
+ extract?: boolean;
12
+ exclude?: string[];
13
+ include?: string[];
14
+ prune?: boolean;
15
+ retainOnDelete?: boolean;
16
+ distributionPaths?: string[];
17
+ waitForDistributionInvalidation?: boolean;
18
+ logRetention?: import("aws-cdk-lib/aws-logs").RetentionDays;
19
+ logGroup?: import("aws-cdk-lib/aws-logs").ILogGroupRef;
20
+ memoryLimit?: number;
21
+ ephemeralStorageSize?: import("aws-cdk-lib").Size;
22
+ useEfs?: boolean;
23
+ role?: import("aws-cdk-lib/aws-iam").IRole;
24
+ metadata?: {
25
+ [key: string]: string;
26
+ };
27
+ cacheControl?: import("aws-cdk-lib/aws-s3-deployment").CacheControl[];
28
+ contentDisposition?: string;
29
+ contentEncoding?: string;
30
+ contentLanguage?: string;
31
+ contentType?: string;
32
+ expires?: import("aws-cdk-lib").Expiration;
33
+ serverSideEncryption?: import("aws-cdk-lib/aws-s3-deployment").ServerSideEncryption;
34
+ storageClass?: import("aws-cdk-lib/aws-s3-deployment").StorageClass;
35
+ websiteRedirectLocation?: string;
36
+ serverSideEncryptionAwsKmsKeyId?: string;
37
+ serverSideEncryptionCustomerAlgorithm?: string;
38
+ vpc?: import("aws-cdk-lib/aws-ec2").IVpc;
39
+ vpcSubnets?: import("aws-cdk-lib/aws-ec2").SubnetSelection;
40
+ signContent?: boolean;
41
+ outputObjectKeys?: boolean;
42
+ securityGroups?: import("aws-cdk-lib/aws-ec2").ISecurityGroup[];
43
+ };
44
+ /**
45
+ * Returns the appropriate defaults based on whether a CloudFront
46
+ * distribution is present. CDK throws if `distributionPaths` is set
47
+ * without a distribution, so distribution-specific defaults are only
48
+ * included when applicable.
49
+ */
50
+ export declare function effectiveDefaults(hasDistribution: boolean): Partial<BucketDeploymentBuilderProps>;
8
51
  //# sourceMappingURL=bucket-deployment-defaults.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bucket-deployment-defaults.d.ts","sourceRoot":"","sources":["../src/bucket-deployment-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAEnF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,OAAO,CAAC,4BAA4B,CAc5E,CAAC"}
1
+ {"version":3,"file":"bucket-deployment-defaults.d.ts","sourceRoot":"","sources":["../src/bucket-deployment-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAmDjF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAEjG"}
@@ -1,20 +1,64 @@
1
1
  /**
2
- * Sensible defaults applied to every S3 BucketDeployment built with
3
- * {@link createBucketDeploymentBuilder}. Each property can be individually
4
- * overridden via the builder's fluent API.
2
+ * Defaults that apply regardless of whether a CloudFront distribution is
3
+ * present. Split from distribution-specific defaults so the builder can
4
+ * merge without runtime filtering.
5
5
  */
6
- export const BUCKET_DEPLOYMENT_DEFAULTS = {
7
- /**
8
- * Invalidate all paths by default so that deployed content is immediately
9
- * visible through CloudFront.
10
- * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html
11
- */
12
- distributionPaths: ["/*"],
6
+ const BASE_DEFAULTS = {
13
7
  /**
14
8
  * Remove files from the destination bucket that are not present in the
15
- * source, keeping the bucket in sync with the deployed assets.
16
- * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_deployment.BucketDeploymentProps.html#prune
9
+ * source, keeping the bucket in sync with the deployed assets and
10
+ * preventing stale content from being served.
11
+ * @see https://docs.aws.amazon.com/wellarchitected/latest/operational-excellence-pillar/ops_evolve_ops_learned_from_experience.html
17
12
  */
18
13
  prune: true,
14
+ /**
15
+ * Allocate 256 MiB to the deployment Lambda. The CDK default of 128 MiB
16
+ * is insufficient for deployments with more than a handful of files and
17
+ * can cause silent failures or timeouts.
18
+ * @see https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/rel_withstand_component_failures_avoid_hard_coded_limits.html
19
+ * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_deployment-readme.html#memory-limit
20
+ */
21
+ memoryLimit: 256,
22
+ /**
23
+ * Do not retain deployed files when the stack is deleted. This aligns
24
+ * with `prune: true` semantics — the deployment keeps the bucket in
25
+ * sync with the source, so retaining stale files on deletion is
26
+ * inconsistent. The destination bucket's own removal policy governs
27
+ * whether the bucket itself is retained.
28
+ * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_deployment.BucketDeploymentProps.html#retainondelete
29
+ */
30
+ retainOnDelete: false,
31
+ };
32
+ /**
33
+ * Defaults that only apply when a CloudFront distribution is configured.
34
+ * CDK throws if `distributionPaths` is set without a distribution.
35
+ */
36
+ const DISTRIBUTION_DEFAULTS = {
37
+ /**
38
+ * Invalidate all paths by default so that deployed content is immediately
39
+ * visible through CloudFront. Uses a wildcard path which counts as a
40
+ * single invalidation path. For deployments that only change a subset of
41
+ * files, override with specific paths to reduce origin fetches.
42
+ * @see https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/rel_withstand_component_failures_static_stability.html
43
+ */
44
+ distributionPaths: ["/*"],
19
45
  };
46
+ /**
47
+ * Secure, AWS-recommended defaults applied to every S3 BucketDeployment
48
+ * built with {@link createBucketDeploymentBuilder}. Each property can be
49
+ * individually overridden via the builder's fluent API.
50
+ */
51
+ export const BUCKET_DEPLOYMENT_DEFAULTS = {
52
+ ...BASE_DEFAULTS,
53
+ ...DISTRIBUTION_DEFAULTS,
54
+ };
55
+ /**
56
+ * Returns the appropriate defaults based on whether a CloudFront
57
+ * distribution is present. CDK throws if `distributionPaths` is set
58
+ * without a distribution, so distribution-specific defaults are only
59
+ * included when applicable.
60
+ */
61
+ export function effectiveDefaults(hasDistribution) {
62
+ return hasDistribution ? { ...BASE_DEFAULTS, ...DISTRIBUTION_DEFAULTS } : BASE_DEFAULTS;
63
+ }
20
64
  //# sourceMappingURL=bucket-deployment-defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bucket-deployment-defaults.js","sourceRoot":"","sources":["../src/bucket-deployment-defaults.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA0C;IAC/E;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,IAAI,CAAC;IAEzB;;;;OAIG;IACH,KAAK,EAAE,IAAI;CACZ,CAAC"}
1
+ {"version":3,"file":"bucket-deployment-defaults.js","sourceRoot":"","sources":["../src/bucket-deployment-defaults.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,aAAa,GAA0C;IAC3D;;;;;OAKG;IACH,KAAK,EAAE,IAAI;IAEX;;;;;;OAMG;IACH,WAAW,EAAE,GAAG;IAEhB;;;;;;;OAOG;IACH,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,qBAAqB,GAA0C;IACnE;;;;;;OAMG;IACH,iBAAiB,EAAE,CAAC,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,GAAG,aAAa;IAChB,GAAG,qBAAqB;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,eAAwB;IACxD,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,qBAAqB,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { BucketDeploymentProps, ISource } from "aws-cdk-lib/aws-s3-deployment";
2
+ /**
3
+ * Configuration properties for the S3 bucket deployment builder.
4
+ *
5
+ * Extends the CDK {@link BucketDeploymentProps} but replaces
6
+ * `destinationBucket` and `distribution` with builder-managed fields that
7
+ * support {@link Resolvable} for cross-component wiring via {@link ref}.
8
+ *
9
+ * `sources` is set via the builder's fluent API rather than the constructor.
10
+ */
11
+ export interface BucketDeploymentBuilderProps extends Omit<BucketDeploymentProps, "sources" | "destinationBucket" | "distribution"> {
12
+ /**
13
+ * The sources from which to deploy content. Typically created with
14
+ * `Source.asset("./path")` or `Source.data("key", "content")`.
15
+ */
16
+ sources?: ISource[];
17
+ }
18
+ //# sourceMappingURL=bucket-deployment-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bucket-deployment-props.d.ts","sourceRoot":"","sources":["../src/bucket-deployment-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAEpF;;;;;;;;GAQG;AACH,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CACxD,qBAAqB,EACrB,SAAS,GAAG,mBAAmB,GAAG,cAAc,CACjD;IACC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bucket-deployment-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bucket-deployment-props.js","sourceRoot":"","sources":["../src/bucket-deployment-props.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export { createBucketBuilder, type BucketBuilderResult, type IBucketBuilder, } from "./bucket-builder.js";
2
2
  export { BUCKET_DEFAULTS } from "./defaults.js";
3
+ export { createBucketDeploymentBuilder, type BucketDeploymentBuilderResult, type IBucketDeploymentBuilder, } from "./bucket-deployment-builder.js";
4
+ export { BUCKET_DEPLOYMENT_DEFAULTS } from "./bucket-deployment-defaults.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,6BAA6B,EAC7B,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,GAC9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export { createBucketBuilder, } from "./bucket-builder.js";
2
2
  export { BUCKET_DEFAULTS } from "./defaults.js";
3
+ export { createBucketDeploymentBuilder, } from "./bucket-deployment-builder.js";
4
+ export { BUCKET_DEPLOYMENT_DEFAULTS } from "./bucket-deployment-defaults.js";
3
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAGpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAGpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,6BAA6B,GAG9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composurecdk/s3",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Composable S3 bucket builder with well-architected defaults",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,6 +36,7 @@
36
36
  "type": "module",
37
37
  "peerDependencies": {
38
38
  "@composurecdk/core": "^0.1.0",
39
+ "@composurecdk/logs": "^0.1.0",
39
40
  "aws-cdk-lib": "^2.0.0",
40
41
  "constructs": "^10.0.0"
41
42
  },