sst 2.0.35 → 2.0.36
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/constructs/Api.d.ts +2 -10
- package/constructs/Api.js +2 -2
- package/constructs/ApiGatewayV1Api.d.ts +2 -10
- package/constructs/ApiGatewayV1Api.js +2 -2
- package/constructs/App.d.ts +0 -2
- package/constructs/App.js +3 -7
- package/constructs/AppSyncApi.d.ts +2 -10
- package/constructs/AppSyncApi.js +2 -2
- package/constructs/Auth.js +10 -7
- package/constructs/Bucket.d.ts +2 -12
- package/constructs/Bucket.js +2 -2
- package/constructs/EventBus.d.ts +2 -12
- package/constructs/EventBus.js +2 -2
- package/constructs/Function.d.ts +3 -12
- package/constructs/Function.js +10 -6
- package/constructs/Job.d.ts +3 -13
- package/constructs/Job.js +9 -7
- package/constructs/KinesisStream.d.ts +2 -12
- package/constructs/KinesisStream.js +2 -2
- package/constructs/NextjsSite.js +19 -30
- package/constructs/Parameter.d.ts +2 -10
- package/constructs/Parameter.js +2 -2
- package/constructs/Queue.d.ts +2 -12
- package/constructs/Queue.js +2 -2
- package/constructs/RDS.d.ts +2 -22
- package/constructs/RDS.js +7 -7
- package/constructs/Secret.js +2 -4
- package/constructs/SsrSite.js +14 -9
- package/constructs/StaticSite.js +14 -9
- package/constructs/Table.d.ts +2 -12
- package/constructs/Table.js +2 -2
- package/constructs/Topic.d.ts +2 -12
- package/constructs/Topic.js +2 -2
- package/constructs/WebSocketApi.d.ts +2 -10
- package/constructs/WebSocketApi.js +2 -2
- package/constructs/deprecated/NextjsSite.js +4 -4
- package/constructs/util/functionBinding.d.ts +14 -3
- package/constructs/util/functionBinding.js +45 -11
- package/node/api/index.js +5 -5
- package/node/auth/auth.js +9 -53
- package/node/bucket/index.js +2 -2
- package/node/config/index.js +4 -56
- package/node/event-bus/index.js +2 -2
- package/node/function/index.js +2 -2
- package/node/job/index.js +2 -2
- package/node/kinesis-stream/index.js +2 -2
- package/node/queue/index.js +2 -2
- package/node/rds/index.js +2 -2
- package/node/site/index.js +6 -52
- package/node/table/index.js +2 -2
- package/node/topic/index.js +2 -2
- package/node/util/index.d.ts +1 -6
- package/node/util/index.js +122 -26
- package/package.json +1 -1
- package/runtime/handlers/node.js +2 -0
- package/sst.mjs +2 -0
- /package/support/{ssr-site-function-stub → sls-nextjs-site-function-stub}/index.js +0 -0
package/constructs/Api.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
|
8
8
|
import * as logs from "aws-cdk-lib/aws-logs";
|
|
9
9
|
import { SSTConstruct } from "./Construct.js";
|
|
10
10
|
import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
11
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
11
12
|
import { Duration } from "./util/duration.js";
|
|
12
13
|
import { Permissions } from "./util/permission.js";
|
|
13
14
|
import * as apigV2Cors from "./util/apiGatewayV2Cors.js";
|
|
@@ -741,16 +742,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
|
|
|
741
742
|
};
|
|
742
743
|
};
|
|
743
744
|
/** @internal */
|
|
744
|
-
getFunctionBinding():
|
|
745
|
-
clientPackage: string;
|
|
746
|
-
variables: {
|
|
747
|
-
url: {
|
|
748
|
-
environment: string;
|
|
749
|
-
parameter: string;
|
|
750
|
-
};
|
|
751
|
-
};
|
|
752
|
-
permissions: {};
|
|
753
|
-
};
|
|
745
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
754
746
|
private createHttpApi;
|
|
755
747
|
private addAuthorizers;
|
|
756
748
|
private addRoute;
|
package/constructs/Api.js
CHANGED
|
@@ -244,8 +244,8 @@ export class Api extends Construct {
|
|
|
244
244
|
clientPackage: "api",
|
|
245
245
|
variables: {
|
|
246
246
|
url: {
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
type: "plain",
|
|
248
|
+
value: this.customDomainUrl || this.url,
|
|
249
249
|
},
|
|
250
250
|
},
|
|
251
251
|
permissions: {},
|
|
@@ -7,6 +7,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
|
7
7
|
import * as apig from "aws-cdk-lib/aws-apigateway";
|
|
8
8
|
import * as apigV1AccessLog from "./util/apiGatewayV1AccessLog.js";
|
|
9
9
|
import { Bucket } from "./Bucket.js";
|
|
10
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
10
11
|
import { Duration } from "./util/duration.js";
|
|
11
12
|
import { SSTConstruct } from "./Construct.js";
|
|
12
13
|
import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
@@ -622,16 +623,7 @@ export declare class ApiGatewayV1Api<Authorizers extends Record<string, ApiGatew
|
|
|
622
623
|
};
|
|
623
624
|
};
|
|
624
625
|
/** @internal */
|
|
625
|
-
getFunctionBinding():
|
|
626
|
-
clientPackage: string;
|
|
627
|
-
variables: {
|
|
628
|
-
url: {
|
|
629
|
-
environment: string;
|
|
630
|
-
parameter: string;
|
|
631
|
-
};
|
|
632
|
-
};
|
|
633
|
-
permissions: {};
|
|
634
|
-
};
|
|
626
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
635
627
|
private createRestApi;
|
|
636
628
|
private buildCorsConfig;
|
|
637
629
|
private createGatewayResponseForCors;
|
|
@@ -234,8 +234,8 @@ export class ApiGatewayV1Api extends Construct {
|
|
|
234
234
|
clientPackage: "api",
|
|
235
235
|
variables: {
|
|
236
236
|
url: {
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
type: "plain",
|
|
238
|
+
value: this.customDomainUrl || this.url,
|
|
239
239
|
},
|
|
240
240
|
},
|
|
241
241
|
permissions: {},
|
package/constructs/App.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as cdk from "aws-cdk-lib";
|
|
2
2
|
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
3
|
-
import * as cxapi from "aws-cdk-lib/cx-api";
|
|
4
3
|
import { SSTConstruct } from "./Construct.js";
|
|
5
4
|
import { FunctionProps } from "./Function.js";
|
|
6
5
|
import { Permissions } from "./util/permission.js";
|
|
@@ -172,7 +171,6 @@ export declare class App extends cdk.App {
|
|
|
172
171
|
* Adds additional default layers to be applied to all Lambda functions in the stack.
|
|
173
172
|
*/
|
|
174
173
|
addDefaultFunctionLayers(layers: lambda.ILayerVersion[]): void;
|
|
175
|
-
synth(options?: cdk.StageSynthesisOptions): cxapi.CloudAssembly;
|
|
176
174
|
finish(): Promise<void>;
|
|
177
175
|
isRunningSSTTest(): boolean;
|
|
178
176
|
getInputFilesFromEsbuildMetafile(file: string): Array<string>;
|
package/constructs/App.js
CHANGED
|
@@ -202,8 +202,10 @@ export class App extends cdk.App {
|
|
|
202
202
|
layers,
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
async finish() {
|
|
206
|
+
await useDeferredTasks().run();
|
|
206
207
|
Auth.injectConfig();
|
|
208
|
+
this.buildConstructsMetadata();
|
|
207
209
|
this.ensureUniqueConstructIds();
|
|
208
210
|
this.codegenTypes();
|
|
209
211
|
this.createBindingSsmParameters();
|
|
@@ -224,12 +226,6 @@ export class App extends cdk.App {
|
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
|
-
const cloudAssembly = super.synth(options);
|
|
228
|
-
return cloudAssembly;
|
|
229
|
-
}
|
|
230
|
-
async finish() {
|
|
231
|
-
await useDeferredTasks().run();
|
|
232
|
-
this.buildConstructsMetadata();
|
|
233
229
|
}
|
|
234
230
|
isRunningSSTTest() {
|
|
235
231
|
// Check the env var set inside test/setup-tests.js
|
|
@@ -10,6 +10,7 @@ import { RDS } from "./RDS.js";
|
|
|
10
10
|
import * as appSyncApiDomain from "./util/appSyncApiDomain.js";
|
|
11
11
|
import { SSTConstruct } from "./Construct.js";
|
|
12
12
|
import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
13
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
13
14
|
import { Permissions } from "./util/permission.js";
|
|
14
15
|
export interface AppSyncApiDomainProps extends appSyncApiDomain.CustomDomainProps {
|
|
15
16
|
}
|
|
@@ -506,16 +507,7 @@ export declare class AppSyncApi extends Construct implements SSTConstruct {
|
|
|
506
507
|
};
|
|
507
508
|
};
|
|
508
509
|
/** @internal */
|
|
509
|
-
getFunctionBinding():
|
|
510
|
-
clientPackage: string;
|
|
511
|
-
variables: {
|
|
512
|
-
url: {
|
|
513
|
-
environment: string;
|
|
514
|
-
parameter: string;
|
|
515
|
-
};
|
|
516
|
-
};
|
|
517
|
-
permissions: {};
|
|
518
|
-
};
|
|
510
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
519
511
|
private createGraphApi;
|
|
520
512
|
private addDataSource;
|
|
521
513
|
private addResolver;
|
package/constructs/AppSyncApi.js
CHANGED
|
@@ -256,8 +256,8 @@ export class AppSyncApi extends Construct {
|
|
|
256
256
|
clientPackage: "api",
|
|
257
257
|
variables: {
|
|
258
258
|
url: {
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
type: "plain",
|
|
260
|
+
value: this.customDomainUrl || this.url,
|
|
261
261
|
},
|
|
262
262
|
},
|
|
263
263
|
permissions: {},
|
package/constructs/Auth.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ssm from "aws-cdk-lib/aws-ssm";
|
|
|
2
2
|
import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
3
3
|
import { Construct } from "constructs";
|
|
4
4
|
import { Stack } from "./Stack.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getEnvironmentKey, getParameterPath, placeholderSecretValue, } from "./util/functionBinding.js";
|
|
6
6
|
import { CustomResource } from "aws-cdk-lib";
|
|
7
7
|
const PUBLIC_KEY_PROP = "publicKey";
|
|
8
8
|
const PRIVATE_KEY_PROP = "privateKey";
|
|
@@ -76,10 +76,13 @@ export class Auth extends Construct {
|
|
|
76
76
|
clientPackage: "auth",
|
|
77
77
|
variables: {
|
|
78
78
|
publicKey: {
|
|
79
|
-
|
|
80
|
-
// SSM parameters will be created by the custom resource
|
|
81
|
-
parameter: undefined,
|
|
79
|
+
type: "secret",
|
|
82
80
|
},
|
|
81
|
+
// Example of referencing a secret
|
|
82
|
+
//publicKey2: {
|
|
83
|
+
// type: "secret_reference",
|
|
84
|
+
// secret: this.publicKey2,
|
|
85
|
+
//},
|
|
83
86
|
},
|
|
84
87
|
permissions: {
|
|
85
88
|
"ssm:GetParameters": [
|
|
@@ -123,12 +126,12 @@ export class Auth extends Construct {
|
|
|
123
126
|
});
|
|
124
127
|
// Auth construct has two types of Function bindinds:
|
|
125
128
|
// - Api routes: bindings defined in `getFunctionBinding()`
|
|
126
|
-
// ie. calling `
|
|
129
|
+
// ie. calling `bind([auth])` will grant functions access to the public key
|
|
127
130
|
// - Auth authenticator: binds manually. Need to grant access to the prefix and private key
|
|
128
131
|
const fn = props.api.getFunction(path);
|
|
129
132
|
fn.addEnvironment(getEnvironmentKey(this, PREFIX_PROP), prefix);
|
|
130
|
-
fn.addEnvironment(getEnvironmentKey(this, PUBLIC_KEY_PROP),
|
|
131
|
-
fn.addEnvironment(getEnvironmentKey(this, PRIVATE_KEY_PROP),
|
|
133
|
+
fn.addEnvironment(getEnvironmentKey(this, PUBLIC_KEY_PROP), placeholderSecretValue());
|
|
134
|
+
fn.addEnvironment(getEnvironmentKey(this, PRIVATE_KEY_PROP), placeholderSecretValue());
|
|
132
135
|
fn.attachPermissions([
|
|
133
136
|
new PolicyStatement({
|
|
134
137
|
actions: ["ssm:GetParameters"],
|
package/constructs/Bucket.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Queue } from "./Queue.js";
|
|
|
4
4
|
import { Topic } from "./Topic.js";
|
|
5
5
|
import { SSTConstruct } from "./Construct.js";
|
|
6
6
|
import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
7
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
7
8
|
import { Permissions } from "./util/permission.js";
|
|
8
9
|
import { Duration } from "./util/duration.js";
|
|
9
10
|
export interface BucketCorsRule {
|
|
@@ -339,18 +340,7 @@ export declare class Bucket extends Construct implements SSTConstruct {
|
|
|
339
340
|
};
|
|
340
341
|
};
|
|
341
342
|
/** @internal */
|
|
342
|
-
getFunctionBinding():
|
|
343
|
-
clientPackage: string;
|
|
344
|
-
variables: {
|
|
345
|
-
bucketName: {
|
|
346
|
-
environment: string;
|
|
347
|
-
parameter: string;
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
permissions: {
|
|
351
|
-
"s3:*": string[];
|
|
352
|
-
};
|
|
353
|
-
};
|
|
343
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
354
344
|
private createBucket;
|
|
355
345
|
private addNotification;
|
|
356
346
|
private addQueueNotification;
|
package/constructs/Bucket.js
CHANGED
|
@@ -161,8 +161,8 @@ export class Bucket extends Construct {
|
|
|
161
161
|
clientPackage: "bucket",
|
|
162
162
|
variables: {
|
|
163
163
|
bucketName: {
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
type: "plain",
|
|
165
|
+
value: this.bucketName,
|
|
166
166
|
},
|
|
167
167
|
},
|
|
168
168
|
permissions: {
|
package/constructs/EventBus.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as eventsTargets from "aws-cdk-lib/aws-events-targets";
|
|
|
5
5
|
import { Queue } from "./Queue.js";
|
|
6
6
|
import { SSTConstruct } from "./Construct.js";
|
|
7
7
|
import { FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
8
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
8
9
|
import { Permissions } from "./util/permission.js";
|
|
9
10
|
/**
|
|
10
11
|
* Used to configure an EventBus function target
|
|
@@ -375,18 +376,7 @@ export declare class EventBus extends Construct implements SSTConstruct {
|
|
|
375
376
|
};
|
|
376
377
|
};
|
|
377
378
|
/** @internal */
|
|
378
|
-
getFunctionBinding():
|
|
379
|
-
clientPackage: string;
|
|
380
|
-
variables: {
|
|
381
|
-
eventBusName: {
|
|
382
|
-
environment: string;
|
|
383
|
-
parameter: string;
|
|
384
|
-
};
|
|
385
|
-
};
|
|
386
|
-
permissions: {
|
|
387
|
-
"events:*": string[];
|
|
388
|
-
};
|
|
389
|
-
};
|
|
379
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
390
380
|
private createEventBus;
|
|
391
381
|
private addRule;
|
|
392
382
|
private addTarget;
|
package/constructs/EventBus.js
CHANGED
|
@@ -215,8 +215,8 @@ export class EventBus extends Construct {
|
|
|
215
215
|
clientPackage: "event-bus",
|
|
216
216
|
variables: {
|
|
217
217
|
eventBusName: {
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
type: "plain",
|
|
219
|
+
value: this.eventBusName,
|
|
220
220
|
},
|
|
221
221
|
},
|
|
222
222
|
permissions: {
|
package/constructs/Function.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Stack } from "./Stack.js";
|
|
|
7
7
|
import { SSTConstruct } from "./Construct.js";
|
|
8
8
|
import { Size } from "./util/size.js";
|
|
9
9
|
import { Duration } from "./util/duration.js";
|
|
10
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
10
11
|
import { Permissions } from "./util/permission.js";
|
|
11
12
|
import * as functionUrlCors from "./util/functionUrlCors.js";
|
|
12
13
|
declare const supportedRuntimes: {
|
|
@@ -552,6 +553,7 @@ export declare class Function extends lambda.Function implements SSTConstruct {
|
|
|
552
553
|
_disableBind?: boolean;
|
|
553
554
|
private functionUrl?;
|
|
554
555
|
private props;
|
|
556
|
+
private allBindings;
|
|
555
557
|
constructor(scope: Construct, id: string, props: FunctionProps);
|
|
556
558
|
/**
|
|
557
559
|
* The AWS generated URL of the Function.
|
|
@@ -585,18 +587,7 @@ export declare class Function extends lambda.Function implements SSTConstruct {
|
|
|
585
587
|
};
|
|
586
588
|
};
|
|
587
589
|
/** @internal */
|
|
588
|
-
getFunctionBinding():
|
|
589
|
-
clientPackage: string;
|
|
590
|
-
variables: {
|
|
591
|
-
functionName: {
|
|
592
|
-
environment: string;
|
|
593
|
-
parameter: string;
|
|
594
|
-
};
|
|
595
|
-
};
|
|
596
|
-
permissions: {
|
|
597
|
-
"lambda:*": string[];
|
|
598
|
-
};
|
|
599
|
-
};
|
|
590
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
600
591
|
private createUrl;
|
|
601
592
|
private isNodeRuntime;
|
|
602
593
|
static validateHandlerSet(id: string, props: FunctionProps): void;
|
package/constructs/Function.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Job } from "./Job.js";
|
|
|
11
11
|
import { Secret } from "./Config.js";
|
|
12
12
|
import { toCdkSize } from "./util/size.js";
|
|
13
13
|
import { toCdkDuration } from "./util/duration.js";
|
|
14
|
-
import { bindEnvironment, bindPermissions } from "./util/functionBinding.js";
|
|
14
|
+
import { bindEnvironment, bindPermissions, getReferencedSecrets, } from "./util/functionBinding.js";
|
|
15
15
|
import { attachPermissionsToRole } from "./util/permission.js";
|
|
16
16
|
import * as functionUrlCors from "./util/functionUrlCors.js";
|
|
17
17
|
import url from "url";
|
|
@@ -67,6 +67,7 @@ export class Function extends lambda.Function {
|
|
|
67
67
|
_disableBind;
|
|
68
68
|
functionUrl;
|
|
69
69
|
props;
|
|
70
|
+
allBindings = [];
|
|
70
71
|
constructor(scope, id, props) {
|
|
71
72
|
const app = scope.node.root;
|
|
72
73
|
const stack = Stack.of(scope);
|
|
@@ -254,7 +255,10 @@ export class Function extends lambda.Function {
|
|
|
254
255
|
* ```
|
|
255
256
|
*/
|
|
256
257
|
bind(constructs) {
|
|
257
|
-
|
|
258
|
+
// Get referenced secrets
|
|
259
|
+
const referencedSecrets = [];
|
|
260
|
+
constructs.forEach((c) => referencedSecrets.push(...getReferencedSecrets(c)));
|
|
261
|
+
[...constructs, ...referencedSecrets].forEach((c) => {
|
|
258
262
|
// Bind environment
|
|
259
263
|
const env = bindEnvironment(c);
|
|
260
264
|
Object.entries(env).forEach(([key, value]) => this.addEnvironment(key, value));
|
|
@@ -268,6 +272,7 @@ export class Function extends lambda.Function {
|
|
|
268
272
|
}),
|
|
269
273
|
]));
|
|
270
274
|
});
|
|
275
|
+
this.allBindings.push(...constructs, ...referencedSecrets);
|
|
271
276
|
}
|
|
272
277
|
/**
|
|
273
278
|
* Attaches additional permissions to function.
|
|
@@ -291,13 +296,12 @@ export class Function extends lambda.Function {
|
|
|
291
296
|
}
|
|
292
297
|
/** @internal */
|
|
293
298
|
getConstructMetadata() {
|
|
294
|
-
const { bind } = this.props;
|
|
295
299
|
return {
|
|
296
300
|
type: "Function",
|
|
297
301
|
data: {
|
|
298
302
|
arn: this.functionArn,
|
|
299
303
|
localId: this.node.addr,
|
|
300
|
-
secrets:
|
|
304
|
+
secrets: this.allBindings
|
|
301
305
|
.filter((c) => c instanceof Secret)
|
|
302
306
|
.map((c) => c.name),
|
|
303
307
|
},
|
|
@@ -309,8 +313,8 @@ export class Function extends lambda.Function {
|
|
|
309
313
|
clientPackage: "function",
|
|
310
314
|
variables: {
|
|
311
315
|
functionName: {
|
|
312
|
-
|
|
313
|
-
|
|
316
|
+
type: "plain",
|
|
317
|
+
value: this.functionName,
|
|
314
318
|
},
|
|
315
319
|
},
|
|
316
320
|
permissions: {
|
package/constructs/Job.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { SSTConstruct } from "./Construct.js";
|
|
|
3
3
|
import { Function } from "./Function.js";
|
|
4
4
|
import { Duration } from "./util/duration.js";
|
|
5
5
|
import { Permissions } from "./util/permission.js";
|
|
6
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
6
7
|
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
|
7
8
|
export type JobMemorySize = "3 GB" | "7 GB" | "15 GB" | "145 GB";
|
|
8
9
|
export interface JobProps {
|
|
@@ -147,18 +148,7 @@ export declare class Job extends Construct implements SSTConstruct {
|
|
|
147
148
|
data: {};
|
|
148
149
|
};
|
|
149
150
|
/** @internal */
|
|
150
|
-
getFunctionBinding():
|
|
151
|
-
clientPackage: string;
|
|
152
|
-
variables: {
|
|
153
|
-
functionName: {
|
|
154
|
-
environment: string;
|
|
155
|
-
parameter: string;
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
permissions: {
|
|
159
|
-
"lambda:*": string[];
|
|
160
|
-
};
|
|
161
|
-
};
|
|
151
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
162
152
|
/**
|
|
163
153
|
* Binds additional resources to job.
|
|
164
154
|
*
|
|
@@ -193,7 +183,7 @@ export declare class Job extends Construct implements SSTConstruct {
|
|
|
193
183
|
private updateCodeBuildProjectCode;
|
|
194
184
|
private createLocalInvoker;
|
|
195
185
|
private createCodeBuildInvoker;
|
|
196
|
-
private
|
|
186
|
+
private bindForCodeBuild;
|
|
197
187
|
private attachPermissionsForCodeBuild;
|
|
198
188
|
private addEnvironmentForCodeBuild;
|
|
199
189
|
private normalizeMemorySize;
|
package/constructs/Job.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Stack } from "./Stack.js";
|
|
|
10
10
|
import { Function, useFunctions } from "./Function.js";
|
|
11
11
|
import { toCdkDuration } from "./util/duration.js";
|
|
12
12
|
import { attachPermissionsToRole } from "./util/permission.js";
|
|
13
|
-
import { bindEnvironment, bindPermissions } from "./util/functionBinding.js";
|
|
13
|
+
import { bindEnvironment, bindPermissions, getReferencedSecrets, } from "./util/functionBinding.js";
|
|
14
14
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
15
15
|
import { useProject } from "../project.js";
|
|
16
16
|
import { useRuntimeHandlers } from "../runtime/handlers.js";
|
|
@@ -79,8 +79,8 @@ export class Job extends Construct {
|
|
|
79
79
|
clientPackage: "job",
|
|
80
80
|
variables: {
|
|
81
81
|
functionName: {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
type: "plain",
|
|
83
|
+
value: this._jobInvoker.functionName,
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
permissions: {
|
|
@@ -98,7 +98,7 @@ export class Job extends Construct {
|
|
|
98
98
|
*/
|
|
99
99
|
bind(constructs) {
|
|
100
100
|
this._jobInvoker.bind(constructs);
|
|
101
|
-
this.
|
|
101
|
+
this.bindForCodeBuild(constructs);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Attaches the given list of [permissions](Permissions.md) to the job. This allows the job to access other AWS resources.
|
|
@@ -265,9 +265,11 @@ export class Job extends Construct {
|
|
|
265
265
|
fn._disableBind = true;
|
|
266
266
|
return fn;
|
|
267
267
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
bindForCodeBuild(constructs) {
|
|
269
|
+
// Get referenced secrets
|
|
270
|
+
const referencedSecrets = [];
|
|
271
|
+
constructs.forEach((c) => referencedSecrets.push(...getReferencedSecrets(c)));
|
|
272
|
+
[...constructs, ...referencedSecrets].forEach((c) => {
|
|
271
273
|
// Bind environment
|
|
272
274
|
const env = bindEnvironment(c);
|
|
273
275
|
Object.entries(env).forEach(([key, value]) => this.addEnvironmentForCodeBuild(key, value));
|
|
@@ -3,6 +3,7 @@ import * as kinesis from "aws-cdk-lib/aws-kinesis";
|
|
|
3
3
|
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
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
6
7
|
import { Permissions } from "./util/permission.js";
|
|
7
8
|
/**
|
|
8
9
|
* Used to define the function consumer for the stream
|
|
@@ -217,18 +218,7 @@ export declare class KinesisStream extends Construct implements SSTConstruct {
|
|
|
217
218
|
};
|
|
218
219
|
};
|
|
219
220
|
/** @internal */
|
|
220
|
-
getFunctionBinding():
|
|
221
|
-
clientPackage: string;
|
|
222
|
-
variables: {
|
|
223
|
-
streamName: {
|
|
224
|
-
environment: string;
|
|
225
|
-
parameter: string;
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
permissions: {
|
|
229
|
-
"kinesis:*": string[];
|
|
230
|
-
};
|
|
231
|
-
};
|
|
221
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
232
222
|
private createStream;
|
|
233
223
|
private addConsumer;
|
|
234
224
|
}
|
|
@@ -152,8 +152,8 @@ export class KinesisStream extends Construct {
|
|
|
152
152
|
clientPackage: "kinesis-stream",
|
|
153
153
|
variables: {
|
|
154
154
|
streamName: {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
type: "plain",
|
|
156
|
+
value: this.streamName,
|
|
157
157
|
},
|
|
158
158
|
},
|
|
159
159
|
permissions: {
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -84,51 +84,40 @@ export class NextjsSite extends SsrSite {
|
|
|
84
84
|
createMiddlewareEdgeFunctionForRegional() {
|
|
85
85
|
const { permissions, environment, path: sitePath } = this.props;
|
|
86
86
|
const middlewarePath = path.resolve(sitePath, ".open-next/middleware-function");
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
if (fs.existsSync(middlewarePath)) {
|
|
88
|
+
return new EdgeFunction(this, "Middleware", {
|
|
89
|
+
bundlePath: middlewarePath,
|
|
90
|
+
handler: "index.handler",
|
|
91
|
+
timeout: 5,
|
|
92
|
+
memorySize: 128,
|
|
93
|
+
permissions,
|
|
94
|
+
environment,
|
|
95
|
+
format: "esm",
|
|
96
|
+
});
|
|
92
97
|
}
|
|
93
|
-
else {
|
|
94
|
-
bundlePath = path.resolve(__dirname, "../support/ssr-site-function-stub");
|
|
95
|
-
handler = "server.handler";
|
|
96
|
-
}
|
|
97
|
-
const fn = new EdgeFunction(this, "Middleware", {
|
|
98
|
-
bundlePath,
|
|
99
|
-
handler,
|
|
100
|
-
timeout: 5,
|
|
101
|
-
memorySize: 128,
|
|
102
|
-
permissions,
|
|
103
|
-
environment,
|
|
104
|
-
format: "esm",
|
|
105
|
-
});
|
|
106
|
-
return { fn, isMiddlewareEnabled };
|
|
107
98
|
}
|
|
108
99
|
createCloudFrontDistributionForRegional() {
|
|
109
100
|
const { cdk } = this.props;
|
|
110
101
|
const cfDistributionProps = cdk?.distribution || {};
|
|
111
102
|
const s3Origin = new origins.S3Origin(this.cdk.bucket);
|
|
112
103
|
// Create server behavior
|
|
113
|
-
const
|
|
114
|
-
const
|
|
104
|
+
const middlewareFn = this.createMiddlewareEdgeFunctionForRegional();
|
|
105
|
+
const serverFnUrl = this.serverLambdaForRegional.addFunctionUrl({
|
|
115
106
|
authType: lambda.FunctionUrlAuthType.NONE,
|
|
116
107
|
});
|
|
117
108
|
const serverBehavior = {
|
|
118
109
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
119
|
-
origin: new origins.HttpOrigin(Fn.parseDomainName(
|
|
110
|
+
origin: new origins.HttpOrigin(Fn.parseDomainName(serverFnUrl.url)),
|
|
120
111
|
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
|
|
121
112
|
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
122
113
|
compress: true,
|
|
123
114
|
cachePolicy: cdk?.serverCachePolicy ?? this.createCloudFrontServerCachePolicy(),
|
|
124
|
-
edgeLambdas:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
]
|
|
131
|
-
: undefined,
|
|
115
|
+
edgeLambdas: middlewareFn && [
|
|
116
|
+
{
|
|
117
|
+
eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
|
|
118
|
+
functionVersion: middlewareFn.currentVersion,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
132
121
|
};
|
|
133
122
|
// Create image optimization behavior
|
|
134
123
|
const imageFn = this.createImageOptimizationFunctionForRegional();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { SSTConstruct } from "./Construct.js";
|
|
3
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
3
4
|
export interface ParameterProps {
|
|
4
5
|
/**
|
|
5
6
|
* Value of the parameter
|
|
@@ -31,15 +32,6 @@ export declare class Parameter extends Construct implements SSTConstruct {
|
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
34
|
/** @internal */
|
|
34
|
-
getFunctionBinding():
|
|
35
|
-
clientPackage: string;
|
|
36
|
-
variables: {
|
|
37
|
-
value: {
|
|
38
|
-
environment: string;
|
|
39
|
-
parameter: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
permissions: {};
|
|
43
|
-
};
|
|
35
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
44
36
|
static create<T extends Record<string, any>>(scope: Construct, parameters: T): { [key in keyof T]: Parameter; };
|
|
45
37
|
}
|
package/constructs/Parameter.js
CHANGED
package/constructs/Queue.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
|
4
4
|
import * as lambdaEventSources from "aws-cdk-lib/aws-lambda-event-sources";
|
|
5
5
|
import { SSTConstruct } from "./Construct.js";
|
|
6
6
|
import { Function as Fn, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
|
|
7
|
+
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
7
8
|
import { Permissions } from "./util/permission.js";
|
|
8
9
|
/**
|
|
9
10
|
* Used to define the consumer for the queue and invocation details
|
|
@@ -188,17 +189,6 @@ export declare class Queue extends Construct implements SSTConstruct {
|
|
|
188
189
|
};
|
|
189
190
|
};
|
|
190
191
|
/** @internal */
|
|
191
|
-
getFunctionBinding():
|
|
192
|
-
clientPackage: string;
|
|
193
|
-
variables: {
|
|
194
|
-
queueUrl: {
|
|
195
|
-
environment: string;
|
|
196
|
-
parameter: string;
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
permissions: {
|
|
200
|
-
"sqs:*": string[];
|
|
201
|
-
};
|
|
202
|
-
};
|
|
192
|
+
getFunctionBinding(): FunctionBindingProps;
|
|
203
193
|
private createQueue;
|
|
204
194
|
}
|
package/constructs/Queue.js
CHANGED