wirejs-deploy-amplify-basic 0.1.151-llm → 0.1.153-llm
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/amplify-backend-assets/backend.ts +33 -28
- package/amplify-backend-assets/constructs/realtime-service/index.ts +2 -7
- package/amplify-backend-assets/constructs/table-indexes/handler-lambda.ts +3 -3
- package/amplify-hosting-assets/compute/default/package.json +1 -1
- package/build.js +1 -1
- package/package.json +2 -2
- package/amplify-backend-assets/functions/api/resource.ts +0 -12
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import { randomUUID } from 'crypto';
|
|
2
3
|
import {
|
|
3
4
|
defineBackend,
|
|
4
5
|
} from '@aws-amplify/backend';
|
|
5
|
-
import { RemovalPolicy, NestedStack } from "aws-cdk-lib";
|
|
6
|
-
import { FunctionUrlAuthType } from 'aws-cdk-lib/aws-lambda';
|
|
6
|
+
import { Duration, RemovalPolicy, NestedStack } from "aws-cdk-lib";
|
|
7
|
+
import { FunctionUrlAuthType, IFunction, Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
8
|
+
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
7
9
|
import { Bucket, BlockPublicAccess } from 'aws-cdk-lib/aws-s3';
|
|
8
10
|
import { Table, AttributeType, BillingMode } from 'aws-cdk-lib/aws-dynamodb';
|
|
9
11
|
import { AnyPrincipal, PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
@@ -11,12 +13,14 @@ import { AnyPrincipal, PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
|
11
13
|
import { TableDefinition, indexName } from 'wirejs-resources';
|
|
12
14
|
import { TableIndexes } from './constructs/table-indexes';
|
|
13
15
|
import { RealtimeService } from './constructs/realtime-service';
|
|
14
|
-
import { api } from './functions/api/resource';
|
|
15
16
|
import { auth } from './auth/resource';
|
|
16
17
|
|
|
17
18
|
// @ts-ignore
|
|
18
19
|
import generatedResources from './generated-resources';
|
|
19
20
|
|
|
21
|
+
const __filename = import.meta.url.replace(/^file:/, '');
|
|
22
|
+
const __dirname = path.dirname(__filename);
|
|
23
|
+
|
|
20
24
|
const generated: any[] = generatedResources;
|
|
21
25
|
|
|
22
26
|
const APP_ID = process.env.AWS_APP_ID ?? process.env.PWD?.replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
@@ -32,9 +36,20 @@ const SELF_INVOCATION_ID = randomUUID();
|
|
|
32
36
|
/**
|
|
33
37
|
* Amplify resources
|
|
34
38
|
*/
|
|
35
|
-
const backend = defineBackend({
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const backend = defineBackend({ auth });
|
|
40
|
+
|
|
41
|
+
const api = new NodejsFunction(backend.stack, 'ApiHandler', {
|
|
42
|
+
runtime: Runtime.NODEJS_22_X,
|
|
43
|
+
memorySize: 2 * 1024,
|
|
44
|
+
handler: 'handler',
|
|
45
|
+
entry: path.join(__dirname, 'functions', 'api', 'handler.ts'),
|
|
46
|
+
bundling: {
|
|
47
|
+
minify: true,
|
|
48
|
+
nodeModules: [
|
|
49
|
+
'jsdom'
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
timeout: Duration.minutes(15),
|
|
38
53
|
});
|
|
39
54
|
|
|
40
55
|
/**
|
|
@@ -56,21 +71,14 @@ userPoolClient.explicitAuthFlows.push(
|
|
|
56
71
|
'ALLOW_ADMIN_USER_PASSWORD_AUTH'
|
|
57
72
|
);
|
|
58
73
|
|
|
59
|
-
|
|
60
|
-
// action: 'lambda:InvokeFunction',
|
|
61
|
-
// functionName: backend.api.resources.lambda.functionName,
|
|
62
|
-
// principal: 'lambda.amazonaws.com',
|
|
63
|
-
// sourceArn: backend.api.resources.lambda.functionArn
|
|
64
|
-
// });
|
|
65
|
-
|
|
66
|
-
backend.api.resources.lambda.role?.addToPrincipalPolicy(new PolicyStatement({
|
|
74
|
+
api.role?.addToPrincipalPolicy(new PolicyStatement({
|
|
67
75
|
actions: ['lambda:InvokeFunction'],
|
|
68
76
|
resources: [
|
|
69
77
|
`arn:${backend.stack.partition}:lambda:${backend.stack.region}:${backend.stack.account}:function:*`,
|
|
70
78
|
],
|
|
71
79
|
}));
|
|
72
80
|
|
|
73
|
-
const allLambdas = [
|
|
81
|
+
const allLambdas: IFunction[] = [ api ];
|
|
74
82
|
|
|
75
83
|
/**
|
|
76
84
|
* CDK resources
|
|
@@ -80,7 +88,7 @@ const bucket = new Bucket(backend.stack, 'data', {
|
|
|
80
88
|
versioned: true,
|
|
81
89
|
removalPolicy: RemovalPolicy.RETAIN,
|
|
82
90
|
});
|
|
83
|
-
bucket.grantReadWrite(
|
|
91
|
+
bucket.grantReadWrite(api);
|
|
84
92
|
|
|
85
93
|
function isRealtimeService(resource: any): resource is {
|
|
86
94
|
type: 'RealtimeService';
|
|
@@ -96,7 +104,7 @@ if (generated.some(isRealtimeService)) {
|
|
|
96
104
|
const realtime = new RealtimeService(realtimeStack, 'realtime', {
|
|
97
105
|
appId: APP_ID!,
|
|
98
106
|
branchId: BRANCH_ID,
|
|
99
|
-
publisher:
|
|
107
|
+
publisher: api,
|
|
100
108
|
bucket: bucket.bucketName,
|
|
101
109
|
namespaces: generated
|
|
102
110
|
.filter(isRealtimeService)
|
|
@@ -188,19 +196,20 @@ for (const resource of generated) {
|
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
|
|
199
|
+
|
|
191
200
|
/**
|
|
192
201
|
* Lambda environment vars
|
|
193
202
|
*/
|
|
194
|
-
|
|
203
|
+
api.addEnvironment(
|
|
195
204
|
'BUCKET', bucket.bucketName,
|
|
196
205
|
);
|
|
197
|
-
|
|
206
|
+
api.addEnvironment(
|
|
198
207
|
'COGNITO_CLIENT_ID', backend.auth.resources.userPoolClient.userPoolClientId
|
|
199
208
|
);
|
|
200
|
-
|
|
209
|
+
api.addEnvironment(
|
|
201
210
|
'TABLE_NAME_PREFIX', TABLE_NAME_PREFIX
|
|
202
211
|
);
|
|
203
|
-
|
|
212
|
+
api.addEnvironment(
|
|
204
213
|
'SELF_INVOCATION_ID', SELF_INVOCATION_ID
|
|
205
214
|
);
|
|
206
215
|
|
|
@@ -208,12 +217,12 @@ backend.api.addEnvironment(
|
|
|
208
217
|
/**
|
|
209
218
|
* Client configuration
|
|
210
219
|
*/
|
|
211
|
-
const apiUrl =
|
|
220
|
+
const apiUrl = api.addFunctionUrl({
|
|
212
221
|
authType: FunctionUrlAuthType.NONE,
|
|
213
222
|
});
|
|
214
223
|
apiUrl.grantInvokeUrl(new AnyPrincipal());
|
|
215
224
|
|
|
216
|
-
|
|
225
|
+
api.addToRolePolicy(new PolicyStatement({
|
|
217
226
|
actions: [
|
|
218
227
|
'bedrock:InvokeModel',
|
|
219
228
|
'bedrock:InvokeModelWithResponseStream',
|
|
@@ -222,8 +231,4 @@ backend.api.resources.lambda.addToRolePolicy(new PolicyStatement({
|
|
|
222
231
|
}));
|
|
223
232
|
|
|
224
233
|
|
|
225
|
-
backend.addOutput({
|
|
226
|
-
custom: {
|
|
227
|
-
api: apiUrl.url
|
|
228
|
-
}
|
|
229
|
-
});
|
|
234
|
+
backend.addOutput({ custom: { api: apiUrl.url } });
|
|
@@ -18,12 +18,7 @@ export class RealtimeService extends Construct {
|
|
|
18
18
|
constructor(scope: Construct, id: string, props: {
|
|
19
19
|
appId: string;
|
|
20
20
|
branchId: string;
|
|
21
|
-
publisher:
|
|
22
|
-
addEnvironment: (key: string, value: string) => void;
|
|
23
|
-
resources: {
|
|
24
|
-
lambda: IFunction;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
21
|
+
publisher: NodejsFunction;
|
|
27
22
|
bucket: string; // needed for `Secret`, which currently uses the common S3 bucket
|
|
28
23
|
namespaces: string[];
|
|
29
24
|
}) {
|
|
@@ -79,7 +74,7 @@ export class RealtimeService extends Construct {
|
|
|
79
74
|
|
|
80
75
|
for (const namespace of props.namespaces) {
|
|
81
76
|
const ns = realtimeService.addChannelNamespace(namespace);
|
|
82
|
-
ns.grantPublish(props.publisher
|
|
77
|
+
ns.grantPublish(props.publisher);
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
80
|
}
|
|
@@ -77,8 +77,8 @@ export const handler = async (event: CloudFormationCustomResourceEvent) => {
|
|
|
77
77
|
TableName: tableName,
|
|
78
78
|
AttributeDefinitions: [
|
|
79
79
|
{
|
|
80
|
-
AttributeName: gsi.partitionKey
|
|
81
|
-
AttributeType: gsi.partitionKey
|
|
80
|
+
AttributeName: gsi.partitionKey!.name,
|
|
81
|
+
AttributeType: gsi.partitionKey!.type,
|
|
82
82
|
},
|
|
83
83
|
...(gsi.sortKey ? [{
|
|
84
84
|
AttributeName: gsi.sortKey.name,
|
|
@@ -90,7 +90,7 @@ export const handler = async (event: CloudFormationCustomResourceEvent) => {
|
|
|
90
90
|
IndexName: gsi.indexName,
|
|
91
91
|
KeySchema: [
|
|
92
92
|
{
|
|
93
|
-
AttributeName: gsi.partitionKey
|
|
93
|
+
AttributeName: gsi.partitionKey!.name,
|
|
94
94
|
KeyType: 'HASH'
|
|
95
95
|
},
|
|
96
96
|
...(gsi.sortKey ? [{
|
package/build.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-deploy-amplify-basic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.153-llm",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"recursive-copy": "^2.0.14",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"wirejs-dom": "^1.0.44",
|
|
47
|
-
"wirejs-resources": "^0.1.
|
|
47
|
+
"wirejs-resources": "^0.1.153-llm"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|