sst 2.40.3 → 2.40.5

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.
Files changed (69) hide show
  1. package/cli/commands/bind.js +1 -1
  2. package/cli/commands/secrets/list.js +1 -1
  3. package/constructs/Api.d.ts +4 -4
  4. package/constructs/Api.js +1 -1
  5. package/constructs/ApiGatewayV1Api.d.ts +4 -4
  6. package/constructs/ApiGatewayV1Api.js +1 -1
  7. package/constructs/App.d.ts +2 -1
  8. package/constructs/App.js +7 -11
  9. package/constructs/AppSyncApi.d.ts +4 -4
  10. package/constructs/AppSyncApi.js +1 -1
  11. package/constructs/Auth.d.ts +2 -2
  12. package/constructs/Auth.js +3 -3
  13. package/constructs/Bucket.d.ts +5 -5
  14. package/constructs/Bucket.js +1 -1
  15. package/constructs/Cognito.d.ts +4 -3
  16. package/constructs/Cognito.js +1 -1
  17. package/constructs/Construct.d.ts +2 -2
  18. package/constructs/Cron.d.ts +3 -2
  19. package/constructs/Cron.js +1 -1
  20. package/constructs/EdgeFunction.d.ts +2 -2
  21. package/constructs/EdgeFunction.js +6 -9
  22. package/constructs/EventBus.d.ts +4 -4
  23. package/constructs/EventBus.js +1 -1
  24. package/constructs/Function.d.ts +42 -6
  25. package/constructs/Function.js +19 -14
  26. package/constructs/Job.d.ts +43 -4
  27. package/constructs/Job.js +11 -14
  28. package/constructs/KinesisStream.d.ts +4 -4
  29. package/constructs/KinesisStream.js +1 -1
  30. package/constructs/NextjsSite.d.ts +2 -0
  31. package/constructs/NextjsSite.js +29 -9
  32. package/constructs/Parameter.d.ts +2 -2
  33. package/constructs/Parameter.js +1 -1
  34. package/constructs/Queue.d.ts +3 -3
  35. package/constructs/Queue.js +1 -1
  36. package/constructs/RDS.d.ts +2 -2
  37. package/constructs/RDS.js +1 -1
  38. package/constructs/RemixSite.d.ts +3 -2
  39. package/constructs/RemixSite.js +38 -12
  40. package/constructs/Script.d.ts +3 -2
  41. package/constructs/Script.js +2 -2
  42. package/constructs/Secret.d.ts +2 -2
  43. package/constructs/Secret.js +2 -2
  44. package/constructs/Service.d.ts +43 -4
  45. package/constructs/Service.js +31 -15
  46. package/constructs/SsrFunction.d.ts +3 -2
  47. package/constructs/SsrFunction.js +7 -13
  48. package/constructs/SsrSite.d.ts +3 -3
  49. package/constructs/SsrSite.js +2 -2
  50. package/constructs/Stack.d.ts +2 -2
  51. package/constructs/StaticSite.d.ts +2 -2
  52. package/constructs/StaticSite.js +2 -2
  53. package/constructs/Table.d.ts +4 -4
  54. package/constructs/Table.js +1 -1
  55. package/constructs/Topic.d.ts +4 -4
  56. package/constructs/Topic.js +1 -1
  57. package/constructs/WebSocketApi.d.ts +4 -4
  58. package/constructs/WebSocketApi.js +1 -1
  59. package/constructs/deprecated/NextjsSite.d.ts +2 -2
  60. package/constructs/deprecated/NextjsSite.js +2 -2
  61. package/constructs/future/Auth.d.ts +2 -2
  62. package/constructs/future/Auth.js +2 -2
  63. package/constructs/util/{functionBinding.d.ts → binding.d.ts} +14 -6
  64. package/constructs/util/{functionBinding.js → binding.js} +28 -14
  65. package/package.json +2 -2
  66. package/runtime/handlers/container.js +42 -0
  67. package/runtime/handlers/rust.js +3 -2
  68. package/support/remix-site-function/edge-server.js +0 -8
  69. package/support/remix-site-function/regional-server.js +0 -8
@@ -1,6 +1,6 @@
1
1
  import { Construct } from "constructs";
2
2
  import { SSTConstruct } from "./Construct.js";
3
- import { FunctionBindingProps } from "./util/functionBinding.js";
3
+ import { BindingProps } from "./util/binding.js";
4
4
  /**
5
5
  * The `Secret` construct is a higher level CDK construct that makes it easy to manage app secrets.
6
6
  *
@@ -25,6 +25,6 @@ export declare class Secret extends Construct implements SSTConstruct {
25
25
  };
26
26
  };
27
27
  /** @internal */
