@awsless/awsless 0.0.275 → 0.0.277
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/dist/bin.js +313 -318
- package/package.json +6 -6
package/dist/bin.js
CHANGED
|
@@ -91,6 +91,113 @@ var Cancelled = class extends Error {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
// src/util/workspace.ts
|
|
95
|
+
import { minutes } from "@awsless/duration";
|
|
96
|
+
import { aws, local, WorkSpace } from "@awsless/formation";
|
|
97
|
+
import { mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
98
|
+
import { dirname, join as join2 } from "path";
|
|
99
|
+
|
|
100
|
+
// src/util/path.ts
|
|
101
|
+
import { lstat } from "fs/promises";
|
|
102
|
+
import { join, normalize } from "path";
|
|
103
|
+
var root = process.cwd();
|
|
104
|
+
var directories = {
|
|
105
|
+
root,
|
|
106
|
+
get output() {
|
|
107
|
+
return join(this.root, ".awsless");
|
|
108
|
+
},
|
|
109
|
+
get cache() {
|
|
110
|
+
return join(this.output, "cache");
|
|
111
|
+
},
|
|
112
|
+
get state() {
|
|
113
|
+
return join(this.output, "state");
|
|
114
|
+
},
|
|
115
|
+
get build() {
|
|
116
|
+
return join(this.output, "build");
|
|
117
|
+
},
|
|
118
|
+
get types() {
|
|
119
|
+
return join(this.output, "types");
|
|
120
|
+
},
|
|
121
|
+
// get template() {
|
|
122
|
+
// return join(this.output, 'template')
|
|
123
|
+
// },
|
|
124
|
+
get test() {
|
|
125
|
+
return join(this.output, "test");
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var setRoot = (path = root) => {
|
|
129
|
+
directories.root = path;
|
|
130
|
+
};
|
|
131
|
+
var findRootDir = async (path, configFiles, level = 5) => {
|
|
132
|
+
if (!level) {
|
|
133
|
+
throw new TypeError("No awsless project found");
|
|
134
|
+
}
|
|
135
|
+
for (const configFile of configFiles) {
|
|
136
|
+
const file = join(path, configFile);
|
|
137
|
+
const exists = await fileExist(file);
|
|
138
|
+
if (exists) {
|
|
139
|
+
return [file, path];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return findRootDir(normalize(join(path, "..")), configFiles, level - 1);
|
|
143
|
+
};
|
|
144
|
+
var fileExist = async (file) => {
|
|
145
|
+
try {
|
|
146
|
+
const stat5 = await lstat(file);
|
|
147
|
+
if (stat5.isFile()) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/util/workspace.ts
|
|
156
|
+
var getStateBucketName = (accountId) => {
|
|
157
|
+
return `awsless-state-${accountId}`;
|
|
158
|
+
};
|
|
159
|
+
var createWorkSpace = (props) => {
|
|
160
|
+
const lockProvider = new aws.dynamodb.LockProvider({
|
|
161
|
+
...props,
|
|
162
|
+
tableName: "awsless-locks"
|
|
163
|
+
});
|
|
164
|
+
const stateProvider = new aws.s3.StateProvider({
|
|
165
|
+
...props,
|
|
166
|
+
bucket: getStateBucketName(props.accountId)
|
|
167
|
+
});
|
|
168
|
+
const cloudProviders = aws.createCloudProviders({
|
|
169
|
+
...props,
|
|
170
|
+
timeout: minutes(60)
|
|
171
|
+
});
|
|
172
|
+
const workspace = new WorkSpace({
|
|
173
|
+
lockProvider,
|
|
174
|
+
stateProvider,
|
|
175
|
+
cloudProviders,
|
|
176
|
+
concurrency: 15
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
workspace,
|
|
180
|
+
lockProvider,
|
|
181
|
+
stateProvider
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
var pullRemoteState = async (app, stateProvider) => {
|
|
185
|
+
const file = join2(directories.state, `${app.urn}.json`);
|
|
186
|
+
const state2 = await stateProvider.get(app.urn);
|
|
187
|
+
await mkdir(dirname(file), { recursive: true });
|
|
188
|
+
if (typeof state2 === "undefined") {
|
|
189
|
+
await rm(file);
|
|
190
|
+
} else {
|
|
191
|
+
await writeFile(file, JSON.stringify(state2, void 0, 2));
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var pushRemoteState = async (app, stateProvider) => {
|
|
195
|
+
const file = join2(directories.state, `${app.urn}.json`);
|
|
196
|
+
const data = await readFile(file, "utf8");
|
|
197
|
+
const state2 = JSON.parse(data);
|
|
198
|
+
await stateProvider.update(app.urn, state2);
|
|
199
|
+
};
|
|
200
|
+
|
|
94
201
|
// src/cli/ui/util.ts
|
|
95
202
|
import wrapAnsi from "wrap-ansi";
|
|
96
203
|
import Table from "cli-table3";
|
|
@@ -183,14 +290,15 @@ var hasStateBucket = async (client, accountId) => {
|
|
|
183
290
|
try {
|
|
184
291
|
const result = await client.send(
|
|
185
292
|
new HeadBucketCommand({
|
|
186
|
-
Bucket:
|
|
293
|
+
Bucket: getStateBucketName(accountId)
|
|
187
294
|
})
|
|
188
295
|
);
|
|
189
296
|
return !!result.BucketRegion;
|
|
190
297
|
} catch (error) {
|
|
191
|
-
console.log(error);
|
|
192
298
|
if (error instanceof S3ServiceException) {
|
|
193
|
-
|
|
299
|
+
if (error.name === "NotFound") {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
194
302
|
}
|
|
195
303
|
throw error;
|
|
196
304
|
}
|
|
@@ -218,7 +326,7 @@ var createLockTable = (client) => {
|
|
|
218
326
|
var createStateBucket = (client, accountId) => {
|
|
219
327
|
return client.send(
|
|
220
328
|
new CreateBucketCommand({
|
|
221
|
-
Bucket:
|
|
329
|
+
Bucket: getStateBucketName(accountId)
|
|
222
330
|
})
|
|
223
331
|
);
|
|
224
332
|
};
|
|
@@ -258,7 +366,7 @@ var bootstrapAwsless = async (props) => {
|
|
|
258
366
|
import { intro, outro } from "@clack/prompts";
|
|
259
367
|
|
|
260
368
|
// src/config/load/load.ts
|
|
261
|
-
import { basename as basename2, dirname as
|
|
369
|
+
import { basename as basename2, dirname as dirname3, join as join5 } from "path";
|
|
262
370
|
|
|
263
371
|
// src/cli/debug.ts
|
|
264
372
|
var queue = [];
|
|
@@ -309,73 +417,16 @@ var durationMax = (max) => {
|
|
|
309
417
|
// src/config/schema/local-file.ts
|
|
310
418
|
import { stat } from "fs/promises";
|
|
311
419
|
import { z as z3 } from "zod";
|
|
312
|
-
|
|
313
|
-
// src/util/path.ts
|
|
314
|
-
import { lstat } from "fs/promises";
|
|
315
|
-
import { join, normalize } from "path";
|
|
316
|
-
var root = process.cwd();
|
|
317
|
-
var directories = {
|
|
318
|
-
root,
|
|
319
|
-
get output() {
|
|
320
|
-
return join(this.root, ".awsless");
|
|
321
|
-
},
|
|
322
|
-
get cache() {
|
|
323
|
-
return join(this.output, "cache");
|
|
324
|
-
},
|
|
325
|
-
get state() {
|
|
326
|
-
return join(this.output, "state");
|
|
327
|
-
},
|
|
328
|
-
get build() {
|
|
329
|
-
return join(this.output, "build");
|
|
330
|
-
},
|
|
331
|
-
get types() {
|
|
332
|
-
return join(this.output, "types");
|
|
333
|
-
},
|
|
334
|
-
// get template() {
|
|
335
|
-
// return join(this.output, 'template')
|
|
336
|
-
// },
|
|
337
|
-
get test() {
|
|
338
|
-
return join(this.output, "test");
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
var setRoot = (path = root) => {
|
|
342
|
-
directories.root = path;
|
|
343
|
-
};
|
|
344
|
-
var findRootDir = async (path, configFiles, level = 5) => {
|
|
345
|
-
if (!level) {
|
|
346
|
-
throw new TypeError("No awsless project found");
|
|
347
|
-
}
|
|
348
|
-
for (const configFile of configFiles) {
|
|
349
|
-
const file = join(path, configFile);
|
|
350
|
-
const exists = await fileExist(file);
|
|
351
|
-
if (exists) {
|
|
352
|
-
return [file, path];
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return findRootDir(normalize(join(path, "..")), configFiles, level - 1);
|
|
356
|
-
};
|
|
357
|
-
var fileExist = async (file) => {
|
|
358
|
-
try {
|
|
359
|
-
const stat5 = await lstat(file);
|
|
360
|
-
if (stat5.isFile()) {
|
|
361
|
-
return true;
|
|
362
|
-
}
|
|
363
|
-
} catch (error) {
|
|
364
|
-
}
|
|
365
|
-
return false;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// src/config/schema/local-file.ts
|
|
369
|
-
import { join as join2 } from "path";
|
|
420
|
+
import { join as join3 } from "path";
|
|
370
421
|
var basePath;
|
|
371
422
|
var setLocalBasePath = (path) => {
|
|
372
423
|
basePath = path;
|
|
373
424
|
};
|
|
374
425
|
var resolvePath = (path) => {
|
|
375
426
|
if (path.startsWith(".") && basePath) {
|
|
376
|
-
return
|
|
427
|
+
return join3(basePath, path);
|
|
377
428
|
}
|
|
378
|
-
return
|
|
429
|
+
return join3(directories.root, path);
|
|
379
430
|
};
|
|
380
431
|
var LocalFileSchema = z3.string().transform((path) => resolvePath(path)).refine(async (path) => {
|
|
381
432
|
try {
|
|
@@ -402,12 +453,12 @@ var sizeMax = (max) => {
|
|
|
402
453
|
};
|
|
403
454
|
|
|
404
455
|
// src/feature/function/schema.ts
|
|
405
|
-
import { days, minutes, seconds } from "@awsless/duration";
|
|
456
|
+
import { days, minutes as minutes2, seconds } from "@awsless/duration";
|
|
406
457
|
import { gibibytes, mebibytes } from "@awsless/size";
|
|
407
458
|
var MemorySizeSchema = SizeSchema.refine(sizeMin(mebibytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(gibibytes(10)), "Maximum memory size is 10 GB").describe(
|
|
408
459
|
"The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The value can be any multiple of 1 MB. You can specify a size value from 128 MB to 10 GB."
|
|
409
460
|
);
|
|
410
|
-
var TimeoutSchema = DurationSchema.refine(durationMin(seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(
|
|
461
|
+
var TimeoutSchema = DurationSchema.refine(durationMin(seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(minutes2(15)), "Maximum timeout duration is 15 minutes").describe(
|
|
411
462
|
"The amount of time that Lambda allows a function to run before stopping it. You can specify a size value from 1 second to 15 minutes."
|
|
412
463
|
);
|
|
413
464
|
var EphemeralStorageSizeSchema = SizeSchema.refine(
|
|
@@ -721,10 +772,10 @@ var InstancesSchema = z12.record(
|
|
|
721
772
|
|
|
722
773
|
// src/feature/queue/schema.ts
|
|
723
774
|
import { z as z13 } from "zod";
|
|
724
|
-
import { days as days2, hours, minutes as
|
|
775
|
+
import { days as days2, hours, minutes as minutes3, seconds as seconds2 } from "@awsless/duration";
|
|
725
776
|
import { kibibytes } from "@awsless/size";
|
|
726
777
|
var RetentionPeriodSchema = DurationSchema.refine(
|
|
727
|
-
durationMin(
|
|
778
|
+
durationMin(minutes3(1)),
|
|
728
779
|
"Minimum retention period is 1 minute"
|
|
729
780
|
).refine(durationMax(days2(14)), "Maximum retention period is 14 days").describe(
|
|
730
781
|
"The number of seconds that Amazon SQS retains a message. You can specify a duration from 1 minute to 14 days."
|
|
@@ -736,7 +787,7 @@ var VisibilityTimeoutSchema = DurationSchema.refine(
|
|
|
736
787
|
"The length of time during which a message will be unavailable after a message is delivered from the queue. This blocks other components from receiving the same message and gives the initial component time to process and delete the message from the queue. You can specify a duration from 0 to 12 hours."
|
|
737
788
|
);
|
|
738
789
|
var DeliveryDelaySchema = DurationSchema.refine(
|
|
739
|
-
durationMax(
|
|
790
|
+
durationMax(minutes3(15)),
|
|
740
791
|
"Maximum delivery delay is 15 minutes"
|
|
741
792
|
).describe(
|
|
742
793
|
"The time in seconds for which the delivery of all messages in the queue is delayed. You can specify a duration from 0 to 15 minutes."
|
|
@@ -757,7 +808,7 @@ var MaxConcurrencySchema = z13.number().int().min(2, "Minimum max concurrency is
|
|
|
757
808
|
"Limits the number of concurrent instances that the queue worker can invoke. You can specify an integer from 2 to 1000."
|
|
758
809
|
);
|
|
759
810
|
var MaxBatchingWindow = DurationSchema.refine(
|
|
760
|
-
durationMax(
|
|
811
|
+
durationMax(minutes3(5)),
|
|
761
812
|
"Maximum max batching window is 5 minutes"
|
|
762
813
|
).describe(
|
|
763
814
|
"The maximum amount of time, that Lambda spends gathering records before invoking the function. You can specify an duration from 0 seconds to 5 minutes."
|
|
@@ -1407,13 +1458,13 @@ var StackSchema = z31.object({
|
|
|
1407
1458
|
});
|
|
1408
1459
|
|
|
1409
1460
|
// src/config/load/read.ts
|
|
1410
|
-
import { basename, dirname, extname, join as
|
|
1411
|
-
import { readFile } from "fs/promises";
|
|
1461
|
+
import { basename, dirname as dirname2, extname, join as join4 } from "path";
|
|
1462
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
1412
1463
|
import JSON5 from "json5";
|
|
1413
1464
|
import merge from "deepmerge";
|
|
1414
1465
|
var readConfig = async (file) => {
|
|
1415
1466
|
try {
|
|
1416
|
-
const json4 = await
|
|
1467
|
+
const json4 = await readFile2(file, "utf8");
|
|
1417
1468
|
const data = JSON5.parse(json4);
|
|
1418
1469
|
return data;
|
|
1419
1470
|
} catch (error) {
|
|
@@ -1427,7 +1478,7 @@ var readConfigWithStage = async (file, stage) => {
|
|
|
1427
1478
|
const config2 = await readConfig(file);
|
|
1428
1479
|
const ext = extname(file);
|
|
1429
1480
|
const stageFileName = basename(file, ext) + "." + stage + ext;
|
|
1430
|
-
const stageFile =
|
|
1481
|
+
const stageFile = join4(dirname2(file), stageFileName);
|
|
1431
1482
|
const stageFileExists = await fileExist(stageFile);
|
|
1432
1483
|
if (!stageFileExists) {
|
|
1433
1484
|
return config2;
|
|
@@ -1454,7 +1505,7 @@ var validateConfig = async (schema, file, data) => {
|
|
|
1454
1505
|
// src/config/load/load.ts
|
|
1455
1506
|
var loadAppConfig = async (options) => {
|
|
1456
1507
|
debug("Find the root directory");
|
|
1457
|
-
const cwd = options.configFile ?
|
|
1508
|
+
const cwd = options.configFile ? dirname3(join5(process.cwd(), options.configFile)) : process.cwd();
|
|
1458
1509
|
const configFileOptions = options.configFile ? [basename2(options.configFile)] : ["app.json", "app.jsonc", "app.json5"];
|
|
1459
1510
|
const [appFileName, root2] = await findRootDir(cwd, configFileOptions);
|
|
1460
1511
|
setRoot(root2);
|
|
@@ -1480,8 +1531,8 @@ var loadStackConfigs = async (options) => {
|
|
|
1480
1531
|
continue;
|
|
1481
1532
|
}
|
|
1482
1533
|
debug("Load stack file:", color.info(file));
|
|
1483
|
-
const stackConfig = await readConfigWithStage(
|
|
1484
|
-
setLocalBasePath(
|
|
1534
|
+
const stackConfig = await readConfigWithStage(join5(directories.root, file), options.stage);
|
|
1535
|
+
setLocalBasePath(join5(directories.root, dirname3(file)));
|
|
1485
1536
|
const stack = await validateConfig(StackSchema, file, stackConfig);
|
|
1486
1537
|
stacks.push({
|
|
1487
1538
|
...stack,
|
|
@@ -1748,10 +1799,10 @@ var bootstrap = (program2) => {
|
|
|
1748
1799
|
};
|
|
1749
1800
|
|
|
1750
1801
|
// src/app.ts
|
|
1751
|
-
import { App, Stack } from "@awsless/formation";
|
|
1802
|
+
import { App as App2, Stack } from "@awsless/formation";
|
|
1752
1803
|
|
|
1753
1804
|
// src/feature/auth/index.ts
|
|
1754
|
-
import { aws as
|
|
1805
|
+
import { aws as aws3, Node as Node2 } from "@awsless/formation";
|
|
1755
1806
|
import { constantCase as constantCase2 } from "change-case";
|
|
1756
1807
|
|
|
1757
1808
|
// src/feature.ts
|
|
@@ -1885,14 +1936,14 @@ var formatLocalResourceName = (appName, stackName, ns, id, seperator = "--") =>
|
|
|
1885
1936
|
};
|
|
1886
1937
|
|
|
1887
1938
|
// src/feature/function/util.ts
|
|
1888
|
-
import { Asset, aws } from "@awsless/formation";
|
|
1939
|
+
import { Asset, aws as aws2 } from "@awsless/formation";
|
|
1889
1940
|
import deepmerge from "deepmerge";
|
|
1890
|
-
import { basename as basename4, dirname as
|
|
1941
|
+
import { basename as basename4, dirname as dirname7, extname as extname3 } from "path";
|
|
1891
1942
|
import { exec } from "promisify-child-process";
|
|
1892
1943
|
|
|
1893
1944
|
// src/build/index.ts
|
|
1894
|
-
import { mkdir, readFile as
|
|
1895
|
-
import { dirname as
|
|
1945
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
1946
|
+
import { dirname as dirname4, join as join6 } from "path";
|
|
1896
1947
|
|
|
1897
1948
|
// old/util/timer.ts
|
|
1898
1949
|
import hrtime from "pretty-hrtime";
|
|
@@ -1927,7 +1978,7 @@ var createTimer = () => {
|
|
|
1927
1978
|
// src/build/index.ts
|
|
1928
1979
|
var readCache = async (file) => {
|
|
1929
1980
|
try {
|
|
1930
|
-
const value = await
|
|
1981
|
+
const value = await readFile3(file, "utf8");
|
|
1931
1982
|
return JSON.parse(value);
|
|
1932
1983
|
} catch (_) {
|
|
1933
1984
|
return void 0;
|
|
@@ -1935,12 +1986,12 @@ var readCache = async (file) => {
|
|
|
1935
1986
|
};
|
|
1936
1987
|
var writeCache = async (file, version, data) => {
|
|
1937
1988
|
const cache = JSON.stringify({ version, data });
|
|
1938
|
-
const base =
|
|
1939
|
-
await
|
|
1940
|
-
await
|
|
1989
|
+
const base = dirname4(file);
|
|
1990
|
+
await mkdir2(base, { recursive: true });
|
|
1991
|
+
await writeFile2(file, cache, "utf8");
|
|
1941
1992
|
};
|
|
1942
1993
|
var getBuildPath = (type, name, file) => {
|
|
1943
|
-
return
|
|
1994
|
+
return join6(directories.build, type, name, file);
|
|
1944
1995
|
};
|
|
1945
1996
|
var build = (type, name, builder) => {
|
|
1946
1997
|
return builder(async (version, callback) => {
|
|
@@ -1955,9 +2006,9 @@ var build = (type, name, builder) => {
|
|
|
1955
2006
|
const time = createTimer();
|
|
1956
2007
|
const meta = await callback(async (file, data2) => {
|
|
1957
2008
|
const path = getBuildPath(type, name, file);
|
|
1958
|
-
const base =
|
|
1959
|
-
await
|
|
1960
|
-
await
|
|
2009
|
+
const base = dirname4(path);
|
|
2010
|
+
await mkdir2(base, { recursive: true });
|
|
2011
|
+
await writeFile2(path, data2);
|
|
1961
2012
|
});
|
|
1962
2013
|
const data = { ...meta, buildTime: time() };
|
|
1963
2014
|
await writeCache(cacheFile, version, data);
|
|
@@ -1993,7 +2044,7 @@ import { swc, minify as swcMinify } from "rollup-plugin-swc3";
|
|
|
1993
2044
|
import json from "@rollup/plugin-json";
|
|
1994
2045
|
import commonjs from "@rollup/plugin-commonjs";
|
|
1995
2046
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
1996
|
-
import { dirname as
|
|
2047
|
+
import { dirname as dirname5 } from "path";
|
|
1997
2048
|
var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file }) => {
|
|
1998
2049
|
const bundle = await rollup({
|
|
1999
2050
|
input: file,
|
|
@@ -2016,7 +2067,7 @@ var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file })
|
|
|
2016
2067
|
// minify,
|
|
2017
2068
|
// module: true,
|
|
2018
2069
|
jsc: {
|
|
2019
|
-
baseUrl:
|
|
2070
|
+
baseUrl: dirname5(file),
|
|
2020
2071
|
minify: { sourceMap: true }
|
|
2021
2072
|
},
|
|
2022
2073
|
sourceMaps: true
|
|
@@ -2062,8 +2113,8 @@ var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file })
|
|
|
2062
2113
|
|
|
2063
2114
|
// src/feature/function/build/typescript/fingerprint.ts
|
|
2064
2115
|
import { createHash as createHash2 } from "crypto";
|
|
2065
|
-
import { readFile as
|
|
2066
|
-
import { basename as basename3, dirname as
|
|
2116
|
+
import { readFile as readFile4, readdir, stat as stat3 } from "fs/promises";
|
|
2117
|
+
import { basename as basename3, dirname as dirname6, extname as extname2, join as join7 } from "path";
|
|
2067
2118
|
import parseStaticImports from "parse-static-imports";
|
|
2068
2119
|
var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
|
|
2069
2120
|
var generateFileHashes = async (file, hashes) => {
|
|
@@ -2094,17 +2145,17 @@ var readModuleFile = (file) => {
|
|
|
2094
2145
|
return readFiles([
|
|
2095
2146
|
file,
|
|
2096
2147
|
...extensions.map((exp) => `${file}.${exp}`),
|
|
2097
|
-
...extensions.map((exp) =>
|
|
2148
|
+
...extensions.map((exp) => join7(file, `/index.${exp}`))
|
|
2098
2149
|
]);
|
|
2099
2150
|
}
|
|
2100
|
-
return
|
|
2151
|
+
return readFile4(file, "utf8");
|
|
2101
2152
|
};
|
|
2102
2153
|
var readFiles = async (files) => {
|
|
2103
2154
|
for (const file of files) {
|
|
2104
2155
|
try {
|
|
2105
2156
|
const s = await stat3(file);
|
|
2106
2157
|
if (s.isFile()) {
|
|
2107
|
-
return
|
|
2158
|
+
return readFile4(file, "utf8");
|
|
2108
2159
|
}
|
|
2109
2160
|
} catch (_) {
|
|
2110
2161
|
continue;
|
|
@@ -2114,7 +2165,7 @@ var readFiles = async (files) => {
|
|
|
2114
2165
|
};
|
|
2115
2166
|
var findDependencies = async (file, code) => {
|
|
2116
2167
|
const imports = await parseStaticImports(code);
|
|
2117
|
-
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ?
|
|
2168
|
+
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join7(dirname6(file), value) : value);
|
|
2118
2169
|
};
|
|
2119
2170
|
|
|
2120
2171
|
// src/feature/function/build/zip.ts
|
|
@@ -2162,14 +2213,14 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2162
2213
|
};
|
|
2163
2214
|
});
|
|
2164
2215
|
});
|
|
2165
|
-
code = new
|
|
2216
|
+
code = new aws2.s3.BucketObject(group, "code", {
|
|
2166
2217
|
bucket: ctx.shared.get("function-bucket-name"),
|
|
2167
2218
|
key: `/lambda/${name}.zip`,
|
|
2168
2219
|
body: Asset.fromFile(getBuildPath("function", name, "bundle.zip"))
|
|
2169
2220
|
});
|
|
2170
2221
|
} else if (basename4(props.file) === "dockerfile") {
|
|
2171
2222
|
ctx.registerBuild("function", name, async (build3) => {
|
|
2172
|
-
const basePath2 =
|
|
2223
|
+
const basePath2 = dirname7(props.file);
|
|
2173
2224
|
const version = await hashElement(basePath2, {
|
|
2174
2225
|
files: {
|
|
2175
2226
|
exclude: ["stack.json"]
|
|
@@ -2190,7 +2241,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2190
2241
|
};
|
|
2191
2242
|
});
|
|
2192
2243
|
});
|
|
2193
|
-
const image = new
|
|
2244
|
+
const image = new aws2.ecr.Image(group, "image", {
|
|
2194
2245
|
repository: ctx.shared.get("function-repository-name"),
|
|
2195
2246
|
hash: Asset.fromFile(getBuildPath("function", name, "HASH")),
|
|
2196
2247
|
name,
|
|
@@ -2203,12 +2254,12 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2203
2254
|
} else {
|
|
2204
2255
|
throw new Error("Unknown Lambda Function type.");
|
|
2205
2256
|
}
|
|
2206
|
-
const role = new
|
|
2257
|
+
const role = new aws2.iam.Role(group, "role", {
|
|
2207
2258
|
name,
|
|
2208
2259
|
assumedBy: "lambda.amazonaws.com"
|
|
2209
2260
|
// policies: inlinePolicies,
|
|
2210
2261
|
});
|
|
2211
|
-
const policy = new
|
|
2262
|
+
const policy = new aws2.iam.RolePolicy(group, "policy", {
|
|
2212
2263
|
role: role.name,
|
|
2213
2264
|
name: "lambda-policy",
|
|
2214
2265
|
version: "2012-10-17"
|
|
@@ -2220,7 +2271,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2220
2271
|
// },
|
|
2221
2272
|
// ],
|
|
2222
2273
|
});
|
|
2223
|
-
const lambda = new
|
|
2274
|
+
const lambda = new aws2.lambda.Function(group, `function`, {
|
|
2224
2275
|
...props,
|
|
2225
2276
|
name,
|
|
2226
2277
|
role: role.arn,
|
|
@@ -2239,7 +2290,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2239
2290
|
lambda.addEnvironment("STACK", ctx.stackConfig.name);
|
|
2240
2291
|
}
|
|
2241
2292
|
if (props.log.retention.value > 0n) {
|
|
2242
|
-
const logGroup = new
|
|
2293
|
+
const logGroup = new aws2.cloudWatch.LogGroup(group, "log", {
|
|
2243
2294
|
name: lambda.name.apply((name2) => `/aws/lambda/${name2}`),
|
|
2244
2295
|
retention: props.log.retention
|
|
2245
2296
|
});
|
|
@@ -2261,7 +2312,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2261
2312
|
policy.addStatement(...local2.permissions);
|
|
2262
2313
|
}
|
|
2263
2314
|
if (props.warm) {
|
|
2264
|
-
const rule = new
|
|
2315
|
+
const rule = new aws2.events.Rule(group, "warm", {
|
|
2265
2316
|
name: `${name}--warm`,
|
|
2266
2317
|
schedule: "rate(5 minutes)",
|
|
2267
2318
|
enabled: true,
|
|
@@ -2276,7 +2327,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2276
2327
|
}
|
|
2277
2328
|
]
|
|
2278
2329
|
});
|
|
2279
|
-
new
|
|
2330
|
+
new aws2.lambda.Permission(group, `warm`, {
|
|
2280
2331
|
action: "lambda:InvokeFunction",
|
|
2281
2332
|
principal: "events.amazonaws.com",
|
|
2282
2333
|
functionArn: lambda.arn,
|
|
@@ -2291,7 +2342,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2291
2342
|
ctx.shared.get(`vpc-public-subnet-id-2`)
|
|
2292
2343
|
]
|
|
2293
2344
|
});
|
|
2294
|
-
const vpcPolicy = new
|
|
2345
|
+
const vpcPolicy = new aws2.iam.RolePolicy(group, "vpc-policy", {
|
|
2295
2346
|
role: role.name,
|
|
2296
2347
|
name: "lambda-vpc-policy",
|
|
2297
2348
|
version: "2012-10-17",
|
|
@@ -2320,7 +2371,7 @@ var createAsyncLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2320
2371
|
const result = createLambdaFunction(group, ctx, ns, id, local2);
|
|
2321
2372
|
const props = deepmerge(ctx.appConfig.defaults.function, local2);
|
|
2322
2373
|
result.lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
2323
|
-
const invokeConfig = new
|
|
2374
|
+
const invokeConfig = new aws2.lambda.EventInvokeConfig(group, "async", {
|
|
2324
2375
|
functionArn: result.lambda.arn,
|
|
2325
2376
|
retryAttempts: props.retryAttempts,
|
|
2326
2377
|
onFailure: getGlobalOnFailure(ctx)
|
|
@@ -2372,12 +2423,12 @@ var authFeature = defineFeature({
|
|
|
2372
2423
|
policy
|
|
2373
2424
|
};
|
|
2374
2425
|
}
|
|
2375
|
-
new
|
|
2426
|
+
new aws3.cognito.LambdaTriggers(group, "lambda-triggers", {
|
|
2376
2427
|
userPoolId,
|
|
2377
2428
|
triggers
|
|
2378
2429
|
});
|
|
2379
2430
|
for (const item of Object.values(list4)) {
|
|
2380
|
-
new
|
|
2431
|
+
new aws3.lambda.Permission(item.group, `permission`, {
|
|
2381
2432
|
action: "lambda:InvokeFunction",
|
|
2382
2433
|
principal: "cognito-idp.amazonaws.com",
|
|
2383
2434
|
functionArn: item.lambda.arn,
|
|
@@ -2416,7 +2467,7 @@ var authFeature = defineFeature({
|
|
|
2416
2467
|
};
|
|
2417
2468
|
}
|
|
2418
2469
|
const name = formatGlobalResourceName(ctx.appConfig.name, "auth", id);
|
|
2419
|
-
const userPool = new
|
|
2470
|
+
const userPool = new aws3.cognito.UserPool(group, "user-pool", {
|
|
2420
2471
|
name,
|
|
2421
2472
|
// deletionProtection: true,
|
|
2422
2473
|
allowUserRegistration: props.allowUserRegistration,
|
|
@@ -2424,7 +2475,7 @@ var authFeature = defineFeature({
|
|
|
2424
2475
|
password: props.password,
|
|
2425
2476
|
email: emailConfig
|
|
2426
2477
|
});
|
|
2427
|
-
const client = new
|
|
2478
|
+
const client = new aws3.cognito.UserPoolClient(group, "client", {
|
|
2428
2479
|
userPoolId: userPool.id,
|
|
2429
2480
|
name,
|
|
2430
2481
|
validity: props.validity,
|
|
@@ -2443,7 +2494,7 @@ var authFeature = defineFeature({
|
|
|
2443
2494
|
});
|
|
2444
2495
|
|
|
2445
2496
|
// src/feature/cache/index.ts
|
|
2446
|
-
import { aws as
|
|
2497
|
+
import { aws as aws4, Node as Node3 } from "@awsless/formation";
|
|
2447
2498
|
import { constantCase as constantCase3 } from "change-case";
|
|
2448
2499
|
var typeGenCode = `
|
|
2449
2500
|
import { Cluster, CommandOptions } from '@awsless/redis'
|
|
@@ -2476,7 +2527,7 @@ var cacheFeature = defineFeature({
|
|
|
2476
2527
|
for (const [id, props] of Object.entries(ctx.stackConfig.caches ?? {})) {
|
|
2477
2528
|
const group = new Node3(ctx.stack, this.name, id);
|
|
2478
2529
|
const name = formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, this.name, id, "-");
|
|
2479
|
-
const subnetGroup = new
|
|
2530
|
+
const subnetGroup = new aws4.memorydb.SubnetGroup(group, "subnets", {
|
|
2480
2531
|
name,
|
|
2481
2532
|
subnetIds: [
|
|
2482
2533
|
//
|
|
@@ -2484,15 +2535,15 @@ var cacheFeature = defineFeature({
|
|
|
2484
2535
|
ctx.shared.get("vpc-private-subnet-id-2")
|
|
2485
2536
|
]
|
|
2486
2537
|
});
|
|
2487
|
-
const securityGroup = new
|
|
2538
|
+
const securityGroup = new aws4.ec2.SecurityGroup(group, "security", {
|
|
2488
2539
|
name,
|
|
2489
2540
|
vpcId: ctx.shared.get(`vpc-id`),
|
|
2490
2541
|
description: name
|
|
2491
2542
|
});
|
|
2492
|
-
const port =
|
|
2493
|
-
securityGroup.addIngressRule({ port, peer:
|
|
2494
|
-
securityGroup.addIngressRule({ port, peer:
|
|
2495
|
-
const cluster = new
|
|
2543
|
+
const port = aws4.ec2.Port.tcp(props.port);
|
|
2544
|
+
securityGroup.addIngressRule({ port, peer: aws4.ec2.Peer.anyIpv4() });
|
|
2545
|
+
securityGroup.addIngressRule({ port, peer: aws4.ec2.Peer.anyIpv6() });
|
|
2546
|
+
const cluster = new aws4.memorydb.Cluster(group, "cluster", {
|
|
2496
2547
|
name,
|
|
2497
2548
|
aclName: "open-access",
|
|
2498
2549
|
securityGroupIds: [securityGroup.id],
|
|
@@ -2649,14 +2700,14 @@ var configFeature = defineFeature({
|
|
|
2649
2700
|
});
|
|
2650
2701
|
|
|
2651
2702
|
// src/feature/cron/index.ts
|
|
2652
|
-
import { Node as Node4, aws as
|
|
2703
|
+
import { Node as Node4, aws as aws5 } from "@awsless/formation";
|
|
2653
2704
|
var cronFeature = defineFeature({
|
|
2654
2705
|
name: "cron",
|
|
2655
2706
|
onStack(ctx) {
|
|
2656
2707
|
for (const [id, props] of Object.entries(ctx.stackConfig.crons ?? {})) {
|
|
2657
2708
|
const group = new Node4(ctx.stack, "cron", id);
|
|
2658
2709
|
const { lambda } = createAsyncLambdaFunction(group, ctx, "cron", id, props.consumer);
|
|
2659
|
-
const rule = new
|
|
2710
|
+
const rule = new aws5.events.Rule(group, "rule", {
|
|
2660
2711
|
name: formatLocalResourceName(ctx.app.name, ctx.stack.name, this.name, id),
|
|
2661
2712
|
schedule: props.schedule,
|
|
2662
2713
|
enabled: props.enabled,
|
|
@@ -2668,7 +2719,7 @@ var cronFeature = defineFeature({
|
|
|
2668
2719
|
}
|
|
2669
2720
|
]
|
|
2670
2721
|
});
|
|
2671
|
-
new
|
|
2722
|
+
new aws5.lambda.Permission(group, "permission", {
|
|
2672
2723
|
action: "lambda:InvokeFunction",
|
|
2673
2724
|
principal: "events.amazonaws.com",
|
|
2674
2725
|
functionArn: lambda.arn,
|
|
@@ -2679,8 +2730,8 @@ var cronFeature = defineFeature({
|
|
|
2679
2730
|
});
|
|
2680
2731
|
|
|
2681
2732
|
// src/feature/domain/index.ts
|
|
2682
|
-
import { minutes as
|
|
2683
|
-
import { aws as
|
|
2733
|
+
import { minutes as minutes4 } from "@awsless/duration";
|
|
2734
|
+
import { aws as aws6, Node as Node5 } from "@awsless/formation";
|
|
2684
2735
|
var domainFeature = defineFeature({
|
|
2685
2736
|
name: "domain",
|
|
2686
2737
|
onApp(ctx) {
|
|
@@ -2689,7 +2740,7 @@ var domainFeature = defineFeature({
|
|
|
2689
2740
|
return;
|
|
2690
2741
|
}
|
|
2691
2742
|
const group = new Node5(ctx.base, "domain", "mail");
|
|
2692
|
-
const configurationSet = new
|
|
2743
|
+
const configurationSet = new aws6.ses.ConfigurationSet(group, "config", {
|
|
2693
2744
|
name: ctx.app.name,
|
|
2694
2745
|
engagementMetrics: true,
|
|
2695
2746
|
reputationMetrics: true
|
|
@@ -2697,29 +2748,29 @@ var domainFeature = defineFeature({
|
|
|
2697
2748
|
ctx.shared.set(`mail-configuration-set`, configurationSet.name);
|
|
2698
2749
|
for (const [id, props] of domains) {
|
|
2699
2750
|
const group2 = new Node5(ctx.base, "domain", id);
|
|
2700
|
-
const hostedZone = new
|
|
2751
|
+
const hostedZone = new aws6.route53.HostedZone(group2, "zone", {
|
|
2701
2752
|
name: props.domain
|
|
2702
2753
|
});
|
|
2703
2754
|
ctx.shared.set(`hosted-zone-${id}-id`, hostedZone.id);
|
|
2704
|
-
const certificate = new
|
|
2755
|
+
const certificate = new aws6.acm.Certificate(group2, "local", {
|
|
2705
2756
|
domainName: props.domain,
|
|
2706
2757
|
alternativeNames: [`*.${props.domain}`]
|
|
2707
2758
|
});
|
|
2708
2759
|
hostedZone.addRecord("local-cert-1", certificate.validationRecord(0));
|
|
2709
2760
|
hostedZone.addRecord("local-cert-2", certificate.validationRecord(1));
|
|
2710
|
-
const validation = new
|
|
2761
|
+
const validation = new aws6.acm.CertificateValidation(group2, "local", {
|
|
2711
2762
|
certificateArn: certificate.arn
|
|
2712
2763
|
});
|
|
2713
2764
|
ctx.shared.set(`local-certificate-${id}-arn`, validation.arn);
|
|
2714
2765
|
if (ctx.appConfig.region !== "us-east-1") {
|
|
2715
|
-
const globalCertificate = new
|
|
2766
|
+
const globalCertificate = new aws6.acm.Certificate(group2, "global", {
|
|
2716
2767
|
domainName: props.domain,
|
|
2717
2768
|
alternativeNames: [`*.${props.domain}`],
|
|
2718
2769
|
region: "us-east-1"
|
|
2719
2770
|
});
|
|
2720
2771
|
hostedZone.addRecord("global-cert-1", globalCertificate.validationRecord(0));
|
|
2721
2772
|
hostedZone.addRecord("global-cert-2", globalCertificate.validationRecord(1));
|
|
2722
|
-
const globalValidation = new
|
|
2773
|
+
const globalValidation = new aws6.acm.CertificateValidation(group2, "global", {
|
|
2723
2774
|
certificateArn: globalCertificate.arn,
|
|
2724
2775
|
region: "us-east-1"
|
|
2725
2776
|
});
|
|
@@ -2727,7 +2778,7 @@ var domainFeature = defineFeature({
|
|
|
2727
2778
|
} else {
|
|
2728
2779
|
ctx.shared.set(`global-certificate-${id}-arn`, validation.arn);
|
|
2729
2780
|
}
|
|
2730
|
-
const emailIdentity = new
|
|
2781
|
+
const emailIdentity = new aws6.ses.EmailIdentity(group2, "mail", {
|
|
2731
2782
|
emailIdentity: props.domain,
|
|
2732
2783
|
mailFromDomain: `mail.${props.domain}`,
|
|
2733
2784
|
configurationSetName: configurationSet.name,
|
|
@@ -2736,30 +2787,30 @@ var domainFeature = defineFeature({
|
|
|
2736
2787
|
});
|
|
2737
2788
|
let i = 0;
|
|
2738
2789
|
for (const record of emailIdentity.dkimRecords) {
|
|
2739
|
-
new
|
|
2790
|
+
new aws6.route53.RecordSet(group2, `dkim-${++i}`, {
|
|
2740
2791
|
hostedZoneId: hostedZone.id,
|
|
2741
2792
|
...record
|
|
2742
2793
|
});
|
|
2743
2794
|
}
|
|
2744
|
-
new
|
|
2795
|
+
new aws6.route53.RecordSet(group2, `MX`, {
|
|
2745
2796
|
hostedZoneId: hostedZone.id,
|
|
2746
2797
|
name: `mail.${props.domain}`,
|
|
2747
2798
|
type: "MX",
|
|
2748
|
-
ttl:
|
|
2799
|
+
ttl: minutes4(5),
|
|
2749
2800
|
records: [`10 feedback-smtp.${ctx.appConfig.region}.amazonses.com`]
|
|
2750
2801
|
});
|
|
2751
|
-
new
|
|
2802
|
+
new aws6.route53.RecordSet(group2, `SPF`, {
|
|
2752
2803
|
hostedZoneId: hostedZone.id,
|
|
2753
2804
|
name: `mail.${props.domain}`,
|
|
2754
2805
|
type: "TXT",
|
|
2755
|
-
ttl:
|
|
2806
|
+
ttl: minutes4(5),
|
|
2756
2807
|
records: ['"v=spf1 include:amazonses.com -all"']
|
|
2757
2808
|
});
|
|
2758
|
-
new
|
|
2809
|
+
new aws6.route53.RecordSet(group2, `DMARC`, {
|
|
2759
2810
|
hostedZoneId: hostedZone.id,
|
|
2760
2811
|
name: `_dmarc.${props.domain}`,
|
|
2761
2812
|
type: "TXT",
|
|
2762
|
-
ttl:
|
|
2813
|
+
ttl: minutes4(5),
|
|
2763
2814
|
records: ['"v=DMARC1; p=none;"']
|
|
2764
2815
|
});
|
|
2765
2816
|
const mailIdentityArn = emailIdentity.output(() => {
|
|
@@ -2769,7 +2820,7 @@ var domainFeature = defineFeature({
|
|
|
2769
2820
|
ctx.shared.set(`mail-${props.domain}-arn`, mailIdentityArn);
|
|
2770
2821
|
for (const record of props.dns ?? []) {
|
|
2771
2822
|
const name = record.name ?? props.domain;
|
|
2772
|
-
new
|
|
2823
|
+
new aws6.route53.RecordSet(group2, `${name}-${record.type}`, {
|
|
2773
2824
|
hostedZoneId: hostedZone.id,
|
|
2774
2825
|
name,
|
|
2775
2826
|
...record
|
|
@@ -2786,7 +2837,7 @@ var domainFeature = defineFeature({
|
|
|
2786
2837
|
});
|
|
2787
2838
|
|
|
2788
2839
|
// src/feature/function/index.ts
|
|
2789
|
-
import { aws as
|
|
2840
|
+
import { aws as aws7, Node as Node6 } from "@awsless/formation";
|
|
2790
2841
|
import { camelCase as camelCase3 } from "change-case";
|
|
2791
2842
|
import { relative } from "path";
|
|
2792
2843
|
var typeGenCode2 = `
|
|
@@ -2840,13 +2891,13 @@ var functionFeature = defineFeature({
|
|
|
2840
2891
|
},
|
|
2841
2892
|
onApp(ctx) {
|
|
2842
2893
|
const group = new Node6(ctx.base, "function", "asset");
|
|
2843
|
-
const bucket = new
|
|
2894
|
+
const bucket = new aws7.s3.Bucket(group, "bucket", {
|
|
2844
2895
|
name: formatGlobalResourceName(ctx.appConfig.name, "function", "assets"),
|
|
2845
2896
|
versioning: true,
|
|
2846
2897
|
forceDelete: true
|
|
2847
2898
|
});
|
|
2848
2899
|
ctx.shared.set("function-bucket-name", bucket.name);
|
|
2849
|
-
const repository = new
|
|
2900
|
+
const repository = new aws7.ecr.Repository(group, "repository", {
|
|
2850
2901
|
name: formatGlobalResourceName(ctx.appConfig.name, "function", "repository", "-"),
|
|
2851
2902
|
imageTagMutability: true
|
|
2852
2903
|
});
|
|
@@ -2871,15 +2922,15 @@ var functionFeature = defineFeature({
|
|
|
2871
2922
|
import { constantCase as constantCase4, paramCase as paramCase5 } from "change-case";
|
|
2872
2923
|
import { generate } from "@awsless/graphql";
|
|
2873
2924
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
2874
|
-
import { readFile as
|
|
2925
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
2875
2926
|
import { buildSchema, print } from "graphql";
|
|
2876
|
-
import { Asset as Asset2, aws as
|
|
2927
|
+
import { Asset as Asset2, aws as aws8, Node as Node7 } from "@awsless/formation";
|
|
2877
2928
|
import { createHash as createHash5 } from "crypto";
|
|
2878
2929
|
|
|
2879
2930
|
// src/build/fingerprint.ts
|
|
2880
2931
|
import { createHash as createHash3 } from "crypto";
|
|
2881
|
-
import { readFile as
|
|
2882
|
-
import { basename as basename5, dirname as
|
|
2932
|
+
import { readFile as readFile5, readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
2933
|
+
import { basename as basename5, dirname as dirname8, extname as extname4, join as join8 } from "path";
|
|
2883
2934
|
import parseStaticImports2 from "parse-static-imports";
|
|
2884
2935
|
var extensions2 = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
|
|
2885
2936
|
var generateFileHashes2 = async (file, hashes) => {
|
|
@@ -2907,7 +2958,7 @@ var fingerprintFromDirectory = async (dir) => {
|
|
|
2907
2958
|
const files = await readdir2(dir, { recursive: true });
|
|
2908
2959
|
for (const file of files) {
|
|
2909
2960
|
if (extensions2.includes(extname4(file).substring(1)) && file.at(0) !== "_") {
|
|
2910
|
-
await generateFileHashes2(
|
|
2961
|
+
await generateFileHashes2(join8(dir, file), hashes);
|
|
2911
2962
|
}
|
|
2912
2963
|
}
|
|
2913
2964
|
const merge2 = Buffer.concat(Array.from(hashes.values()).sort());
|
|
@@ -2921,17 +2972,17 @@ var readModuleFile2 = (file) => {
|
|
|
2921
2972
|
return readFiles2([
|
|
2922
2973
|
file,
|
|
2923
2974
|
...extensions2.map((exp) => `${file}.${exp}`),
|
|
2924
|
-
...extensions2.map((exp) =>
|
|
2975
|
+
...extensions2.map((exp) => join8(file, `/index.${exp}`))
|
|
2925
2976
|
]);
|
|
2926
2977
|
}
|
|
2927
|
-
return
|
|
2978
|
+
return readFile5(file, "utf8");
|
|
2928
2979
|
};
|
|
2929
2980
|
var readFiles2 = async (files) => {
|
|
2930
2981
|
for (const file of files) {
|
|
2931
2982
|
try {
|
|
2932
2983
|
const s = await stat4(file);
|
|
2933
2984
|
if (s.isFile()) {
|
|
2934
|
-
return
|
|
2985
|
+
return readFile5(file, "utf8");
|
|
2935
2986
|
}
|
|
2936
2987
|
} catch (_) {
|
|
2937
2988
|
continue;
|
|
@@ -2941,7 +2992,7 @@ var readFiles2 = async (files) => {
|
|
|
2941
2992
|
};
|
|
2942
2993
|
var findDependencies2 = async (file, code) => {
|
|
2943
2994
|
const imports = await parseStaticImports2(code);
|
|
2944
|
-
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ?
|
|
2995
|
+
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join8(dirname8(file), value) : value);
|
|
2945
2996
|
};
|
|
2946
2997
|
|
|
2947
2998
|
// src/util/id.ts
|
|
@@ -2974,7 +3025,7 @@ import { swc as swc2, minify as swcMinify2 } from "rollup-plugin-swc3";
|
|
|
2974
3025
|
import json2 from "@rollup/plugin-json";
|
|
2975
3026
|
import commonjs2 from "@rollup/plugin-commonjs";
|
|
2976
3027
|
import nodeResolve2 from "@rollup/plugin-node-resolve";
|
|
2977
|
-
import { dirname as
|
|
3028
|
+
import { dirname as dirname9 } from "path";
|
|
2978
3029
|
var buildTypeScriptResolver = async (input, { minify = true } = {}) => {
|
|
2979
3030
|
const bundle = await rollup2({
|
|
2980
3031
|
input,
|
|
@@ -2996,7 +3047,7 @@ var buildTypeScriptResolver = async (input, { minify = true } = {}) => {
|
|
|
2996
3047
|
// minify,
|
|
2997
3048
|
// module: true,
|
|
2998
3049
|
jsc: {
|
|
2999
|
-
baseUrl:
|
|
3050
|
+
baseUrl: dirname9(input),
|
|
3000
3051
|
minify: { sourceMap: true }
|
|
3001
3052
|
},
|
|
3002
3053
|
sourceMaps: true
|
|
@@ -3081,7 +3132,7 @@ var graphqlFeature = defineFeature({
|
|
|
3081
3132
|
for (const [id, files] of apis) {
|
|
3082
3133
|
const sources = await Promise.all(
|
|
3083
3134
|
files.map((file) => {
|
|
3084
|
-
return
|
|
3135
|
+
return readFile6(file, "utf8");
|
|
3085
3136
|
})
|
|
3086
3137
|
);
|
|
3087
3138
|
if (sources.length) {
|
|
@@ -3119,7 +3170,7 @@ var graphqlFeature = defineFeature({
|
|
|
3119
3170
|
authorizer = lambda;
|
|
3120
3171
|
}
|
|
3121
3172
|
const name = formatGlobalResourceName(ctx.app.name, "graphql", id);
|
|
3122
|
-
const api = new
|
|
3173
|
+
const api = new aws8.appsync.GraphQLApi(group, "api", {
|
|
3123
3174
|
name,
|
|
3124
3175
|
type: "graphql",
|
|
3125
3176
|
auth: {
|
|
@@ -3137,7 +3188,7 @@ var graphqlFeature = defineFeature({
|
|
|
3137
3188
|
}
|
|
3138
3189
|
});
|
|
3139
3190
|
if (typeof props.auth === "object") {
|
|
3140
|
-
new
|
|
3191
|
+
new aws8.lambda.Permission(group, "authorizer", {
|
|
3141
3192
|
functionArn: authorizer.arn,
|
|
3142
3193
|
principal: "appsync.amazonaws.com",
|
|
3143
3194
|
action: "lambda:InvokeFunction"
|
|
@@ -3150,7 +3201,7 @@ var graphqlFeature = defineFeature({
|
|
|
3150
3201
|
for (const stack of ctx.stackConfigs) {
|
|
3151
3202
|
const file = stack.graphql?.[id]?.schema;
|
|
3152
3203
|
if (file) {
|
|
3153
|
-
const source = await
|
|
3204
|
+
const source = await readFile6(file, "utf8");
|
|
3154
3205
|
const finger2 = createHash5("sha1").update(source).digest("hex");
|
|
3155
3206
|
sources.push(source);
|
|
3156
3207
|
fingers.push(finger2);
|
|
@@ -3166,7 +3217,7 @@ var graphqlFeature = defineFeature({
|
|
|
3166
3217
|
};
|
|
3167
3218
|
});
|
|
3168
3219
|
});
|
|
3169
|
-
new
|
|
3220
|
+
new aws8.appsync.GraphQLSchema(group, "schema", {
|
|
3170
3221
|
apiId: api.id,
|
|
3171
3222
|
definition: Asset2.fromFile(getBuildPath("graphql-schema", name, "schema.gql"))
|
|
3172
3223
|
});
|
|
@@ -3189,15 +3240,15 @@ var graphqlFeature = defineFeature({
|
|
|
3189
3240
|
if (props.domain) {
|
|
3190
3241
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
3191
3242
|
const domainGroup = new Node7(group, "domain", domainName);
|
|
3192
|
-
const domain = new
|
|
3243
|
+
const domain = new aws8.appsync.DomainName(domainGroup, "domain", {
|
|
3193
3244
|
domainName,
|
|
3194
3245
|
certificateArn: ctx.shared.get(`global-certificate-${props.domain}-arn`)
|
|
3195
3246
|
});
|
|
3196
|
-
new
|
|
3247
|
+
new aws8.appsync.DomainNameApiAssociation(domainGroup, "association", {
|
|
3197
3248
|
apiId: api.id,
|
|
3198
3249
|
domainName: domain.domainName
|
|
3199
3250
|
});
|
|
3200
|
-
new
|
|
3251
|
+
new aws8.route53.RecordSet(domainGroup, "record", {
|
|
3201
3252
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
3202
3253
|
type: "A",
|
|
3203
3254
|
name: domainName,
|
|
@@ -3230,7 +3281,7 @@ var graphqlFeature = defineFeature({
|
|
|
3230
3281
|
...props2.consumer,
|
|
3231
3282
|
description: `${id} ${typeName}.${fieldName}`
|
|
3232
3283
|
});
|
|
3233
|
-
const role = new
|
|
3284
|
+
const role = new aws8.iam.Role(resolverGroup, "source-role", {
|
|
3234
3285
|
assumedBy: "appsync.amazonaws.com",
|
|
3235
3286
|
policies: [
|
|
3236
3287
|
{
|
|
@@ -3244,7 +3295,7 @@ var graphqlFeature = defineFeature({
|
|
|
3244
3295
|
}
|
|
3245
3296
|
]
|
|
3246
3297
|
});
|
|
3247
|
-
const source = new
|
|
3298
|
+
const source = new aws8.appsync.DataSource(resolverGroup, "source", {
|
|
3248
3299
|
apiId,
|
|
3249
3300
|
name,
|
|
3250
3301
|
role: role.arn,
|
|
@@ -3257,13 +3308,13 @@ var graphqlFeature = defineFeature({
|
|
|
3257
3308
|
} else if (defaultProps.resolver) {
|
|
3258
3309
|
code = Asset2.fromFile(getBuildPath("graphql-resolver", id, "resolver.js"));
|
|
3259
3310
|
}
|
|
3260
|
-
const config2 = new
|
|
3311
|
+
const config2 = new aws8.appsync.FunctionConfiguration(resolverGroup, "config", {
|
|
3261
3312
|
apiId,
|
|
3262
3313
|
name,
|
|
3263
3314
|
code,
|
|
3264
3315
|
dataSourceName: source.name
|
|
3265
3316
|
});
|
|
3266
|
-
new
|
|
3317
|
+
new aws8.appsync.Resolver(resolverGroup, "resolver", {
|
|
3267
3318
|
apiId,
|
|
3268
3319
|
typeName,
|
|
3269
3320
|
fieldName,
|
|
@@ -3277,7 +3328,7 @@ var graphqlFeature = defineFeature({
|
|
|
3277
3328
|
});
|
|
3278
3329
|
|
|
3279
3330
|
// src/feature/http/index.ts
|
|
3280
|
-
import { aws as
|
|
3331
|
+
import { aws as aws9, Node as Node8 } from "@awsless/formation";
|
|
3281
3332
|
import { camelCase as camelCase4, constantCase as constantCase5 } from "change-case";
|
|
3282
3333
|
import { relative as relative2 } from "path";
|
|
3283
3334
|
var parseRoute = (route) => {
|
|
@@ -3353,17 +3404,17 @@ var httpFeature = defineFeature({
|
|
|
3353
3404
|
return;
|
|
3354
3405
|
}
|
|
3355
3406
|
const group = new Node8(ctx.base, "http", "main");
|
|
3356
|
-
const securityGroup = new
|
|
3407
|
+
const securityGroup = new aws9.ec2.SecurityGroup(group, "http", {
|
|
3357
3408
|
vpcId: ctx.shared.get(`vpc-id`),
|
|
3358
3409
|
name: formatGlobalResourceName(ctx.app.name, "http", "http"),
|
|
3359
3410
|
description: `Global security group for HTTP api.`
|
|
3360
3411
|
});
|
|
3361
|
-
const port =
|
|
3362
|
-
securityGroup.addIngressRule({ port, peer:
|
|
3363
|
-
securityGroup.addIngressRule({ port, peer:
|
|
3412
|
+
const port = aws9.ec2.Port.tcp(443);
|
|
3413
|
+
securityGroup.addIngressRule({ port, peer: aws9.ec2.Peer.anyIpv4() });
|
|
3414
|
+
securityGroup.addIngressRule({ port, peer: aws9.ec2.Peer.anyIpv6() });
|
|
3364
3415
|
for (const [id, props] of Object.entries(ctx.appConfig.defaults?.http ?? {})) {
|
|
3365
3416
|
const group2 = new Node8(ctx.base, "http", id);
|
|
3366
|
-
const loadBalancer = new
|
|
3417
|
+
const loadBalancer = new aws9.elb.LoadBalancer(group2, "balancer", {
|
|
3367
3418
|
name: formatGlobalResourceName(ctx.app.name, "http", id),
|
|
3368
3419
|
type: "application",
|
|
3369
3420
|
securityGroups: [securityGroup.id],
|
|
@@ -3373,13 +3424,13 @@ var httpFeature = defineFeature({
|
|
|
3373
3424
|
ctx.shared.get(`vpc-public-subnet-id-2`)
|
|
3374
3425
|
]
|
|
3375
3426
|
});
|
|
3376
|
-
const listener = new
|
|
3427
|
+
const listener = new aws9.elb.Listener(group2, "listener", {
|
|
3377
3428
|
loadBalancerArn: loadBalancer.arn,
|
|
3378
3429
|
port: 443,
|
|
3379
3430
|
protocol: "https",
|
|
3380
3431
|
certificates: [ctx.shared.get(`local-certificate-${props.domain}-arn`)],
|
|
3381
3432
|
defaultActions: [
|
|
3382
|
-
|
|
3433
|
+
aws9.elb.ListenerAction.fixedResponse({
|
|
3383
3434
|
statusCode: 404,
|
|
3384
3435
|
contentType: "application/json",
|
|
3385
3436
|
messageBody: JSON.stringify({
|
|
@@ -3390,7 +3441,7 @@ var httpFeature = defineFeature({
|
|
|
3390
3441
|
});
|
|
3391
3442
|
ctx.shared.set(`http-${id}-listener-arn`, listener.arn);
|
|
3392
3443
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
3393
|
-
new
|
|
3444
|
+
new aws9.route53.RecordSet(group2, domainName, {
|
|
3394
3445
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
3395
3446
|
name: domainName,
|
|
3396
3447
|
type: "A",
|
|
@@ -3419,25 +3470,25 @@ var httpFeature = defineFeature({
|
|
|
3419
3470
|
description: routeKey
|
|
3420
3471
|
});
|
|
3421
3472
|
const name = formatLocalResourceName(ctx.app.name, ctx.stack.name, "http", routeId);
|
|
3422
|
-
const permission = new
|
|
3473
|
+
const permission = new aws9.lambda.Permission(routeGroup, id, {
|
|
3423
3474
|
action: "lambda:InvokeFunction",
|
|
3424
3475
|
principal: "elasticloadbalancing.amazonaws.com",
|
|
3425
3476
|
functionArn: lambda.arn
|
|
3426
3477
|
// sourceArn: `arn:aws:elasticloadbalancing:${ctx.appConfig.region}:*:targetgroup/${name}/*`,
|
|
3427
3478
|
});
|
|
3428
|
-
const target = new
|
|
3479
|
+
const target = new aws9.elb.TargetGroup(routeGroup, id, {
|
|
3429
3480
|
name,
|
|
3430
3481
|
type: "lambda",
|
|
3431
3482
|
targets: [lambda.arn]
|
|
3432
3483
|
}).dependsOn(permission);
|
|
3433
|
-
new
|
|
3484
|
+
new aws9.elb.ListenerRule(routeGroup, id, {
|
|
3434
3485
|
listenerArn: ctx.shared.get(`http-${id}-listener-arn`),
|
|
3435
3486
|
priority: generatePriority(ctx.stackConfig.name, routeKey),
|
|
3436
3487
|
conditions: [
|
|
3437
|
-
|
|
3438
|
-
|
|
3488
|
+
aws9.elb.ListenerCondition.httpRequestMethods([method]),
|
|
3489
|
+
aws9.elb.ListenerCondition.pathPatterns([path])
|
|
3439
3490
|
],
|
|
3440
|
-
actions: [
|
|
3491
|
+
actions: [aws9.elb.ListenerAction.forward([target.arn])]
|
|
3441
3492
|
}).dependsOn(target);
|
|
3442
3493
|
}
|
|
3443
3494
|
}
|
|
@@ -3446,22 +3497,22 @@ var httpFeature = defineFeature({
|
|
|
3446
3497
|
|
|
3447
3498
|
// src/feature/instance/index.ts
|
|
3448
3499
|
import { days as days3 } from "@awsless/duration";
|
|
3449
|
-
import { Asset as Asset3, aws as
|
|
3500
|
+
import { Asset as Asset3, aws as aws10, combine, Node as Node9, Output as Output2, unwrap } from "@awsless/formation";
|
|
3450
3501
|
import { hashElement as hashElement2 } from "folder-hash";
|
|
3451
|
-
import { mkdir as
|
|
3452
|
-
import { dirname as
|
|
3502
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
3503
|
+
import { dirname as dirname10 } from "path";
|
|
3453
3504
|
import { zip } from "zip-a-folder";
|
|
3454
3505
|
var instanceFeature = defineFeature({
|
|
3455
3506
|
name: "instance",
|
|
3456
3507
|
onApp(ctx) {
|
|
3457
3508
|
const group = new Node9(ctx.base, "instance", "asset");
|
|
3458
|
-
const bucket = new
|
|
3509
|
+
const bucket = new aws10.s3.Bucket(group, "bucket", {
|
|
3459
3510
|
name: formatGlobalResourceName(ctx.appConfig.name, "instance", "assets"),
|
|
3460
3511
|
forceDelete: true
|
|
3461
3512
|
});
|
|
3462
3513
|
ctx.shared.set("instance-bucket-name", bucket.name);
|
|
3463
3514
|
if (ctx.appConfig.defaults.instance.connect) {
|
|
3464
|
-
new
|
|
3515
|
+
new aws10.ec2.InstanceConnectEndpoint(group, "connect", {
|
|
3465
3516
|
name: ctx.appConfig.name,
|
|
3466
3517
|
subnetId: ctx.shared.get(`vpc-public-subnet-id-1`),
|
|
3467
3518
|
securityGroupIds: [ctx.shared.get("vpc-security-group-id")]
|
|
@@ -3517,16 +3568,16 @@ var instanceFeature = defineFeature({
|
|
|
3517
3568
|
}
|
|
3518
3569
|
});
|
|
3519
3570
|
await build3(version.hash, async () => {
|
|
3520
|
-
await
|
|
3571
|
+
await mkdir3(dirname10(bundleFile), { recursive: true });
|
|
3521
3572
|
await zip(props.code, bundleFile);
|
|
3522
3573
|
});
|
|
3523
3574
|
});
|
|
3524
|
-
const code = new
|
|
3575
|
+
const code = new aws10.s3.BucketObject(group, "code", {
|
|
3525
3576
|
key: name,
|
|
3526
3577
|
bucket: bucketName,
|
|
3527
3578
|
body: Asset3.fromFile(bundleFile)
|
|
3528
3579
|
});
|
|
3529
|
-
const template = new
|
|
3580
|
+
const template = new aws10.ec2.LaunchTemplate(group, "template", {
|
|
3530
3581
|
name,
|
|
3531
3582
|
imageId: props.image,
|
|
3532
3583
|
instanceType: props.type,
|
|
@@ -3534,11 +3585,11 @@ var instanceFeature = defineFeature({
|
|
|
3534
3585
|
monitoring: true,
|
|
3535
3586
|
userData
|
|
3536
3587
|
});
|
|
3537
|
-
const role = new
|
|
3588
|
+
const role = new aws10.iam.Role(group, "role", {
|
|
3538
3589
|
name,
|
|
3539
3590
|
assumedBy: "ec2.amazonaws.com"
|
|
3540
3591
|
});
|
|
3541
|
-
const policy = new
|
|
3592
|
+
const policy = new aws10.iam.RolePolicy(group, "policy", {
|
|
3542
3593
|
name,
|
|
3543
3594
|
role: role.name
|
|
3544
3595
|
});
|
|
@@ -3547,18 +3598,18 @@ var instanceFeature = defineFeature({
|
|
|
3547
3598
|
resources: [bucketName.apply((bucket) => `arn:aws:s3:::${bucket}/${name}`)]
|
|
3548
3599
|
});
|
|
3549
3600
|
ctx.registerPolicy(policy);
|
|
3550
|
-
const profile = new
|
|
3601
|
+
const profile = new aws10.iam.InstanceProfile(group, "profile", {
|
|
3551
3602
|
name,
|
|
3552
3603
|
roles: [role.name]
|
|
3553
3604
|
});
|
|
3554
|
-
const instance = new
|
|
3605
|
+
const instance = new aws10.ec2.Instance(group, "instance", {
|
|
3555
3606
|
name,
|
|
3556
3607
|
iamInstanceProfile: profile.arn,
|
|
3557
3608
|
launchTemplate: template,
|
|
3558
3609
|
subnetId: ctx.shared.get(`vpc-public-subnet-id-1`)
|
|
3559
3610
|
});
|
|
3560
3611
|
instance.dependsOn(code);
|
|
3561
|
-
const logGroup = new
|
|
3612
|
+
const logGroup = new aws10.cloudWatch.LogGroup(group, "log", {
|
|
3562
3613
|
name: `/awsless/instance/${name}`,
|
|
3563
3614
|
retention: days3(3)
|
|
3564
3615
|
});
|
|
@@ -3577,7 +3628,7 @@ var instanceFeature = defineFeature({
|
|
|
3577
3628
|
});
|
|
3578
3629
|
|
|
3579
3630
|
// src/feature/on-failure/index.ts
|
|
3580
|
-
import { Node as Node10, aws as
|
|
3631
|
+
import { Node as Node10, aws as aws11 } from "@awsless/formation";
|
|
3581
3632
|
var onFailureFeature = defineFeature({
|
|
3582
3633
|
name: "on-failure",
|
|
3583
3634
|
onApp(ctx) {
|
|
@@ -3588,7 +3639,7 @@ var onFailureFeature = defineFeature({
|
|
|
3588
3639
|
if (count > 1) {
|
|
3589
3640
|
throw new TypeError("Only 1 onFailure configuration is allowed in your app.");
|
|
3590
3641
|
}
|
|
3591
|
-
const queue2 = new
|
|
3642
|
+
const queue2 = new aws11.sqs.Queue(ctx.base, "on-failure", {
|
|
3592
3643
|
name: formatGlobalResourceName(ctx.appConfig.name, "on-failure", "failure")
|
|
3593
3644
|
});
|
|
3594
3645
|
ctx.shared.set("on-failure-queue-arn", queue2.arn);
|
|
@@ -3601,7 +3652,7 @@ var onFailureFeature = defineFeature({
|
|
|
3601
3652
|
const queueArn = ctx.shared.get("on-failure-queue-arn");
|
|
3602
3653
|
const group = new Node10(ctx.stack, "on-failure", "failure");
|
|
3603
3654
|
const { lambda, policy } = createLambdaFunction(group, ctx, "on-failure", "failure", onFailure);
|
|
3604
|
-
const source = new
|
|
3655
|
+
const source = new aws11.lambda.EventSourceMapping(group, "on-failure", {
|
|
3605
3656
|
functionArn: lambda.arn,
|
|
3606
3657
|
sourceArn: queueArn,
|
|
3607
3658
|
batchSize: 10
|
|
@@ -3621,7 +3672,7 @@ var onFailureFeature = defineFeature({
|
|
|
3621
3672
|
});
|
|
3622
3673
|
|
|
3623
3674
|
// src/feature/pubsub/index.ts
|
|
3624
|
-
import { aws as
|
|
3675
|
+
import { aws as aws12, Node as Node11 } from "@awsless/formation";
|
|
3625
3676
|
var pubsubFeature = defineFeature({
|
|
3626
3677
|
name: "pubsub",
|
|
3627
3678
|
onApp(ctx) {
|
|
@@ -3637,13 +3688,13 @@ var pubsubFeature = defineFeature({
|
|
|
3637
3688
|
const group = new Node11(ctx.stack, "pubsub", id);
|
|
3638
3689
|
const { lambda } = createAsyncLambdaFunction(group, ctx, `pubsub`, id, props.consumer);
|
|
3639
3690
|
const name = formatLocalResourceName(ctx.app.name, ctx.stack.name, "pubsub", id);
|
|
3640
|
-
const topic = new
|
|
3691
|
+
const topic = new aws12.iot.TopicRule(group, "rule", {
|
|
3641
3692
|
name: name.replaceAll("-", "_"),
|
|
3642
3693
|
sql: props.sql,
|
|
3643
3694
|
sqlVersion: props.sqlVersion,
|
|
3644
3695
|
actions: [{ lambda: { functionArn: lambda.arn } }]
|
|
3645
3696
|
});
|
|
3646
|
-
new
|
|
3697
|
+
new aws12.lambda.Permission(group, "permission", {
|
|
3647
3698
|
action: "lambda:InvokeFunction",
|
|
3648
3699
|
principal: "iot.amazonaws.com",
|
|
3649
3700
|
functionArn: lambda.arn,
|
|
@@ -3654,7 +3705,7 @@ var pubsubFeature = defineFeature({
|
|
|
3654
3705
|
});
|
|
3655
3706
|
|
|
3656
3707
|
// src/feature/queue/index.ts
|
|
3657
|
-
import { aws as
|
|
3708
|
+
import { aws as aws13, Node as Node12 } from "@awsless/formation";
|
|
3658
3709
|
import { camelCase as camelCase5, constantCase as constantCase6 } from "change-case";
|
|
3659
3710
|
import deepmerge2 from "deepmerge";
|
|
3660
3711
|
import { relative as relative3 } from "path";
|
|
@@ -3710,14 +3761,14 @@ var queueFeature = defineFeature({
|
|
|
3710
3761
|
for (const [id, local2] of Object.entries(ctx.stackConfig.queues || {})) {
|
|
3711
3762
|
const props = deepmerge2(ctx.appConfig.defaults.queue, local2);
|
|
3712
3763
|
const group = new Node12(ctx.stack, "queue", id);
|
|
3713
|
-
const queue2 = new
|
|
3764
|
+
const queue2 = new aws13.sqs.Queue(group, "queue", {
|
|
3714
3765
|
name: formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, "queue", id),
|
|
3715
3766
|
deadLetterArn: getGlobalOnFailure(ctx),
|
|
3716
3767
|
...props
|
|
3717
3768
|
});
|
|
3718
3769
|
const { lambda, policy } = createLambdaFunction(group, ctx, `queue`, id, props.consumer);
|
|
3719
3770
|
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
3720
|
-
new
|
|
3771
|
+
new aws13.lambda.EventSourceMapping(group, "event", {
|
|
3721
3772
|
functionArn: lambda.arn,
|
|
3722
3773
|
sourceArn: queue2.arn,
|
|
3723
3774
|
batchSize: props.batchSize,
|
|
@@ -3737,18 +3788,18 @@ var queueFeature = defineFeature({
|
|
|
3737
3788
|
});
|
|
3738
3789
|
|
|
3739
3790
|
// src/feature/rest/index.ts
|
|
3740
|
-
import { aws as
|
|
3791
|
+
import { aws as aws14, Node as Node13 } from "@awsless/formation";
|
|
3741
3792
|
import { constantCase as constantCase7 } from "change-case";
|
|
3742
3793
|
var restFeature = defineFeature({
|
|
3743
3794
|
name: "rest",
|
|
3744
3795
|
onApp(ctx) {
|
|
3745
3796
|
for (const [id, props] of Object.entries(ctx.appConfig.defaults?.rest ?? {})) {
|
|
3746
3797
|
const group = new Node13(ctx.base, "rest", id);
|
|
3747
|
-
const api = new
|
|
3798
|
+
const api = new aws14.apiGatewayV2.Api(group, "api", {
|
|
3748
3799
|
name: formatGlobalResourceName(ctx.app.name, "rest", id),
|
|
3749
3800
|
protocolType: "HTTP"
|
|
3750
3801
|
});
|
|
3751
|
-
const stage = new
|
|
3802
|
+
const stage = new aws14.apiGatewayV2.Stage(group, "stage", {
|
|
3752
3803
|
name: "v1",
|
|
3753
3804
|
apiId: api.id
|
|
3754
3805
|
});
|
|
@@ -3757,7 +3808,7 @@ var restFeature = defineFeature({
|
|
|
3757
3808
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
3758
3809
|
const hostedZoneId = ctx.shared.get(`hosted-zone-${props.domain}-id`);
|
|
3759
3810
|
const certificateArn = ctx.shared.get(`certificate-${props.domain}-arn`);
|
|
3760
|
-
const domain = new
|
|
3811
|
+
const domain = new aws14.apiGatewayV2.DomainName(group, "domain", {
|
|
3761
3812
|
name: domainName,
|
|
3762
3813
|
certificates: [
|
|
3763
3814
|
{
|
|
@@ -3765,12 +3816,12 @@ var restFeature = defineFeature({
|
|
|
3765
3816
|
}
|
|
3766
3817
|
]
|
|
3767
3818
|
});
|
|
3768
|
-
const mapping = new
|
|
3819
|
+
const mapping = new aws14.apiGatewayV2.ApiMapping(group, "mapping", {
|
|
3769
3820
|
apiId: api.id,
|
|
3770
3821
|
domainName: domain.name,
|
|
3771
3822
|
stage: stage.name
|
|
3772
3823
|
});
|
|
3773
|
-
const record = new
|
|
3824
|
+
const record = new aws14.route53.RecordSet(group, "record", {
|
|
3774
3825
|
hostedZoneId,
|
|
3775
3826
|
type: "A",
|
|
3776
3827
|
name: domainName,
|
|
@@ -3797,12 +3848,12 @@ var restFeature = defineFeature({
|
|
|
3797
3848
|
...props,
|
|
3798
3849
|
description: `${id} ${routeKey}`
|
|
3799
3850
|
});
|
|
3800
|
-
const permission = new
|
|
3851
|
+
const permission = new aws14.lambda.Permission(group, "permission", {
|
|
3801
3852
|
action: "lambda:InvokeFunction",
|
|
3802
3853
|
principal: "apigateway.amazonaws.com",
|
|
3803
3854
|
functionArn: lambda.arn
|
|
3804
3855
|
});
|
|
3805
|
-
const integration = new
|
|
3856
|
+
const integration = new aws14.apiGatewayV2.Integration(group, "integration", {
|
|
3806
3857
|
apiId,
|
|
3807
3858
|
description: `${id} ${routeKey}`,
|
|
3808
3859
|
method: "POST",
|
|
@@ -3812,7 +3863,7 @@ var restFeature = defineFeature({
|
|
|
3812
3863
|
return `arn:aws:apigateway:${ctx.appConfig.region}:lambda:path/2015-03-31/functions/${arn}/invocations`;
|
|
3813
3864
|
})
|
|
3814
3865
|
});
|
|
3815
|
-
const route = new
|
|
3866
|
+
const route = new aws14.apiGatewayV2.Route(group, "route", {
|
|
3816
3867
|
apiId,
|
|
3817
3868
|
routeKey,
|
|
3818
3869
|
target: integration.id.apply((id2) => `integrations/${id2}`)
|
|
@@ -3824,7 +3875,7 @@ var restFeature = defineFeature({
|
|
|
3824
3875
|
});
|
|
3825
3876
|
|
|
3826
3877
|
// src/feature/search/index.ts
|
|
3827
|
-
import { aws as
|
|
3878
|
+
import { aws as aws15, Node as Node14 } from "@awsless/formation";
|
|
3828
3879
|
import { constantCase as constantCase8 } from "change-case";
|
|
3829
3880
|
var typeGenCode4 = `
|
|
3830
3881
|
import { AnyStruct, Table } from '@awsless/open-search'
|
|
@@ -3853,7 +3904,7 @@ var searchFeature = defineFeature({
|
|
|
3853
3904
|
onStack(ctx) {
|
|
3854
3905
|
for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
|
|
3855
3906
|
const group = new Node14(ctx.stack, "search", id);
|
|
3856
|
-
const openSearch = new
|
|
3907
|
+
const openSearch = new aws15.openSearch.Domain(group, "domain", {
|
|
3857
3908
|
// name: formatLocalResourceName(ctx.app.name, ctx.stack.name, this.name, id),
|
|
3858
3909
|
version: props.version,
|
|
3859
3910
|
storageSize: props.storage,
|
|
@@ -3892,9 +3943,9 @@ var searchFeature = defineFeature({
|
|
|
3892
3943
|
|
|
3893
3944
|
// src/feature/site/index.ts
|
|
3894
3945
|
import { days as days4, seconds as seconds3 } from "@awsless/duration";
|
|
3895
|
-
import { Asset as Asset4, aws as
|
|
3946
|
+
import { Asset as Asset4, aws as aws16, Node as Node15 } from "@awsless/formation";
|
|
3896
3947
|
import { glob as glob2 } from "glob";
|
|
3897
|
-
import { join as
|
|
3948
|
+
import { join as join9 } from "path";
|
|
3898
3949
|
|
|
3899
3950
|
// src/feature/site/util.ts
|
|
3900
3951
|
import { lookup, contentType } from "mime-types";
|
|
@@ -3933,7 +3984,7 @@ var siteFeature = defineFeature({
|
|
|
3933
3984
|
ctx.onBind((name2, value) => {
|
|
3934
3985
|
lambda.addEnvironment(name2, value);
|
|
3935
3986
|
});
|
|
3936
|
-
new
|
|
3987
|
+
new aws16.lambda.Permission(group, "permission", {
|
|
3937
3988
|
principal: "*",
|
|
3938
3989
|
// principal: 'cloudfront.amazonaws.com',
|
|
3939
3990
|
action: "lambda:InvokeFunctionUrl",
|
|
@@ -3942,7 +3993,7 @@ var siteFeature = defineFeature({
|
|
|
3942
3993
|
// urlAuthType: 'aws-iam',
|
|
3943
3994
|
// sourceArn: distribution.arn,
|
|
3944
3995
|
});
|
|
3945
|
-
const url = new
|
|
3996
|
+
const url = new aws16.lambda.Url(group, "url", {
|
|
3946
3997
|
targetArn: lambda.arn,
|
|
3947
3998
|
authType: "none"
|
|
3948
3999
|
// authType: 'aws-iam',
|
|
@@ -3954,7 +4005,7 @@ var siteFeature = defineFeature({
|
|
|
3954
4005
|
});
|
|
3955
4006
|
}
|
|
3956
4007
|
if (props.static) {
|
|
3957
|
-
bucket = new
|
|
4008
|
+
bucket = new aws16.s3.Bucket(group, "bucket", {
|
|
3958
4009
|
name,
|
|
3959
4010
|
forceDelete: true,
|
|
3960
4011
|
website: {
|
|
@@ -3971,7 +4022,7 @@ var siteFeature = defineFeature({
|
|
|
3971
4022
|
]
|
|
3972
4023
|
});
|
|
3973
4024
|
bucket.deletionPolicy = "after-deployment";
|
|
3974
|
-
const accessControl = new
|
|
4025
|
+
const accessControl = new aws16.cloudFront.OriginAccessControl(group, `access`, {
|
|
3975
4026
|
name,
|
|
3976
4027
|
type: "s3",
|
|
3977
4028
|
behavior: "always",
|
|
@@ -3983,10 +4034,10 @@ var siteFeature = defineFeature({
|
|
|
3983
4034
|
nodir: true
|
|
3984
4035
|
});
|
|
3985
4036
|
for (const file of files) {
|
|
3986
|
-
const object = new
|
|
4037
|
+
const object = new aws16.s3.BucketObject(group, file, {
|
|
3987
4038
|
bucket: bucket.name,
|
|
3988
4039
|
key: file,
|
|
3989
|
-
body: Asset4.fromFile(
|
|
4040
|
+
body: Asset4.fromFile(join9(props.static, file)),
|
|
3990
4041
|
cacheControl: getCacheControl(file),
|
|
3991
4042
|
contentType: getContentType(file)
|
|
3992
4043
|
});
|
|
@@ -4006,14 +4057,14 @@ var siteFeature = defineFeature({
|
|
|
4006
4057
|
statusCodes: [403, 404]
|
|
4007
4058
|
});
|
|
4008
4059
|
}
|
|
4009
|
-
const cache = new
|
|
4060
|
+
const cache = new aws16.cloudFront.CachePolicy(group, "cache", {
|
|
4010
4061
|
name,
|
|
4011
4062
|
minTtl: seconds3(1),
|
|
4012
4063
|
maxTtl: days4(365),
|
|
4013
4064
|
defaultTtl: days4(1),
|
|
4014
4065
|
...props.cache
|
|
4015
4066
|
});
|
|
4016
|
-
const originRequest = new
|
|
4067
|
+
const originRequest = new aws16.cloudFront.OriginRequestPolicy(group, "request", {
|
|
4017
4068
|
name,
|
|
4018
4069
|
header: {
|
|
4019
4070
|
behavior: "all-except",
|
|
@@ -4021,7 +4072,7 @@ var siteFeature = defineFeature({
|
|
|
4021
4072
|
}
|
|
4022
4073
|
});
|
|
4023
4074
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
4024
|
-
const responseHeaders = new
|
|
4075
|
+
const responseHeaders = new aws16.cloudFront.ResponseHeadersPolicy(group, "response", {
|
|
4025
4076
|
name,
|
|
4026
4077
|
cors: props.cors,
|
|
4027
4078
|
remove: ["server"]
|
|
@@ -4029,7 +4080,7 @@ var siteFeature = defineFeature({
|
|
|
4029
4080
|
// override: true,
|
|
4030
4081
|
// },
|
|
4031
4082
|
});
|
|
4032
|
-
const distribution = new
|
|
4083
|
+
const distribution = new aws16.cloudFront.Distribution(group, "distribution", {
|
|
4033
4084
|
name,
|
|
4034
4085
|
certificateArn: ctx.shared.get(`global-certificate-${props.domain}-arn`),
|
|
4035
4086
|
compress: true,
|
|
@@ -4057,13 +4108,13 @@ var siteFeature = defineFeature({
|
|
|
4057
4108
|
};
|
|
4058
4109
|
})
|
|
4059
4110
|
});
|
|
4060
|
-
new
|
|
4111
|
+
new aws16.cloudFront.InvalidateCache(group, "invalidate", {
|
|
4061
4112
|
distributionId: distribution.id,
|
|
4062
4113
|
paths: ["/*"],
|
|
4063
4114
|
versions
|
|
4064
4115
|
});
|
|
4065
4116
|
if (props.static) {
|
|
4066
|
-
new
|
|
4117
|
+
new aws16.s3.BucketPolicy(group, `policy`, {
|
|
4067
4118
|
bucketName: bucket.name,
|
|
4068
4119
|
statements: [
|
|
4069
4120
|
{
|
|
@@ -4089,7 +4140,7 @@ var siteFeature = defineFeature({
|
|
|
4089
4140
|
]
|
|
4090
4141
|
});
|
|
4091
4142
|
}
|
|
4092
|
-
new
|
|
4143
|
+
new aws16.route53.RecordSet(group, `record`, {
|
|
4093
4144
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
4094
4145
|
type: "A",
|
|
4095
4146
|
name: domainName,
|
|
@@ -4104,7 +4155,7 @@ var siteFeature = defineFeature({
|
|
|
4104
4155
|
});
|
|
4105
4156
|
|
|
4106
4157
|
// src/feature/store/index.ts
|
|
4107
|
-
import { aws as
|
|
4158
|
+
import { aws as aws17, Node as Node16 } from "@awsless/formation";
|
|
4108
4159
|
import { paramCase as paramCase6 } from "change-case";
|
|
4109
4160
|
var typeGenCode5 = `
|
|
4110
4161
|
import { Body, PutObjectProps, BodyStream, createPresignedPost } from '@awsless/s3'
|
|
@@ -4158,7 +4209,7 @@ var storeFeature = defineFeature({
|
|
|
4158
4209
|
const eventGroup = new Node16(group, "event", event);
|
|
4159
4210
|
const eventId = paramCase6(`${id}-${shortId(event)}`);
|
|
4160
4211
|
const { lambda } = createAsyncLambdaFunction(eventGroup, ctx, `store`, eventId, funcProps);
|
|
4161
|
-
new
|
|
4212
|
+
new aws17.lambda.Permission(eventGroup, "permission", {
|
|
4162
4213
|
action: "lambda:InvokeFunction",
|
|
4163
4214
|
principal: "s3.amazonaws.com",
|
|
4164
4215
|
functionArn: lambda.arn,
|
|
@@ -4169,7 +4220,7 @@ var storeFeature = defineFeature({
|
|
|
4169
4220
|
function: lambda.arn
|
|
4170
4221
|
});
|
|
4171
4222
|
}
|
|
4172
|
-
const bucket = new
|
|
4223
|
+
const bucket = new aws17.s3.Bucket(group, "store", {
|
|
4173
4224
|
name: bucketName,
|
|
4174
4225
|
versioning: props.versioning,
|
|
4175
4226
|
lambdaConfigs,
|
|
@@ -4192,7 +4243,7 @@ var storeFeature = defineFeature({
|
|
|
4192
4243
|
});
|
|
4193
4244
|
|
|
4194
4245
|
// src/feature/stream/index.ts
|
|
4195
|
-
import { aws as
|
|
4246
|
+
import { aws as aws18, Node as Node17 } from "@awsless/formation";
|
|
4196
4247
|
import { constantCase as constantCase9 } from "change-case";
|
|
4197
4248
|
var streamFeature = defineFeature({
|
|
4198
4249
|
name: "stream",
|
|
@@ -4200,11 +4251,11 @@ var streamFeature = defineFeature({
|
|
|
4200
4251
|
for (const [id, props] of Object.entries(ctx.stackConfig.streams ?? {})) {
|
|
4201
4252
|
const group = new Node17(ctx.stack, "stream", id);
|
|
4202
4253
|
const name = formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, "stream", id);
|
|
4203
|
-
const channel = new
|
|
4254
|
+
const channel = new aws18.ivs.Channel(group, "channel", {
|
|
4204
4255
|
name,
|
|
4205
4256
|
...props
|
|
4206
4257
|
});
|
|
4207
|
-
const streamKey = new
|
|
4258
|
+
const streamKey = new aws18.ivs.StreamKey(group, "key", {
|
|
4208
4259
|
channel: channel.arn
|
|
4209
4260
|
});
|
|
4210
4261
|
const prefix = `STREAM_${constantCase9(ctx.stack.name)}_${constantCase9(id)}`;
|
|
@@ -4216,7 +4267,7 @@ var streamFeature = defineFeature({
|
|
|
4216
4267
|
});
|
|
4217
4268
|
|
|
4218
4269
|
// src/feature/table/index.ts
|
|
4219
|
-
import { aws as
|
|
4270
|
+
import { aws as aws19, Node as Node18 } from "@awsless/formation";
|
|
4220
4271
|
var tableFeature = defineFeature({
|
|
4221
4272
|
name: "table",
|
|
4222
4273
|
async onTypeGen(ctx) {
|
|
@@ -4236,7 +4287,7 @@ var tableFeature = defineFeature({
|
|
|
4236
4287
|
onStack(ctx) {
|
|
4237
4288
|
for (const [id, props] of Object.entries(ctx.stackConfig.tables ?? {})) {
|
|
4238
4289
|
const group = new Node18(ctx.stack, "table", id);
|
|
4239
|
-
const table2 = new
|
|
4290
|
+
const table2 = new aws19.dynamodb.Table(group, "table", {
|
|
4240
4291
|
...props,
|
|
4241
4292
|
name: formatLocalResourceName(ctx.appConfig.name, ctx.stackConfig.name, "table", id),
|
|
4242
4293
|
stream: props.stream?.type
|
|
@@ -4245,7 +4296,7 @@ var tableFeature = defineFeature({
|
|
|
4245
4296
|
const { lambda, policy } = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
|
|
4246
4297
|
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
4247
4298
|
const onFailure = getGlobalOnFailure(ctx);
|
|
4248
|
-
const source = new
|
|
4299
|
+
const source = new aws19.lambda.EventSourceMapping(group, id, {
|
|
4249
4300
|
functionArn: lambda.arn,
|
|
4250
4301
|
sourceArn: table2.streamArn,
|
|
4251
4302
|
batchSize: 100,
|
|
@@ -4339,7 +4390,7 @@ var testFeature = defineFeature({
|
|
|
4339
4390
|
});
|
|
4340
4391
|
|
|
4341
4392
|
// src/feature/topic/index.ts
|
|
4342
|
-
import { aws as
|
|
4393
|
+
import { aws as aws20, Node as Node20 } from "@awsless/formation";
|
|
4343
4394
|
var typeGenCode7 = `
|
|
4344
4395
|
import type { PublishOptions } from '@awsless/sns'
|
|
4345
4396
|
import type { Mock } from 'vitest'
|
|
@@ -4377,7 +4428,7 @@ var topicFeature = defineFeature({
|
|
|
4377
4428
|
for (const stack of ctx.stackConfigs) {
|
|
4378
4429
|
for (const id of stack.topics ?? []) {
|
|
4379
4430
|
const group = new Node20(ctx.base, "topic", id);
|
|
4380
|
-
const topic = new
|
|
4431
|
+
const topic = new aws20.sns.Topic(group, "topic", {
|
|
4381
4432
|
name: formatGlobalResourceName(ctx.appConfig.name, "topic", id)
|
|
4382
4433
|
});
|
|
4383
4434
|
ctx.shared.set(`topic-${id}-arn`, topic.arn);
|
|
@@ -4397,19 +4448,19 @@ var topicFeature = defineFeature({
|
|
|
4397
4448
|
const group = new Node20(ctx.stack, "topic", id);
|
|
4398
4449
|
const topicArn = ctx.shared.get(`topic-${id}-arn`);
|
|
4399
4450
|
if (typeof props === "string" && isEmail(props)) {
|
|
4400
|
-
new
|
|
4451
|
+
new aws20.sns.Subscription(group, id, {
|
|
4401
4452
|
topicArn,
|
|
4402
4453
|
protocol: "email",
|
|
4403
4454
|
endpoint: props
|
|
4404
4455
|
});
|
|
4405
4456
|
} else if (typeof props === "object") {
|
|
4406
4457
|
const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
|
|
4407
|
-
new
|
|
4458
|
+
new aws20.sns.Subscription(group, id, {
|
|
4408
4459
|
topicArn,
|
|
4409
4460
|
protocol: "lambda",
|
|
4410
4461
|
endpoint: lambda.arn
|
|
4411
4462
|
});
|
|
4412
|
-
new
|
|
4463
|
+
new aws20.lambda.Permission(group, id, {
|
|
4413
4464
|
action: "lambda:InvokeFunction",
|
|
4414
4465
|
principal: "sns.amazonaws.com",
|
|
4415
4466
|
functionArn: lambda.arn,
|
|
@@ -4421,45 +4472,37 @@ var topicFeature = defineFeature({
|
|
|
4421
4472
|
});
|
|
4422
4473
|
|
|
4423
4474
|
// src/feature/vpc/index.ts
|
|
4424
|
-
import {
|
|
4425
|
-
import { aws as aws20, combine as combine2, Node as Node21 } from "@awsless/formation";
|
|
4475
|
+
import { aws as aws21, combine as combine2, Node as Node21 } from "@awsless/formation";
|
|
4426
4476
|
var vpcFeature = defineFeature({
|
|
4427
4477
|
name: "vpc",
|
|
4428
4478
|
onApp(ctx) {
|
|
4429
4479
|
const group = new Node21(ctx.base, "vpc", "main");
|
|
4430
|
-
const vpc = new
|
|
4480
|
+
const vpc = new aws21.ec2.Vpc(group, "vpc", {
|
|
4431
4481
|
name: ctx.app.name,
|
|
4432
|
-
cidrBlock:
|
|
4482
|
+
cidrBlock: aws21.ec2.Peer.ipv4("10.0.0.0/16")
|
|
4433
4483
|
// cidrBlock: aws.ec2.Peer.ipv6('fd00:10:20::/48'),
|
|
4434
4484
|
// cidrBlock: aws.ec2.Peer.ipv6('2a05:d018:c69:6600::/56'),
|
|
4435
4485
|
// enableDnsSupport: true,
|
|
4436
4486
|
// enableDnsHostnames: true,
|
|
4437
4487
|
});
|
|
4438
|
-
const
|
|
4439
|
-
vpcId: vpc.id,
|
|
4440
|
-
amazonProvidedIpv6CidrBlock: true
|
|
4441
|
-
});
|
|
4442
|
-
const slices = ipv6CidrBlock.ipv6CidrBlock.apply((ip) => {
|
|
4443
|
-
return ipv6CidrBlockFromString(ip).slice(64);
|
|
4444
|
-
});
|
|
4445
|
-
const privateRouteTable = new aws20.ec2.RouteTable(group, "private", {
|
|
4488
|
+
const privateRouteTable = new aws21.ec2.RouteTable(group, "private", {
|
|
4446
4489
|
vpcId: vpc.id,
|
|
4447
4490
|
name: "private"
|
|
4448
4491
|
});
|
|
4449
|
-
const publicRouteTable = new
|
|
4492
|
+
const publicRouteTable = new aws21.ec2.RouteTable(group, "public", {
|
|
4450
4493
|
vpcId: vpc.id,
|
|
4451
4494
|
name: "public"
|
|
4452
4495
|
});
|
|
4453
|
-
const gateway = new
|
|
4454
|
-
const attachment = new
|
|
4496
|
+
const gateway = new aws21.ec2.InternetGateway(group, "gateway");
|
|
4497
|
+
const attachment = new aws21.ec2.VPCGatewayAttachment(group, "attachment", {
|
|
4455
4498
|
vpcId: vpc.id,
|
|
4456
4499
|
internetGatewayId: gateway.id
|
|
4457
4500
|
});
|
|
4458
|
-
new
|
|
4501
|
+
new aws21.ec2.Route(group, "route", {
|
|
4459
4502
|
gatewayId: gateway.id,
|
|
4460
4503
|
routeTableId: publicRouteTable.id,
|
|
4461
|
-
|
|
4462
|
-
destination:
|
|
4504
|
+
destination: aws21.ec2.Peer.anyIpv4()
|
|
4505
|
+
// destination: aws.ec2.Peer.anyIpv6(),
|
|
4463
4506
|
});
|
|
4464
4507
|
ctx.shared.set(
|
|
4465
4508
|
"vpc-id",
|
|
@@ -4474,19 +4517,20 @@ var vpcFeature = defineFeature({
|
|
|
4474
4517
|
for (const i in zones) {
|
|
4475
4518
|
const index = Number(i) + 1;
|
|
4476
4519
|
const id = `${table2.identifier}-${index}`;
|
|
4477
|
-
const subnet = new
|
|
4520
|
+
const subnet = new aws21.ec2.Subnet(group, id, {
|
|
4478
4521
|
name: `${ctx.app.name}--${table2.identifier}-${index}`,
|
|
4479
4522
|
vpcId: vpc.id,
|
|
4480
|
-
cidrBlock:
|
|
4523
|
+
cidrBlock: aws21.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
|
|
4481
4524
|
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
|
|
4482
4525
|
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`2a05:d018:c69:660${++block}::/64`),
|
|
4483
4526
|
// ipv6CidrBlock: ipv6CidrBlock.ipv6CidrBlock.apply(ip => ),
|
|
4484
|
-
ipv6CidrBlock: slices.apply(
|
|
4485
|
-
assignIpv6AddressOnCreation: true,
|
|
4527
|
+
// ipv6CidrBlock: slices.apply(list => aws.ec2.Peer.ipv6(list.get(block++).toString())),
|
|
4528
|
+
// assignIpv6AddressOnCreation: true,
|
|
4486
4529
|
// ipv6Native: true,
|
|
4530
|
+
mapPublicIpOnLaunch: table2.identifier === "public",
|
|
4487
4531
|
availabilityZone: ctx.appConfig.region + zones[i]
|
|
4488
4532
|
});
|
|
4489
|
-
new
|
|
4533
|
+
new aws21.ec2.SubnetRouteTableAssociation(group, id, {
|
|
4490
4534
|
routeTableId: table2.id,
|
|
4491
4535
|
subnetId: subnet.id
|
|
4492
4536
|
});
|
|
@@ -4557,7 +4601,7 @@ var getFiltersWithDeps = (stacks, filters) => {
|
|
|
4557
4601
|
return list4;
|
|
4558
4602
|
};
|
|
4559
4603
|
var createApp = (props, filters = []) => {
|
|
4560
|
-
const app = new
|
|
4604
|
+
const app = new App2(props.appConfig.name);
|
|
4561
4605
|
const base = new Stack(app, "base");
|
|
4562
4606
|
const shared = new SharedData();
|
|
4563
4607
|
const siteFunctions = [];
|
|
@@ -4922,55 +4966,6 @@ var config = (program2) => {
|
|
|
4922
4966
|
|
|
4923
4967
|
// src/cli/command/delete.ts
|
|
4924
4968
|
import { confirm as confirm3 } from "@clack/prompts";
|
|
4925
|
-
|
|
4926
|
-
// src/util/workspace.ts
|
|
4927
|
-
import { minutes as minutes4 } from "@awsless/duration";
|
|
4928
|
-
import { aws as aws22, local, WorkSpace } from "@awsless/formation";
|
|
4929
|
-
import { mkdir as mkdir3, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4930
|
-
import { dirname as dirname10, join as join9 } from "path";
|
|
4931
|
-
var createWorkSpace = (props) => {
|
|
4932
|
-
const lockProvider = new aws22.dynamodb.LockProvider({
|
|
4933
|
-
...props,
|
|
4934
|
-
tableName: "awsless-locks"
|
|
4935
|
-
});
|
|
4936
|
-
const stateProvider = new aws22.s3.StateProvider({
|
|
4937
|
-
...props,
|
|
4938
|
-
bucket: `awsless-state-${props.accountId}`
|
|
4939
|
-
});
|
|
4940
|
-
const cloudProviders = aws22.createCloudProviders({
|
|
4941
|
-
...props,
|
|
4942
|
-
timeout: minutes4(60)
|
|
4943
|
-
});
|
|
4944
|
-
const workspace = new WorkSpace({
|
|
4945
|
-
lockProvider,
|
|
4946
|
-
stateProvider,
|
|
4947
|
-
cloudProviders,
|
|
4948
|
-
concurrency: 15
|
|
4949
|
-
});
|
|
4950
|
-
return {
|
|
4951
|
-
workspace,
|
|
4952
|
-
lockProvider,
|
|
4953
|
-
stateProvider
|
|
4954
|
-
};
|
|
4955
|
-
};
|
|
4956
|
-
var pullRemoteState = async (app, stateProvider) => {
|
|
4957
|
-
const file = join9(directories.state, `${app.urn}.json`);
|
|
4958
|
-
const state2 = await stateProvider.get(app.urn);
|
|
4959
|
-
await mkdir3(dirname10(file), { recursive: true });
|
|
4960
|
-
if (typeof state2 === "undefined") {
|
|
4961
|
-
await rm(file);
|
|
4962
|
-
} else {
|
|
4963
|
-
await writeFile2(file, JSON.stringify(state2, void 0, 2));
|
|
4964
|
-
}
|
|
4965
|
-
};
|
|
4966
|
-
var pushRemoteState = async (app, stateProvider) => {
|
|
4967
|
-
const file = join9(directories.state, `${app.urn}.json`);
|
|
4968
|
-
const data = await readFile6(file, "utf8");
|
|
4969
|
-
const state2 = JSON.parse(data);
|
|
4970
|
-
await stateProvider.update(app.urn, state2);
|
|
4971
|
-
};
|
|
4972
|
-
|
|
4973
|
-
// src/cli/command/delete.ts
|
|
4974
4969
|
var del2 = (program2) => {
|
|
4975
4970
|
program2.command("delete").argument("[stacks...]", "Optionally filter stacks to delete").description("Delete your app from AWS").action(async (filters) => {
|
|
4976
4971
|
await layout("delete", async ({ appConfig, stackConfigs }) => {
|