sst 2.1.31 → 2.1.33
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 +22 -22
- package/constructs/Api.js +34 -37
- package/constructs/App.d.ts +9 -8
- package/constructs/App.js +22 -22
- package/constructs/AppSyncApi.d.ts +17 -17
- package/constructs/AppSyncApi.js +6 -6
- package/constructs/Bucket.d.ts +5 -5
- package/constructs/Bucket.js +14 -14
- package/constructs/Cognito.d.ts +10 -10
- package/constructs/Cognito.js +31 -33
- package/constructs/Function.d.ts +37 -37
- package/constructs/Function.js +57 -58
- package/constructs/Topic.d.ts +7 -7
- package/constructs/Topic.js +6 -6
- package/credentials.js +1 -2
- package/iot.js +42 -14
- package/node/future/auth/handler.js +10 -1
- package/package.json +1 -1
- package/sst.mjs +959 -932
- package/support/base-site-archiver.mjs +16 -16
- package/support/bridge/bridge.mjs +70 -45
- package/support/ssr-site-function-archiver.mjs +15 -15
package/constructs/AppSyncApi.js
CHANGED
|
@@ -11,11 +11,11 @@ export async function weakImport(pkg) {
|
|
|
11
11
|
const { print, buildSchema } = await weakImport("graphql");
|
|
12
12
|
const { mergeTypeDefs } = await weakImport("@graphql-tools/merge");
|
|
13
13
|
import { Construct } from "constructs";
|
|
14
|
-
import * as appsync from "aws-cdk-lib/aws-appsync";
|
|
15
14
|
import * as appSyncApiDomain from "./util/appSyncApiDomain.js";
|
|
16
15
|
import { getFunctionRef, isCDKConstruct } from "./Construct.js";
|
|
17
16
|
import { Function as Fn, } from "./Function.js";
|
|
18
17
|
import { useProject } from "../project.js";
|
|
18
|
+
import { GraphqlApi, MappingTemplate as CDKMappingTemplate, SchemaFile, } from "aws-cdk-lib/aws-appsync";
|
|
19
19
|
/////////////////////
|
|
20
20
|
// Construct
|
|
21
21
|
/////////////////////
|
|
@@ -282,7 +282,7 @@ export class AppSyncApi extends Construct {
|
|
|
282
282
|
throw new Error(`Missing "schema" in "${id}" AppSyncApi`);
|
|
283
283
|
}
|
|
284
284
|
else if (typeof schema === "string") {
|
|
285
|
-
mainSchema =
|
|
285
|
+
mainSchema = SchemaFile.fromAsset(schema);
|
|
286
286
|
}
|
|
287
287
|
else {
|
|
288
288
|
if (schema.length === 0) {
|
|
@@ -294,13 +294,13 @@ export class AppSyncApi extends Construct {
|
|
|
294
294
|
.map(buildSchema));
|
|
295
295
|
const filePath = path.join(useProject().paths.out, `appsyncapi-${id}-${this.node.addr}.graphql`);
|
|
296
296
|
fs.writeFileSync(filePath, print(mergedSchema));
|
|
297
|
-
mainSchema =
|
|
297
|
+
mainSchema = SchemaFile.fromAsset(filePath);
|
|
298
298
|
}
|
|
299
299
|
// build domain
|
|
300
300
|
const domainData = appSyncApiDomain.buildCustomDomainData(this, customDomain);
|
|
301
301
|
this._customDomainUrl =
|
|
302
302
|
domainData && `https://${domainData.domainName}/graphql`;
|
|
303
|
-
this.cdk.graphqlApi = new
|
|
303
|
+
this.cdk.graphqlApi = new GraphqlApi(this, "Api", {
|
|
304
304
|
name: app.logicalPrefixedName(id),
|
|
305
305
|
xrayEnabled: true,
|
|
306
306
|
schema: mainSchema,
|
|
@@ -482,9 +482,9 @@ export class AppSyncApi extends Construct {
|
|
|
482
482
|
return undefined;
|
|
483
483
|
}
|
|
484
484
|
if (mapping.file) {
|
|
485
|
-
return
|
|
485
|
+
return CDKMappingTemplate.fromFile(mapping.file);
|
|
486
486
|
}
|
|
487
|
-
return
|
|
487
|
+
return CDKMappingTemplate.fromString(mapping.inline);
|
|
488
488
|
}
|
|
489
489
|
buildDataSourceKey(typeName, fieldName) {
|
|
490
490
|
return `LambdaDS_${typeName}_${fieldName}`;
|
package/constructs/Bucket.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
3
2
|
import { Queue } from "./Queue.js";
|
|
4
3
|
import { Topic } from "./Topic.js";
|
|
5
4
|
import { SSTConstruct } from "./Construct.js";
|
|
@@ -7,11 +6,12 @@ import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefini
|
|
|
7
6
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
8
7
|
import { Permissions } from "./util/permission.js";
|
|
9
8
|
import { Duration } from "./util/duration.js";
|
|
9
|
+
import { BucketProps as CDKBucketProps, IBucket, EventType, HttpMethods } from "aws-cdk-lib/aws-s3";
|
|
10
10
|
export interface BucketCorsRule {
|
|
11
11
|
/**
|
|
12
12
|
* The collection of allowed HTTP methods.
|
|
13
13
|
*/
|
|
14
|
-
allowedMethods: (keyof typeof
|
|
14
|
+
allowedMethods: (keyof typeof HttpMethods)[];
|
|
15
15
|
/**
|
|
16
16
|
* The collection of allowed origins.
|
|
17
17
|
*
|
|
@@ -46,7 +46,7 @@ interface BucketBaseNotificationProps {
|
|
|
46
46
|
/**
|
|
47
47
|
* The S3 event types that will trigger the notification.
|
|
48
48
|
*/
|
|
49
|
-
events?: Lowercase<keyof typeof
|
|
49
|
+
events?: Lowercase<keyof typeof EventType>[];
|
|
50
50
|
/**
|
|
51
51
|
* S3 object key filter rules to determine which objects trigger this event.
|
|
52
52
|
*/
|
|
@@ -219,7 +219,7 @@ export interface BucketProps {
|
|
|
219
219
|
* });
|
|
220
220
|
* ```
|
|
221
221
|
*/
|
|
222
|
-
bucket?:
|
|
222
|
+
bucket?: IBucket | CDKBucketProps;
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
@@ -239,7 +239,7 @@ export declare class Bucket extends Construct implements SSTConstruct {
|
|
|
239
239
|
/**
|
|
240
240
|
* The internally created CDK `Bucket` instance.
|
|
241
241
|
*/
|
|
242
|
-
bucket:
|
|
242
|
+
bucket: IBucket;
|
|
243
243
|
};
|
|
244
244
|
readonly notifications: Record<string, Fn | Queue | Topic>;
|
|
245
245
|
readonly bindingForAllNotifications: SSTConstruct[];
|
package/constructs/Bucket.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
3
|
-
import * as s3Notifications from "aws-cdk-lib/aws-s3-notifications";
|
|
4
2
|
import { Queue } from "./Queue.js";
|
|
5
3
|
import { Topic } from "./Topic.js";
|
|
6
4
|
import { getFunctionRef, isCDKConstruct } from "./Construct.js";
|
|
7
5
|
import { Function as Fn, } from "./Function.js";
|
|
8
6
|
import { toCdkDuration } from "./util/duration.js";
|
|
7
|
+
import { Bucket as CDKBucket, EventType, HttpMethods, } from "aws-cdk-lib/aws-s3";
|
|
8
|
+
import { LambdaDestination, SnsDestination, SqsDestination, } from "aws-cdk-lib/aws-s3-notifications";
|
|
9
9
|
/////////////////////
|
|
10
10
|
// Construct
|
|
11
11
|
/////////////////////
|
|
@@ -179,7 +179,7 @@ export class Bucket extends Construct {
|
|
|
179
179
|
this.cdk.bucket = cdk?.bucket;
|
|
180
180
|
}
|
|
181
181
|
else {
|
|
182
|
-
this.cdk.bucket = new
|
|
182
|
+
this.cdk.bucket = new CDKBucket(this, "Bucket", {
|
|
183
183
|
bucketName: name,
|
|
184
184
|
cors: this.buildCorsConfig(cors),
|
|
185
185
|
...cdk?.bucket,
|
|
@@ -202,7 +202,7 @@ export class Bucket extends Construct {
|
|
|
202
202
|
this.addFunctionNotification(scope, notificationName, notification);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
addQueueNotification(
|
|
205
|
+
addQueueNotification(_scope, notificationName, notification) {
|
|
206
206
|
// Parse notification props
|
|
207
207
|
let notificationProps;
|
|
208
208
|
let queue;
|
|
@@ -225,9 +225,9 @@ export class Bucket extends Construct {
|
|
|
225
225
|
"object_removed",
|
|
226
226
|
];
|
|
227
227
|
const filters = notificationProps?.filters || [];
|
|
228
|
-
events.forEach((event) => this.cdk.bucket.addEventNotification(
|
|
228
|
+
events.forEach((event) => this.cdk.bucket.addEventNotification(EventType[event.toUpperCase()], new SqsDestination(queue.cdk.queue), ...filters));
|
|
229
229
|
}
|
|
230
|
-
addTopicNotification(
|
|
230
|
+
addTopicNotification(_scope, notificationName, notification) {
|
|
231
231
|
// Parse notification props
|
|
232
232
|
let notificationProps;
|
|
233
233
|
let topic;
|
|
@@ -250,7 +250,7 @@ export class Bucket extends Construct {
|
|
|
250
250
|
"object_removed",
|
|
251
251
|
];
|
|
252
252
|
const filters = notificationProps?.filters || [];
|
|
253
|
-
events.forEach((event) => this.cdk.bucket.addEventNotification(
|
|
253
|
+
events.forEach((event) => this.cdk.bucket.addEventNotification(EventType[event.toUpperCase()], new SnsDestination(topic.cdk.topic), ...filters));
|
|
254
254
|
}
|
|
255
255
|
addFunctionNotification(scope, notificationName, notification) {
|
|
256
256
|
// parse notification
|
|
@@ -275,7 +275,7 @@ export class Bucket extends Construct {
|
|
|
275
275
|
"object_removed",
|
|
276
276
|
];
|
|
277
277
|
const filters = notificationProps?.filters || [];
|
|
278
|
-
events.forEach((event) => this.cdk.bucket.addEventNotification(
|
|
278
|
+
events.forEach((event) => this.cdk.bucket.addEventNotification(EventType[event.toUpperCase()], new LambdaDestination(fn), ...filters));
|
|
279
279
|
// attached permissions
|
|
280
280
|
this.permissionsAttachedForAllNotifications.forEach((permissions) => fn.attachPermissions(permissions));
|
|
281
281
|
fn.bind(this.bindingForAllNotifications);
|
|
@@ -289,18 +289,18 @@ export class Bucket extends Construct {
|
|
|
289
289
|
{
|
|
290
290
|
allowedHeaders: ["*"],
|
|
291
291
|
allowedMethods: [
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
292
|
+
HttpMethods.GET,
|
|
293
|
+
HttpMethods.PUT,
|
|
294
|
+
HttpMethods.HEAD,
|
|
295
|
+
HttpMethods.POST,
|
|
296
|
+
HttpMethods.DELETE,
|
|
297
297
|
],
|
|
298
298
|
allowedOrigins: ["*"],
|
|
299
299
|
},
|
|
300
300
|
];
|
|
301
301
|
}
|
|
302
302
|
return cors.map((e) => ({
|
|
303
|
-
allowedMethods: (e.allowedMethods || []).map((method) =>
|
|
303
|
+
allowedMethods: (e.allowedMethods || []).map((method) => HttpMethods[method]),
|
|
304
304
|
allowedOrigins: e.allowedOrigins,
|
|
305
305
|
allowedHeaders: e.allowedHeaders,
|
|
306
306
|
exposedHeaders: e.exposedHeaders,
|
package/constructs/Cognito.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import * as iam from "aws-cdk-lib/aws-iam";
|
|
3
|
-
import * as cognito from "aws-cdk-lib/aws-cognito";
|
|
4
2
|
import { SSTConstruct } from "./Construct.js";
|
|
5
3
|
import { Function as Fn, FunctionProps, FunctionDefinition } from "./Function.js";
|
|
6
4
|
import { Permissions } from "./util/permission.js";
|
|
5
|
+
import { CfnIdentityPool, CfnIdentityPoolProps, IUserPool, IUserPoolClient, UserPoolClientOptions, UserPoolProps } from "aws-cdk-lib/aws-cognito";
|
|
6
|
+
import { Role } from "aws-cdk-lib/aws-iam";
|
|
7
7
|
export interface CognitoUserPoolTriggers {
|
|
8
8
|
createAuthChallenge?: FunctionDefinition;
|
|
9
9
|
customEmailSender?: FunctionDefinition;
|
|
@@ -38,7 +38,7 @@ export interface CognitoTwitterProps {
|
|
|
38
38
|
consumerKey: string;
|
|
39
39
|
consumerSecret: string;
|
|
40
40
|
}
|
|
41
|
-
export interface CognitoCdkCfnIdentityPoolProps extends Omit<
|
|
41
|
+
export interface CognitoCdkCfnIdentityPoolProps extends Omit<CfnIdentityPoolProps, "allowUnauthenticatedIdentities"> {
|
|
42
42
|
allowUnauthenticatedIdentities?: boolean;
|
|
43
43
|
}
|
|
44
44
|
export interface CognitoIdentityPoolFederationProps {
|
|
@@ -112,11 +112,11 @@ export interface CognitoProps {
|
|
|
112
112
|
/**
|
|
113
113
|
* This allows you to override the default settings this construct uses internally to create the User Pool.
|
|
114
114
|
*/
|
|
115
|
-
userPool?:
|
|
115
|
+
userPool?: UserPoolProps | IUserPool;
|
|
116
116
|
/**
|
|
117
117
|
* This allows you to override the default settings this construct uses internally to create the User Pool client.
|
|
118
118
|
*/
|
|
119
|
-
userPoolClient?:
|
|
119
|
+
userPoolClient?: UserPoolClientOptions | IUserPoolClient;
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
@@ -133,11 +133,11 @@ export interface CognitoProps {
|
|
|
133
133
|
export declare class Cognito extends Construct implements SSTConstruct {
|
|
134
134
|
readonly id: string;
|
|
135
135
|
readonly cdk: {
|
|
136
|
-
userPool:
|
|
137
|
-
userPoolClient:
|
|
138
|
-
cfnIdentityPool?:
|
|
139
|
-
authRole:
|
|
140
|
-
unauthRole:
|
|
136
|
+
userPool: IUserPool;
|
|
137
|
+
userPoolClient: IUserPoolClient;
|
|
138
|
+
cfnIdentityPool?: CfnIdentityPool;
|
|
139
|
+
authRole: Role;
|
|
140
|
+
unauthRole: Role;
|
|
141
141
|
};
|
|
142
142
|
private functions;
|
|
143
143
|
private props;
|
package/constructs/Cognito.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
-
import * as iam from "aws-cdk-lib/aws-iam";
|
|
3
|
-
import * as cognito from "aws-cdk-lib/aws-cognito";
|
|
4
2
|
import { Stack } from "./Stack.js";
|
|
5
|
-
import { getFunctionRef, isCDKConstruct
|
|
3
|
+
import { getFunctionRef, isCDKConstruct } from "./Construct.js";
|
|
6
4
|
import { Function as Fn, } from "./Function.js";
|
|
7
5
|
import { attachPermissionsToRole, attachPermissionsToPolicy, } from "./util/permission.js";
|
|
6
|
+
import { CfnIdentityPool, CfnIdentityPoolRoleAttachment, UserPool, UserPoolClient, UserPoolOperation, } from "aws-cdk-lib/aws-cognito";
|
|
7
|
+
import { Effect, FederatedPrincipal, OpenIdConnectProvider, Policy, PolicyStatement, Role, } from "aws-cdk-lib/aws-iam";
|
|
8
8
|
const CognitoUserPoolTriggerOperationMapping = {
|
|
9
|
-
createAuthChallenge:
|
|
10
|
-
customEmailSender:
|
|
11
|
-
customMessage:
|
|
12
|
-
customSmsSender:
|
|
13
|
-
defineAuthChallenge:
|
|
14
|
-
postAuthentication:
|
|
15
|
-
postConfirmation:
|
|
16
|
-
preAuthentication:
|
|
17
|
-
preSignUp:
|
|
18
|
-
preTokenGeneration:
|
|
19
|
-
userMigration:
|
|
20
|
-
verifyAuthChallengeResponse:
|
|
9
|
+
createAuthChallenge: UserPoolOperation.CREATE_AUTH_CHALLENGE,
|
|
10
|
+
customEmailSender: UserPoolOperation.CUSTOM_EMAIL_SENDER,
|
|
11
|
+
customMessage: UserPoolOperation.CUSTOM_MESSAGE,
|
|
12
|
+
customSmsSender: UserPoolOperation.CUSTOM_SMS_SENDER,
|
|
13
|
+
defineAuthChallenge: UserPoolOperation.DEFINE_AUTH_CHALLENGE,
|
|
14
|
+
postAuthentication: UserPoolOperation.POST_AUTHENTICATION,
|
|
15
|
+
postConfirmation: UserPoolOperation.POST_CONFIRMATION,
|
|
16
|
+
preAuthentication: UserPoolOperation.PRE_AUTHENTICATION,
|
|
17
|
+
preSignUp: UserPoolOperation.PRE_SIGN_UP,
|
|
18
|
+
preTokenGeneration: UserPoolOperation.PRE_TOKEN_GENERATION,
|
|
19
|
+
userMigration: UserPoolOperation.USER_MIGRATION,
|
|
20
|
+
verifyAuthChallengeResponse: UserPoolOperation.VERIFY_AUTH_CHALLENGE_RESPONSE,
|
|
21
21
|
};
|
|
22
22
|
/////////////////////
|
|
23
23
|
// Construct
|
|
@@ -141,7 +141,7 @@ export class Cognito extends Construct {
|
|
|
141
141
|
: `Auth-${this.node.id}-${scope.node.id}-UnauthRole`;
|
|
142
142
|
let policy = scope.node.tryFindChild(policyId);
|
|
143
143
|
if (!policy) {
|
|
144
|
-
policy = new
|
|
144
|
+
policy = new Policy(scope, policyId);
|
|
145
145
|
}
|
|
146
146
|
role.attachInlinePolicy(policy);
|
|
147
147
|
attachPermissionsToPolicy(policy, permissions);
|
|
@@ -154,8 +154,7 @@ export class Cognito extends Construct {
|
|
|
154
154
|
this.cdk.userPool = cdk?.userPool;
|
|
155
155
|
}
|
|
156
156
|
else {
|
|
157
|
-
const cognitoUserPoolProps = (cdk?.userPool ||
|
|
158
|
-
{});
|
|
157
|
+
const cognitoUserPoolProps = (cdk?.userPool || {});
|
|
159
158
|
// validate `lambdaTriggers` is not specified
|
|
160
159
|
if (cognitoUserPoolProps.lambdaTriggers) {
|
|
161
160
|
throw new Error(`Cannot configure the "cdk.userPool.lambdaTriggers" in the Cognito construct. Use the "triggers" instead.`);
|
|
@@ -164,7 +163,7 @@ export class Cognito extends Construct {
|
|
|
164
163
|
if (isCDKConstruct(cdk?.userPoolClient)) {
|
|
165
164
|
throw new Error(`Cannot import the "userPoolClient" when the "userPool" is not imported.`);
|
|
166
165
|
}
|
|
167
|
-
this.cdk.userPool = new
|
|
166
|
+
this.cdk.userPool = new UserPool(this, "UserPool", {
|
|
168
167
|
userPoolName: app.logicalPrefixedName(this.node.id),
|
|
169
168
|
selfSignUpEnabled: true,
|
|
170
169
|
signInCaseSensitive: false,
|
|
@@ -179,9 +178,8 @@ export class Cognito extends Construct {
|
|
|
179
178
|
this.cdk.userPoolClient = cdk?.userPoolClient;
|
|
180
179
|
}
|
|
181
180
|
else {
|
|
182
|
-
const clientProps = (cdk?.userPoolClient ||
|
|
183
|
-
|
|
184
|
-
this.cdk.userPoolClient = new cognito.UserPoolClient(this, "UserPoolClient", {
|
|
181
|
+
const clientProps = (cdk?.userPoolClient || {});
|
|
182
|
+
this.cdk.userPoolClient = new UserPoolClient(this, "UserPoolClient", {
|
|
185
183
|
userPool: this.cdk.userPool,
|
|
186
184
|
...clientProps,
|
|
187
185
|
});
|
|
@@ -217,7 +215,7 @@ export class Cognito extends Construct {
|
|
|
217
215
|
if (!auth0.clientId) {
|
|
218
216
|
throw new Error(`Auth0ClientId: No Auth0 clientId defined for the "${id}" Auth`);
|
|
219
217
|
}
|
|
220
|
-
const provider = new
|
|
218
|
+
const provider = new OpenIdConnectProvider(this, "Auth0Provider", {
|
|
221
219
|
url: auth0.domain.startsWith("https://")
|
|
222
220
|
? auth0.domain
|
|
223
221
|
: `https://${auth0.domain}`,
|
|
@@ -266,7 +264,7 @@ export class Cognito extends Construct {
|
|
|
266
264
|
const identityPoolProps = typeof identityPoolFederation === "object"
|
|
267
265
|
? identityPoolFederation.cdk?.cfnIdentityPool || {}
|
|
268
266
|
: {};
|
|
269
|
-
this.cdk.cfnIdentityPool = new
|
|
267
|
+
this.cdk.cfnIdentityPool = new CfnIdentityPool(this, "IdentityPool", {
|
|
270
268
|
identityPoolName: app.logicalPrefixedName(id),
|
|
271
269
|
allowUnauthenticatedIdentities: true,
|
|
272
270
|
cognitoIdentityProviders,
|
|
@@ -277,7 +275,7 @@ export class Cognito extends Construct {
|
|
|
277
275
|
this.cdk.authRole = this.createAuthRole(this.cdk.cfnIdentityPool);
|
|
278
276
|
this.cdk.unauthRole = this.createUnauthRole(this.cdk.cfnIdentityPool);
|
|
279
277
|
// Attach roles to Identity Pool
|
|
280
|
-
new
|
|
278
|
+
new CfnIdentityPoolRoleAttachment(this, "IdentityPoolRoleAttachment", {
|
|
281
279
|
identityPoolId: this.cdk.cfnIdentityPool.ref,
|
|
282
280
|
roles: {
|
|
283
281
|
authenticated: this.cdk.authRole.roleArn,
|
|
@@ -312,8 +310,8 @@ export class Cognito extends Construct {
|
|
|
312
310
|
return lambda;
|
|
313
311
|
}
|
|
314
312
|
createAuthRole(identityPool) {
|
|
315
|
-
const role = new
|
|
316
|
-
assumedBy: new
|
|
313
|
+
const role = new Role(this, "IdentityPoolAuthRole", {
|
|
314
|
+
assumedBy: new FederatedPrincipal("cognito-identity.amazonaws.com", {
|
|
317
315
|
StringEquals: {
|
|
318
316
|
"cognito-identity.amazonaws.com:aud": identityPool.ref,
|
|
319
317
|
},
|
|
@@ -322,8 +320,8 @@ export class Cognito extends Construct {
|
|
|
322
320
|
},
|
|
323
321
|
}, "sts:AssumeRoleWithWebIdentity"),
|
|
324
322
|
});
|
|
325
|
-
role.addToPolicy(new
|
|
326
|
-
effect:
|
|
323
|
+
role.addToPolicy(new PolicyStatement({
|
|
324
|
+
effect: Effect.ALLOW,
|
|
327
325
|
actions: [
|
|
328
326
|
"mobileanalytics:PutEvents",
|
|
329
327
|
"cognito-sync:*",
|
|
@@ -334,8 +332,8 @@ export class Cognito extends Construct {
|
|
|
334
332
|
return role;
|
|
335
333
|
}
|
|
336
334
|
createUnauthRole(identityPool) {
|
|
337
|
-
const role = new
|
|
338
|
-
assumedBy: new
|
|
335
|
+
const role = new Role(this, "IdentityPoolUnauthRole", {
|
|
336
|
+
assumedBy: new FederatedPrincipal("cognito-identity.amazonaws.com", {
|
|
339
337
|
StringEquals: {
|
|
340
338
|
"cognito-identity.amazonaws.com:aud": identityPool.ref,
|
|
341
339
|
},
|
|
@@ -344,8 +342,8 @@ export class Cognito extends Construct {
|
|
|
344
342
|
},
|
|
345
343
|
}, "sts:AssumeRoleWithWebIdentity"),
|
|
346
344
|
});
|
|
347
|
-
role.addToPolicy(new
|
|
348
|
-
effect:
|
|
345
|
+
role.addToPolicy(new PolicyStatement({
|
|
346
|
+
effect: Effect.ALLOW,
|
|
349
347
|
actions: ["mobileanalytics:PutEvents", "cognito-sync:*"],
|
|
350
348
|
resources: ["*"],
|
|
351
349
|
}));
|
package/constructs/Function.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { Loader, BuildOptions } from "esbuild";
|
|
2
2
|
import { Construct } from "constructs";
|
|
3
|
-
import * as cdk from "aws-cdk-lib";
|
|
4
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
5
|
-
import * as logs from "aws-cdk-lib/aws-logs";
|
|
6
3
|
import { Stack } from "./Stack.js";
|
|
7
4
|
import { SSTConstruct } from "./Construct.js";
|
|
8
5
|
import { Size } from "./util/size.js";
|
|
@@ -10,31 +7,34 @@ import { Duration } from "./util/duration.js";
|
|
|
10
7
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
11
8
|
import { Permissions } from "./util/permission.js";
|
|
12
9
|
import * as functionUrlCors from "./util/functionUrlCors.js";
|
|
10
|
+
import { Architecture, Function as CDKFunction, FunctionOptions, ILayerVersion, Runtime as CDKRuntime, Tracing } from "aws-cdk-lib/aws-lambda";
|
|
11
|
+
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
12
|
+
import { Size as CDKSize, Duration as CDKDuration } from "aws-cdk-lib";
|
|
13
13
|
declare const supportedRuntimes: {
|
|
14
|
-
rust:
|
|
15
|
-
nodejs:
|
|
16
|
-
"nodejs4.3":
|
|
17
|
-
"nodejs6.10":
|
|
18
|
-
"nodejs8.10":
|
|
19
|
-
"nodejs10.x":
|
|
20
|
-
"nodejs12.x":
|
|
21
|
-
"nodejs14.x":
|
|
22
|
-
"nodejs16.x":
|
|
23
|
-
"nodejs18.x":
|
|
24
|
-
"python2.7":
|
|
25
|
-
"python3.6":
|
|
26
|
-
"python3.7":
|
|
27
|
-
"python3.8":
|
|
28
|
-
"python3.9":
|
|
29
|
-
"dotnetcore1.0":
|
|
30
|
-
"dotnetcore2.0":
|
|
31
|
-
"dotnetcore2.1":
|
|
32
|
-
"dotnetcore3.1":
|
|
33
|
-
dotnet6:
|
|
34
|
-
java8:
|
|
35
|
-
java11:
|
|
36
|
-
"go1.x":
|
|
37
|
-
go:
|
|
14
|
+
rust: CDKRuntime;
|
|
15
|
+
nodejs: CDKRuntime;
|
|
16
|
+
"nodejs4.3": CDKRuntime;
|
|
17
|
+
"nodejs6.10": CDKRuntime;
|
|
18
|
+
"nodejs8.10": CDKRuntime;
|
|
19
|
+
"nodejs10.x": CDKRuntime;
|
|
20
|
+
"nodejs12.x": CDKRuntime;
|
|
21
|
+
"nodejs14.x": CDKRuntime;
|
|
22
|
+
"nodejs16.x": CDKRuntime;
|
|
23
|
+
"nodejs18.x": CDKRuntime;
|
|
24
|
+
"python2.7": CDKRuntime;
|
|
25
|
+
"python3.6": CDKRuntime;
|
|
26
|
+
"python3.7": CDKRuntime;
|
|
27
|
+
"python3.8": CDKRuntime;
|
|
28
|
+
"python3.9": CDKRuntime;
|
|
29
|
+
"dotnetcore1.0": CDKRuntime;
|
|
30
|
+
"dotnetcore2.0": CDKRuntime;
|
|
31
|
+
"dotnetcore2.1": CDKRuntime;
|
|
32
|
+
"dotnetcore3.1": CDKRuntime;
|
|
33
|
+
dotnet6: CDKRuntime;
|
|
34
|
+
java8: CDKRuntime;
|
|
35
|
+
java11: CDKRuntime;
|
|
36
|
+
"go1.x": CDKRuntime;
|
|
37
|
+
go: CDKRuntime;
|
|
38
38
|
};
|
|
39
39
|
export type Runtime = keyof typeof supportedRuntimes;
|
|
40
40
|
export type FunctionInlineDefinition = string | Function;
|
|
@@ -51,7 +51,7 @@ export interface FunctionHooks {
|
|
|
51
51
|
*/
|
|
52
52
|
afterBuild?: (props: FunctionProps, out: string) => Promise<void>;
|
|
53
53
|
}
|
|
54
|
-
export interface FunctionProps extends Omit<
|
|
54
|
+
export interface FunctionProps extends Omit<FunctionOptions, "functionName" | "memorySize" | "timeout" | "runtime" | "tracing" | "layers" | "architecture" | "logRetention"> {
|
|
55
55
|
/**
|
|
56
56
|
* Used to configure additional files to copy into the function bundle
|
|
57
57
|
*
|
|
@@ -91,7 +91,7 @@ export interface FunctionProps extends Omit<lambda.FunctionOptions, "functionNam
|
|
|
91
91
|
* })
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
|
-
architecture?: Lowercase<keyof Pick<typeof
|
|
94
|
+
architecture?: Lowercase<keyof Pick<typeof Architecture, "ARM_64" | "X86_64">>;
|
|
95
95
|
/**
|
|
96
96
|
* By default, the name of the function is auto-generated by AWS. You can configure the name by providing a string.
|
|
97
97
|
*
|
|
@@ -185,7 +185,7 @@ export interface FunctionProps extends Omit<lambda.FunctionOptions, "functionNam
|
|
|
185
185
|
* })
|
|
186
186
|
*```
|
|
187
187
|
*/
|
|
188
|
-
tracing?: Lowercase<keyof typeof
|
|
188
|
+
tracing?: Lowercase<keyof typeof Tracing>;
|
|
189
189
|
/**
|
|
190
190
|
* Can be used to disable Live Lambda Development when using `sst start`. Useful for things like Custom Resources that need to execute during deployment.
|
|
191
191
|
*
|
|
@@ -278,7 +278,7 @@ export interface FunctionProps extends Omit<lambda.FunctionOptions, "functionNam
|
|
|
278
278
|
* })
|
|
279
279
|
* ```
|
|
280
280
|
*/
|
|
281
|
-
layers?: (string |
|
|
281
|
+
layers?: (string | ILayerVersion)[];
|
|
282
282
|
/**
|
|
283
283
|
* The duration function logs are kept in CloudWatch Logs.
|
|
284
284
|
*
|
|
@@ -292,7 +292,7 @@ export interface FunctionProps extends Omit<lambda.FunctionOptions, "functionNam
|
|
|
292
292
|
* })
|
|
293
293
|
* ```
|
|
294
294
|
*/
|
|
295
|
-
logRetention?: Lowercase<keyof typeof
|
|
295
|
+
logRetention?: Lowercase<keyof typeof RetentionDays>;
|
|
296
296
|
}
|
|
297
297
|
export interface FunctionNameProps {
|
|
298
298
|
/**
|
|
@@ -534,7 +534,7 @@ export interface FunctionCopyFilesProps {
|
|
|
534
534
|
* });
|
|
535
535
|
* ```
|
|
536
536
|
*/
|
|
537
|
-
export declare class Function extends
|
|
537
|
+
export declare class Function extends CDKFunction implements SSTConstruct {
|
|
538
538
|
readonly id: string;
|
|
539
539
|
readonly _isLiveDevEnabled: boolean;
|
|
540
540
|
/** @internal */
|
|
@@ -580,11 +580,11 @@ export declare class Function extends lambda.Function implements SSTConstruct {
|
|
|
580
580
|
private isNodeRuntime;
|
|
581
581
|
static validateHandlerSet(id: string, props: FunctionProps): void;
|
|
582
582
|
static validateVpcSettings(id: string, props: FunctionProps): void;
|
|
583
|
-
static buildLayers(scope: Construct, id: string, props: FunctionProps):
|
|
583
|
+
static buildLayers(scope: Construct, id: string, props: FunctionProps): ILayerVersion[];
|
|
584
584
|
static normalizeMemorySize(memorySize?: number | Size): number;
|
|
585
|
-
static normalizeDiskSize(diskSize?: number | Size):
|
|
586
|
-
static normalizeTimeout(timeout?: number | Duration):
|
|
587
|
-
static handleImportedLayer(scope: Construct, layer:
|
|
585
|
+
static normalizeDiskSize(diskSize?: number | Size): CDKSize;
|
|
586
|
+
static normalizeTimeout(timeout?: number | Duration): CDKDuration;
|
|
587
|
+
static handleImportedLayer(scope: Construct, layer: ILayerVersion): ILayerVersion;
|
|
588
588
|
static isInlineDefinition(definition: any): definition is FunctionInlineDefinition;
|
|
589
589
|
static fromDefinition(scope: Construct, id: string, definition: FunctionDefinition, inheritedProps?: FunctionProps, inheritErrorMessage?: string): Function;
|
|
590
590
|
static mergeProps(baseProps?: FunctionProps, props?: FunctionProps): FunctionProps;
|