28
- getFunctionBinding(): FunctionBindingProps;
28
+ getBindings(): BindingProps;
29
29
  static create<T extends string[]>(scope: Construct, ...parameters: T): { [key in T[number]]: Secret; };
30
30
  }
@@ -1,6 +1,6 @@
1
1
  import { Construct } from "constructs";
2
2
  import { Stack } from "./Stack.js";
3
- import { getParameterPath, getParameterFallbackPath, } from "./util/functionBinding.js";
3
+ import { getParameterPath, getParameterFallbackPath, } from "./util/binding.js";
4
4
  /**
5
5
  * The `Secret` construct is a higher level CDK construct that makes it easy to manage app secrets.
6
6
  *
@@ -33,7 +33,7 @@ export class Secret extends Construct {
33
33
  };
34
34
  }
35
35
  /** @internal */
36
- getFunctionBinding() {
36
+ getBindings() {
37
37
  const app = this.node.root;
38
38
  const partition = Stack.of(this).partition;
39
39
  return {
@@ -1,9 +1,10 @@
1
1
  import { Construct } from "constructs";
2
+ import { DockerCacheOption } from "aws-cdk-lib/core";
2
3
  import { DistributionProps } from "aws-cdk-lib/aws-cloudfront";
3
4
  import { DistributionDomainProps } from "./Distribution.js";
4
5
  import { SSTConstruct } from "./Construct.js";
5
6
  import { Permissions } from "./util/permission.js";
6
- import { FunctionBindingProps } from "./util/functionBinding.js";
7
+ import { BindingProps, BindingResource } from "./util/binding.js";
7
8
  import { IVpc } from "aws-cdk-lib/aws-ec2";
8
9
  import { Cluster, ContainerDefinitionOptions, CpuArchitecture, FargateService, FargateTaskDefinition, FargateServiceProps } from "aws-cdk-lib/aws-ecs";
9
10
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
@@ -21,6 +22,8 @@ export interface ServiceDomainProps extends DistributionDomainProps {
21
22
  }
22
23
  export interface ServiceCdkDistributionProps extends Omit<DistributionProps, "defaultBehavior"> {
23
24
  }
25
+ export interface ServiceContainerCacheProps extends DockerCacheOption {
26
+ }
24
27
  export interface ServiceProps {
25
28
  /**
26
29
  * Path to the directory where the app is located.
@@ -167,7 +170,7 @@ export interface ServiceProps {
167
170
  * }
168
171
  * ```
169
172
  */
170
- bind?: SSTConstruct[];
173
+ bind?: BindingResource[];
171
174
  /**
172
175
  * The customDomain for this service. SST supports domains that are hosted
173
176
  * either on [Route 53](https://aws.amazon.com/route53/) or externally.
@@ -255,6 +258,42 @@ export interface ServiceProps {
255
258
  * ```
256
259
  */
257
260
  buildArgs?: Record<string, string>;
261
+ /**
262
+ * SSH agent socket or keys to pass to the docker build command.
263
+ * Docker BuildKit must be enabled to use the ssh flag
264
+ * @default No --ssh flag is passed to the build command
265
+ * @example
266
+ * ```js
267
+ * container: {
268
+ * buildSsh: "default"
269
+ * }
270
+ * ```
271
+ */
272
+ buildSsh?: string;
273
+ /**
274
+ * Cache from options to pass to the docker build command.
275
+ * [DockerCacheOption](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerCacheOption.html)[].
276
+ * @default No cache from options are passed to the build command
277
+ * @example
278
+ * ```js
279
+ * container: {
280
+ * cacheFrom: [{ type: 'registry', params: { ref: 'ghcr.io/myorg/myimage:cache' }}],
281
+ * }
282
+ * ```
283
+ */
284
+ cacheFrom?: ServiceContainerCacheProps[];
285
+ /**
286
+ * Cache to options to pass to the docker build command.
287
+ * [DockerCacheOption](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerCacheOption.html)[].
288
+ * @default No cache to options are passed to the build command
289
+ * @example
290
+ * ```js
291
+ * container: {
292
+ * cacheTo: { type: 'registry', params: { ref: 'ghcr.io/myorg/myimage:cache', mode: 'max', compression: 'zstd' }},
293
+ * }
294
+ * ```
295
+ */
296
+ cacheTo?: ServiceContainerCacheProps;
258
297
  };
259
298
  dev?: {
260
299
  /**
@@ -446,7 +485,7 @@ export declare class Service extends Construct implements SSTConstruct {
446
485
  };
447
486
  };
448
487
  /** @internal */
449
- getFunctionBinding(): FunctionBindingProps;
488
+ getBindings(): BindingProps;
450
489
  /**
451
490
  * Binds additional resources to service.
452
491
  *
@@ -455,7 +494,7 @@ export declare class Service extends Construct implements SSTConstruct {
455
494
  * service.bind([STRIPE_KEY, bucket]);
456
495
  * ```
457
496
  */
458
- bind(constructs: SSTConstruct[]): void;
497
+ bind(constructs: BindingResource[]): void;
459
498
  /**
460
499
  * Attaches the given list of permissions to allow the service
461
500
  * to access other AWS resources.
@@ -6,8 +6,8 @@ import { execAsync } from "../util/process.js";
6
6
  import { existsAsync } from "../util/fs.js";
7
7
  import { Colors } from "../cli/colors.js";
8
8
  import { Construct } from "constructs";
9
- import { Duration as CdkDuration, IgnoreMode } from "aws-cdk-lib/core";
10
- import { Role, Effect, PolicyStatement, AccountPrincipal, ServicePrincipal, CompositePrincipal, } from "aws-cdk-lib/aws-iam";
9
+ import { Duration as CdkDuration, IgnoreMode, } from "aws-cdk-lib/core";
10
+ import { Role, AccountPrincipal, ServicePrincipal, CompositePrincipal, } from "aws-cdk-lib/aws-iam";
11
11
  import { ViewerProtocolPolicy, AllowedMethods, CachedMethods, CachePolicy, CacheQueryStringBehavior, CacheHeaderBehavior, CacheCookieBehavior, OriginProtocolPolicy, OriginRequestPolicy, } from "aws-cdk-lib/aws-cloudfront";
12
12
  import { HttpOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
13
13
  import { Stack } from "./Stack.js";
@@ -16,7 +16,7 @@ import { Function } from "./Function.js";
16
16
  import { Secret } from "./Secret.js";
17
17
  import { useDeferredTasks } from "./deferred_task.js";
18
18
  import { attachPermissionsToRole } from "./util/permission.js";
19
- import { bindEnvironment, bindPermissions, getParameterPath, getReferencedSecrets, } from "./util/functionBinding.js";
19
+ import { getParameterPath, getBindingEnvironments, getBindingPermissions, getBindingReferencedSecrets, } from "./util/binding.js";
20
20
  import { useProject } from "../project.js";
21
21
  import { Vpc } from "aws-cdk-lib/aws-ec2";
22
22
  import { AwsLogDriver, Cluster, ContainerImage, CpuArchitecture, FargateService, FargateTaskDefinition, } from "aws-cdk-lib/aws-ecs";
@@ -277,7 +277,7 @@ export class Service extends Construct {
277
277
  };
278
278
  }
279
279
  /** @internal */
280
- getFunctionBinding() {
280
+ getBindings() {
281
281
  const app = this.node.root;
282
282
  return this.distribution
283
283
  ? {
@@ -557,20 +557,14 @@ export class Service extends Construct {
557
557
  bindForService(constructs) {
558
558
  // Get referenced secrets
559
559
  const referencedSecrets = [];
560
- constructs.forEach((c) => referencedSecrets.push(...getReferencedSecrets(c)));
561
- [...constructs, ...referencedSecrets].forEach((c) => {
560
+ constructs.forEach((r) => referencedSecrets.push(...getBindingReferencedSecrets(r)));
561
+ [...constructs, ...referencedSecrets].forEach((r) => {
562
562
  // Bind environment
563
- const env = bindEnvironment(c);
563
+ const env = getBindingEnvironments(r);
564
564
  Object.entries(env).forEach(([key, value]) => this.addEnvironmentForService(key, value));
565
565
  // Bind permissions
566
- const permissions = bindPermissions(c);
567
- Object.entries(permissions).forEach(([action, resources]) => this.attachPermissionsForService([
568
- new PolicyStatement({
569
- actions: [action],
570
- effect: Effect.ALLOW,
571
- resources,
572
- }),
573
- ]));
566
+ const policyStatements = getBindingPermissions(r);
567
+ this.attachPermissionsForService(policyStatements);
574
568
  });
575
569
  }
576
570
  addEnvironmentForService(name, value) {
@@ -639,6 +633,25 @@ export class Service extends Construct {
639
633
  `--platform ${platform}`,
640
634
  `-f ${path.join(servicePath, dockerfile)}`,
641
635
  ...Object.entries(build?.buildArgs || {}).map(([k, v]) => `--build-arg ${k}=${v}`),
636
+ ...(build?.buildSsh ? [`--ssh ${build.buildSsh}`] : []),
637
+ ...(build?.cacheFrom || []).map((v) => "--cache-from=" +
638
+ [
639
+ `type=${v.type}`,
640
+ ...(v.params
641
+ ? Object.entries(v.params).map(([pk, pv]) => `${pk}=${pv}`)
642
+ : []),
643
+ ].join(",")),
644
+ ...(build?.cacheTo
645
+ ? [
646
+ "--cache-to " +
647
+ [
648
+ `type=${build?.cacheTo.type}`,
649
+ ...(build?.cacheTo?.params
650
+ ? Object.entries(build?.cacheTo?.params).map(([pk, pv]) => `${pk}=${pv}`)
651
+ : []).join(","),
652
+ ],
653
+ ]
654
+ : []),
642
655
  this.props.path,
643
656
  ].join(" "), {
644
657
  env: {
@@ -657,6 +670,9 @@ export class Service extends Construct {
657
670
  platform: architecture === "arm64" ? Platform.LINUX_ARM64 : Platform.LINUX_AMD64,
658
671
  file: dockerfile,
659
672
  buildArgs: build?.buildArgs,
673
+ buildSsh: build?.buildSsh,
674
+ cacheFrom: build?.cacheFrom,
675
+ cacheTo: build?.cacheTo,
660
676
  exclude: [".sst/dist", ".sst/artifacts"],
661
677
  ignoreMode: IgnoreMode.GLOB,
662
678
  });
@@ -4,6 +4,7 @@ import { RetentionDays } from "aws-cdk-lib/aws-logs";
4
4
  import { FunctionOptions, Function as CdkFunction, FunctionUrlOptions } from "aws-cdk-lib/aws-lambda";
5
5
  import { NodeJSProps, FunctionCopyFilesProps } from "./Function.js";
6
6
  import { SSTConstruct } from "./Construct.js";
7
+ import { BindingResource } from "./util/binding.js";
7
8
  import { Permissions } from "./util/permission.js";
8
9
  import { Size } from "./util/size.js";
9
10
  import { Duration } from "./util/duration.js";
@@ -15,7 +16,7 @@ export interface SsrFunctionProps extends Omit<FunctionOptions, "memorySize" | "
15
16
  memorySize?: number | Size;
16
17
  permissions?: Permissions;
17
18
  environment?: Record<string, string>;
18
- bind?: SSTConstruct[];
19
+ bind?: BindingResource[];
19
20
  nodejs?: NodeJSProps;
20
21
  copyFiles?: FunctionCopyFilesProps[];
21
22
  logRetention?: RetentionDays;
@@ -64,5 +65,5 @@ export declare class SsrFunction extends Construct implements SSTConstruct {
64
65
  };
65
66
  };
66
67
  /** @internal */
67
- getFunctionBinding(): undefined;
68
+ getBindings(): undefined;
68
69
  }
@@ -13,7 +13,7 @@ import { useProject } from "../project.js";
13
13
  import { useRuntimeHandlers } from "../runtime/handlers.js";
14
14
  import { useFunctions, } from "./Function.js";
15
15
  import { Stack } from "./Stack.js";
16
- import { bindEnvironment, bindPermissions, getReferencedSecrets, } from "./util/functionBinding.js";
16
+ import { getBindingEnvironments, getBindingPermissions, getBindingReferencedSecrets, } from "./util/binding.js";
17
17
  import { attachPermissionsToRole } from "./util/permission.js";
18
18
  import { toCdkSize } from "./util/size.js";
19
19
  import { toCdkDuration } from "./util/duration.js";
@@ -193,20 +193,14 @@ export class SsrFunction extends Construct {
193
193
  this.function.addEnvironment("SST_SSM_PREFIX", useProject().config.ssmPrefix);
194
194
  // Get referenced secrets
195
195
  const referencedSecrets = [];
196
- constructs.forEach((c) => referencedSecrets.push(...getReferencedSecrets(c)));
197
- [...constructs, ...referencedSecrets].forEach((c) => {
196
+ constructs.forEach((r) => referencedSecrets.push(...getBindingReferencedSecrets(r)));
197
+ [...constructs, ...referencedSecrets].forEach((r) => {
198
198
  // Bind environment
199
- const env = bindEnvironment(c);
199
+ const env = getBindingEnvironments(r);
200
200
  Object.entries(env).forEach(([key, value]) => this.function.addEnvironment(key, value));
201
201
  // Bind permissions
202
- const permissions = bindPermissions(c);
203
- Object.entries(permissions).forEach(([action, resources]) => this.attachPermissions([
204
- new PolicyStatement({
205
- actions: [action],
206
- effect: Effect.ALLOW,
207
- resources,
208
- }),
209
- ]));
202
+ const policyStatements = getBindingPermissions(r);
203
+ this.attachPermissions(policyStatements);
210
204
  });
211
205
  }
212
206
  async buildAssetFromHandler() {
@@ -323,7 +317,7 @@ export class SsrFunction extends Construct {
323
317
  };
324
318
  }
325
319
  /** @internal */
326
- getFunctionBinding() {
320
+ getBindings() {
327
321
  return undefined;
328
322
  }
329
323
  }
@@ -12,7 +12,7 @@ import { BaseSiteFileOptions, BaseSiteReplaceProps, BaseSiteCdkDistributionProps
12
12
  import { Size } from "./util/size.js";
13
13
  import { Duration } from "./util/duration.js";
14
14
  import { Permissions } from "./util/permission.js";
15
- import { FunctionBindingProps } from "./util/functionBinding.js";
15
+ import { BindingResource, BindingProps } from "./util/binding.js";
16
16
  type CloudFrontFunctionConfig = {
17
17
  constructId: string;
18
18
  injections: string[];
@@ -71,7 +71,7 @@ export interface SsrSiteProps {
71
71
  * })
72
72
  * ```
73
73
  */
74
- bind?: SSTConstruct[];
74
+ bind?: BindingResource[];
75
75
  /**
76
76
  * Path to the directory where the app is located.
77
77
  * @default "."
@@ -474,7 +474,7 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
474
474
  };
475
475
  abstract getConstructMetadata(): ReturnType<SSTConstruct["getConstructMetadata"]>;
476
476
  /** @internal */
477
- getFunctionBinding(): FunctionBindingProps;
477
+ getBindings(): BindingProps;
478
478
  protected useCloudFrontFunctionHostHeaderInjection(): string;
479
479
  protected abstract plan(bucket: Bucket): ReturnType<typeof this.validatePlan>;
480
480
  protected validatePlan<CloudFrontFunctions extends Record<string, CloudFrontFunctionConfig>, EdgeFunctions extends Record<string, EdgeFunctionConfig>, Origins extends Record<string, FunctionOriginConfig | ImageOptimizationFunctionOriginConfig | S3OriginConfig | OriginGroupConfig>>(input: {
@@ -26,7 +26,7 @@ import { EdgeFunction } from "./EdgeFunction.js";
26
26
  import { getBuildCmdEnvironment, } from "./BaseSite.js";
27
27
  import { toCdkDuration } from "./util/duration.js";
28
28
  import { attachPermissionsToRole } from "./util/permission.js";
29
- import { getParameterPath, } from "./util/functionBinding.js";
29
+ import { getParameterPath, } from "./util/binding.js";
30
30
  import { useProject } from "../project.js";
31
31
  import { VisibleError } from "../error.js";
32
32
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
@@ -881,7 +881,7 @@ function handler(event) {
881
881
  };
882
882
  }
883
883
  /** @internal */
884
- getFunctionBinding() {
884
+ getBindings() {
885
885
  const app = this.node.root;
886
886
  return {
887
887
  clientPackage: "site",
@@ -2,8 +2,8 @@ import { Construct } from "constructs";
2
2
  import { StackProps as CDKStackProps, Stack as CDKStack, CfnOutputProps } from "aws-cdk-lib/core";
3
3
  import * as lambda from "aws-cdk-lib/aws-lambda";
4
4
  import { FunctionProps, Function as Fn } from "./Function.js";
5
- import { SSTConstruct } from "./Construct.js";
6
5
  import { Permissions } from "./util/permission.js";
6
+ import { BindingResource } from "./util/binding.js";
7
7
  export type StackProps = CDKStackProps;
8
8
  /**
9
9
  * The Stack construct extends cdk.Stack. It automatically prefixes the stack names with the stage and app name to ensure that they can be deployed to multiple regions in the same AWS account. It also ensure that the stack uses the same AWS profile and region as the app. They're defined using functions that return resources that can be imported by other stacks.
@@ -80,7 +80,7 @@ export declare class Stack extends CDKStack {
80
80
  * app.addDefaultFunctionBinding([STRIPE_KEY, bucket]);
81
81
  * ```
82
82
  */
83
- addDefaultFunctionBinding(bind: SSTConstruct[]): void;
83
+ addDefaultFunctionBinding(bind: BindingResource[]): void;
84
84
  /**
85
85
  * Adds additional default layers to be applied to all Lambda functions in the stack.
86
86
  *
@@ -4,7 +4,7 @@ import { IDistribution } from "aws-cdk-lib/aws-cloudfront";
4
4
  import { DistributionDomainProps } from "./Distribution.js";
5
5
  import { BaseSiteFileOptions, BaseSiteReplaceProps, BaseSiteCdkDistributionProps } from "./BaseSite.js";
6
6
  import { SSTConstruct } from "./Construct.js";
7
- import { FunctionBindingProps } from "./util/functionBinding.js";
7
+ import { BindingProps } from "./util/binding.js";
8
8
  export interface StaticSiteProps {
9
9
  /**
10
10
  * Path to the directory where the website source is located.
@@ -338,7 +338,7 @@ export declare class StaticSite extends Construct implements SSTConstruct {
338
338
  };
339
339
  };
340
340
  /** @internal */
341
- getFunctionBinding(): FunctionBindingProps;
341
+ getBindings(): BindingProps;
342
342
  private validateDeprecatedFileOptions;
343
343
  private generateViteTypes;
344
344
  private buildApp;
@@ -14,7 +14,7 @@ import { Distribution } from "./Distribution.js";
14
14
  import { getBuildCmdEnvironment, buildErrorResponsesFor404ErrorPage, buildErrorResponsesForRedirectToIndex, } from "./BaseSite.js";
15
15
  import { useDeferredTasks } from "./deferred_task.js";
16
16
  import { isCDKConstruct } from "./Construct.js";
17
- import { getParameterPath, } from "./util/functionBinding.js";
17
+ import { getParameterPath } from "./util/binding.js";
18
18
  import { gray } from "colorette";
19
19
  import { useProject } from "../project.js";
20
20
  import { createAppContext } from "./context.js";
@@ -130,7 +130,7 @@ export class StaticSite extends Construct {
130
130
  };
131
131
  }
132
132
  /** @internal */
133
- getFunctionBinding() {
133
+ getBindings() {
134
134
  const app = this.node.root;
135
135
  return {
136
136
  clientPackage: "site",
@@ -4,7 +4,7 @@ import * as lambdaEventSources from "aws-cdk-lib/aws-lambda-event-sources";
4
4
  import { SSTConstruct } from "./Construct.js";
5
5
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
6
6
  import { KinesisStream } from "./KinesisStream.js";
7
- import { FunctionBindingProps } from "./util/functionBinding.js";
7
+ import { BindingResource, BindingProps } from "./util/binding.js";
8
8
  import { Permissions } from "./util/permission.js";
9
9
  export interface TableConsumerProps {
10
10
  /**
@@ -343,7 +343,7 @@ export declare class Table extends Construct implements SSTConstruct {
343
343
  * table.bind([STRIPE_KEY, bucket]);
344
344
  * ```
345
345
  */
346
- bind(constructs: SSTConstruct[]): void;
346
+ bind(constructs: BindingResource[]): void;
347
347
  /**
348
348
  * Binds the given list of resources to a specific consumer of this table.
349
349
  *
@@ -352,7 +352,7 @@ export declare class Table extends Construct implements SSTConstruct {
352
352
  * table.bindToConsumer("consumer1", [STRIPE_KEY, bucket]);
353
353
  * ```
354
354
  */
355
- bindToConsumer(consumerName: string, constructs: SSTConstruct[]): void;
355
+ bindToConsumer(consumerName: string, constructs: BindingResource[]): void;
356
356
  /**
357
357
  * Grant permissions to all consumers of this table.
358
358
  *
@@ -399,7 +399,7 @@ export declare class Table extends Construct implements SSTConstruct {
399
399
  };
400
400
  };
401
401
  /** @internal */
402
- getFunctionBinding(): FunctionBindingProps;
402
+ getBindings(): BindingProps;
403
403
  private createTable;
404
404
  private addConsumer;
405
405
  private buildAttribute;
@@ -267,7 +267,7 @@ export class Table extends Construct {
267
267
  };
268
268
  }
269
269
  /** @internal */
270
- getFunctionBinding() {
270
+ getBindings() {
271
271
  return {
272
272
  clientPackage: "table",
273
273
  variables: {
@@ -4,7 +4,7 @@ import { Construct } from "constructs";
4
4
  import { SSTConstruct } from "./Construct.js";
5
5
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
6
6
  import { Queue } from "./Queue.js";
7
- import { FunctionBindingProps } from "./util/functionBinding.js";
7
+ import { BindingResource, BindingProps } from "./util/binding.js";
8
8
  import { Permissions } from "./util/permission.js";
9
9
  /**
10
10
  * Used to define a queue subscriber for a topic
@@ -190,7 +190,7 @@ export declare class Topic extends Construct implements SSTConstruct {
190
190
  * topic.bind([STRIPE_KEY, bucket]);
191
191
  * ```
192
192
  */
193
- bind(constructs: SSTConstruct[]): void;
193
+ bind(constructs: BindingResource[]): void;
194
194
  /**
195
195
  * Binds the given list of resources to a specific subscriber.
196
196
  * @example
@@ -205,7 +205,7 @@ export declare class Topic extends Construct implements SSTConstruct {
205
205
  * topic.bindToSubscriber("subscriber1", [STRIPE_KEY, bucket]);
206
206
  * ```
207
207
  */
208
- bindToSubscriber(subscriberName: string, constructs: SSTConstruct[]): void;
208
+ bindToSubscriber(subscriberName: string, constructs: BindingResource[]): void;
209
209
  /**
210
210
  * Attaches the given list of permissions to all the subscriber functions. This allows the subscribers to access other AWS resources.
211
211
  *
@@ -249,7 +249,7 @@ export declare class Topic extends Construct implements SSTConstruct {
249
249
  };
250
250
  };
251
251
  /** @internal */
252
- getFunctionBinding(): FunctionBindingProps;
252
+ getBindings(): BindingProps;
253
253
  private createTopic;
254
254
  private addSubscriber;
255
255
  private addQueueSubscriber;
@@ -195,7 +195,7 @@ export class Topic extends Construct {
195
195
  };
196
196
  }
197
197
  /** @internal */
198
- getFunctionBinding() {
198
+ getBindings() {
199
199
  return {
200
200
  clientPackage: "topic",
201
201
  variables: {
@@ -5,7 +5,7 @@ import * as apig from "aws-cdk-lib/aws-apigatewayv2";
5
5
  import * as apigAuthorizers from "aws-cdk-lib/aws-apigatewayv2-authorizers";
6
6
  import { SSTConstruct } from "./Construct.js";
7
7
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
8
- import { FunctionBindingProps } from "./util/functionBinding.js";
8
+ import { BindingResource, BindingProps } from "./util/binding.js";
9
9
  import { Permissions } from "./util/permission.js";
10
10
  import * as apigV2Domain from "./util/apiGatewayV2Domain.js";
11
11
  import * as apigV2AccessLog from "./util/apiGatewayV2AccessLog.js";
@@ -301,7 +301,7 @@ export declare class WebSocketApi extends Construct implements SSTConstruct {
301
301
  * api.bind([STRIPE_KEY, bucket]);
302
302
  * ```
303
303
  */
304
- bind(constructs: SSTConstruct[]): void;
304
+ bind(constructs: BindingResource[]): void;
305
305
  /**
306
306
  * Binds the given list of resources to a specific route.
307
307
  *
@@ -311,7 +311,7 @@ export declare class WebSocketApi extends Construct implements SSTConstruct {
311
311
  * ```
312
312
  *
313
313
  */
314
- bindToRoute(routeKey: string, constructs: SSTConstruct[]): void;
314
+ bindToRoute(routeKey: string, constructs: BindingResource[]): void;
315
315
  /**
316
316
  * Attaches the given list of permissions to all the routes. This allows the functions to access other AWS resources.
317
317
  *
@@ -348,7 +348,7 @@ export declare class WebSocketApi extends Construct implements SSTConstruct {
348
348
  };
349
349
  };
350
350
  /** @internal */
351
- getFunctionBinding(): FunctionBindingProps;
351
+ getBindings(): BindingProps;
352
352
  private createWebSocketApi;
353
353
  private createWebSocketStage;
354
354
  private createCloudWatchRole;
@@ -196,7 +196,7 @@ export class WebSocketApi extends Construct {
196
196
  };
197
197
  }
198
198
  /** @internal */
199
- getFunctionBinding() {
199
+ getBindings() {
200
200
  return {
201
201
  clientPackage: "websocket-api",
202
202
  variables: {
@@ -8,7 +8,7 @@ import { SSTConstruct } from "../Construct.js";
8
8
  import { DistributionDomainProps } from "../Distribution.js";
9
9
  import { BaseSiteCdkDistributionProps } from "../BaseSite.js";
10
10
  import { Permissions } from "../util/permission.js";
11
- import { FunctionBindingProps } from "../util/functionBinding.js";
11
+ import { BindingProps } from "../util/binding.js";
12
12
  export interface NextjsDomainProps extends DistributionDomainProps {
13
13
  }
14
14
  export interface NextjsCdkDistributionProps extends BaseSiteCdkDistributionProps {
@@ -268,7 +268,7 @@ export declare class NextjsSite extends Construct implements SSTConstruct {
268
268
  };
269
269
  };
270
270
  /** @internal */
271
- getFunctionBinding(): FunctionBindingProps;
271
+ getBindings(): BindingProps;
272
272
  private zipAppAssets;
273
273
  private zipAppStubAssets;
274
274
  private createEdgeFunction;
@@ -24,7 +24,7 @@ import { isCDKConstruct } from "../Construct.js";
24
24
  import { getBuildCmdEnvironment, buildErrorResponsesForRedirectToIndex, } from "../BaseSite.js";
25
25
  import { attachPermissionsToRole } from "../util/permission.js";
26
26
  import { getHandlerHash } from "../util/builder.js";
27
- import { getParameterPath, } from "../util/functionBinding.js";
27
+ import { getParameterPath } from "../util/binding.js";
28
28
  import * as crossRegionHelper from "./cross-region-helper.js";
29
29
  import { gray, red } from "colorette";
30
30
  import { useProject } from "../../project.js";
@@ -242,7 +242,7 @@ export class NextjsSite extends Construct {
242
242
  };
243
243
  }
244
244
  /** @internal */
245
- getFunctionBinding() {
245
+ getBindings() {
246
246
  const app = this.node.root;
247
247
  return {
248
248
  clientPackage: "site",
@@ -3,7 +3,7 @@ import { Api, ApiProps } from "../Api.js";
3
3
  import { FunctionDefinition } from "../Function.js";
4
4
  import { SSTConstruct } from "../Construct.js";
5
5
  import { Secret } from "../Secret.js";
6
- import { FunctionBindingProps } from "../util/functionBinding.js";
6
+ import { BindingProps } from "../util/binding.js";
7
7
  export interface AuthProps {
8
8
  /**
9
9
  * The function that will handle authentication
@@ -76,5 +76,5 @@ export declare class Auth extends Construct implements SSTConstruct {
76
76
  data: {};
77
77
  };
78
78
  /** @internal */
79
- getFunctionBinding(): FunctionBindingProps;
79
+ getBindings(): BindingProps;
80
80
  }
@@ -3,7 +3,7 @@ import { Construct } from "constructs";
3
3
  import { Api } from "../Api.js";
4
4
  import { Stack } from "../Stack.js";
5
5
  import { Secret } from "../Secret.js";
6
- import { getParameterPath, } from "../util/functionBinding.js";
6
+ import { getParameterPath } from "../util/binding.js";
7
7
  import { CustomResource } from "aws-cdk-lib/core";
8
8
  /**
9
9
  * SST Auth is a lightweight authentication solution for your applications. With a simple set of configuration you can deploy a function attached to your API that can handle various authentication flows. *
@@ -105,7 +105,7 @@ export class Auth extends Construct {
105
105
  };
106
106
  }
107
107
  /** @internal */
108
- getFunctionBinding() {
108
+ getBindings() {
109
109
  return {
110
110
  clientPackage: "future/auth",
111
111
  variables: {
@@ -1,6 +1,7 @@
1
1
  import { SSTConstruct } from "../Construct.js";
2
2
  import { Secret } from "../Secret.js";
3
- export interface FunctionBindingProps {
3
+ import { PolicyStatement } from "aws-cdk-lib/aws-iam";
4
+ export interface BindingProps {
4
5
  clientPackage: string;
5
6
  permissions: Record<string, string[]>;
6
7
  variables: Record<string, {
@@ -19,14 +20,21 @@ export interface FunctionBindingProps {
19
20
  value: string;
20
21
  }>;
21
22
  }
22
- export declare function bindEnvironment(c: SSTConstruct): Record<string, string>;
23
- export declare function bindParameters(c: SSTConstruct): void;
24
- export declare function bindPermissions(c: SSTConstruct): Record<string, string[]>;
25
- export declare function bindType(c: SSTConstruct): {
23
+ export type BindingResource = SSTConstruct | {
24
+ resource: SSTConstruct;
25
+ permissions: {
26
+ actions: string[];
27
+ resources: string[];
28
+ }[];
29
+ };
30
+ export declare function getBindingEnvironments(r: BindingResource): Record<string, string>;
31
+ export declare function getBindingParameters(r: BindingResource): void;
32
+ export declare function getBindingPermissions(r: BindingResource): PolicyStatement[];
33
+ export declare function getBindingType(r: BindingResource): {
26
34
  clientPackage: string;
27
35
  variables: string[];
28
36
  } | undefined;
29
- export declare function getReferencedSecrets(c: SSTConstruct): Secret[];
37
+ export declare function getBindingReferencedSecrets(r: BindingResource): Secret[];
30
38
  export declare function getEnvironmentKey(c: SSTConstruct, prop: string): string;
31
39
  export declare function getParameterPath(c: SSTConstruct, prop: string): string;
32
40
  export declare function getParameterFallbackPath(c: SSTConstruct, prop: string): string;