@awsless/awsless 0.0.146 → 0.0.148
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/app.json +1 -1
- package/dist/bin.js +279 -135
- package/dist/features/cognito-client-secret/bundle.zip +0 -0
- package/dist/features/delete-bucket/bundle.zip +0 -0
- package/dist/features/delete-hosted-zone/bundle.zip +0 -0
- package/dist/features/global-exports/bundle.zip +0 -0
- package/dist/features/invalidate-cache/bundle.zip +0 -0
- package/dist/features/upload-bucket-asset/bundle.zip +0 -0
- package/dist/index.d.ts +2081 -299
- package/dist/index.js +3 -0
- package/dist/json.js +39 -6
- package/dist/stack.json +1 -1
- package/package.json +5 -4
package/dist/bin.js
CHANGED
|
@@ -55,6 +55,9 @@ var flushDebug = () => {
|
|
|
55
55
|
return queue.splice(0, queue.length);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
// src/formation/resource/lambda/function.ts
|
|
59
|
+
import { constantCase as constantCase3 } from "change-case";
|
|
60
|
+
|
|
58
61
|
// src/formation/asset.ts
|
|
59
62
|
import { paramCase } from "change-case";
|
|
60
63
|
var Asset = class {
|
|
@@ -65,6 +68,43 @@ var Asset = class {
|
|
|
65
68
|
id;
|
|
66
69
|
};
|
|
67
70
|
|
|
71
|
+
// src/formation/property/duration.ts
|
|
72
|
+
var Duration = class _Duration {
|
|
73
|
+
constructor(value) {
|
|
74
|
+
this.value = value;
|
|
75
|
+
}
|
|
76
|
+
static milliseconds(value) {
|
|
77
|
+
return new _Duration(value);
|
|
78
|
+
}
|
|
79
|
+
static seconds(value) {
|
|
80
|
+
return new _Duration(value * 1e3 /* seconds */);
|
|
81
|
+
}
|
|
82
|
+
static minutes(value) {
|
|
83
|
+
return new _Duration(value * 6e4 /* minutes */);
|
|
84
|
+
}
|
|
85
|
+
static hours(value) {
|
|
86
|
+
return new _Duration(value * 36e5 /* hours */);
|
|
87
|
+
}
|
|
88
|
+
static days(value) {
|
|
89
|
+
return new _Duration(value * 864e5 /* days */);
|
|
90
|
+
}
|
|
91
|
+
toMilliseconds() {
|
|
92
|
+
return this.value;
|
|
93
|
+
}
|
|
94
|
+
toSeconds() {
|
|
95
|
+
return Math.floor(this.value / 1e3 /* seconds */);
|
|
96
|
+
}
|
|
97
|
+
toMinutes() {
|
|
98
|
+
return Math.floor(this.value / 6e4 /* minutes */);
|
|
99
|
+
}
|
|
100
|
+
toHours() {
|
|
101
|
+
return Math.floor(this.value / 36e5 /* hours */);
|
|
102
|
+
}
|
|
103
|
+
toDays() {
|
|
104
|
+
return Math.floor(this.value / 864e5 /* days */);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
68
108
|
// src/formation/util.ts
|
|
69
109
|
import { paramCase as paramCase2, pascalCase } from "change-case";
|
|
70
110
|
var ref = (logicalId) => {
|
|
@@ -303,7 +343,7 @@ var Rule = class extends Resource {
|
|
|
303
343
|
properties() {
|
|
304
344
|
return {
|
|
305
345
|
Name: this.name,
|
|
306
|
-
...this.attr("State", "ENABLED"),
|
|
346
|
+
...this.attr("State", this.props.enabled ? "ENABLED" : "DISABLED"),
|
|
307
347
|
...this.attr("Description", this.props.description),
|
|
308
348
|
...this.attr("ScheduleExpression", this.props.schedule),
|
|
309
349
|
...this.attr("RoleArn", this.props.roleArn),
|
|
@@ -341,11 +381,14 @@ var EventsEventSource = class extends Group {
|
|
|
341
381
|
constructor(id, lambda, props) {
|
|
342
382
|
const rule = new Rule(id, {
|
|
343
383
|
schedule: props.schedule,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
384
|
+
enabled: props.enabled,
|
|
385
|
+
targets: [
|
|
386
|
+
{
|
|
387
|
+
id,
|
|
388
|
+
arn: lambda.arn,
|
|
389
|
+
input: props.payload
|
|
390
|
+
}
|
|
391
|
+
]
|
|
349
392
|
});
|
|
350
393
|
const permission = new Permission(id, {
|
|
351
394
|
action: "lambda:InvokeFunction",
|
|
@@ -411,11 +454,22 @@ var Function = class extends Resource {
|
|
|
411
454
|
if (this.name.length > 64) {
|
|
412
455
|
throw new TypeError(`Lambda function name length can't be greater then 64. ${this.name}`);
|
|
413
456
|
}
|
|
457
|
+
if (props.log) {
|
|
458
|
+
if (typeof props.log === "boolean") {
|
|
459
|
+
this.enableLogs(Duration.days(7));
|
|
460
|
+
} else if (props.log instanceof Duration) {
|
|
461
|
+
this.enableLogs(props.log);
|
|
462
|
+
} else {
|
|
463
|
+
this.enableLogs(props.log.retention);
|
|
464
|
+
this.logConfig = props.log;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
414
467
|
}
|
|
415
468
|
name;
|
|
416
469
|
role;
|
|
417
470
|
policy;
|
|
418
471
|
environmentVariables;
|
|
472
|
+
logConfig = {};
|
|
419
473
|
enableLogs(retention) {
|
|
420
474
|
const logGroup = new LogGroup(this._logicalId, {
|
|
421
475
|
name: sub("/aws/lambda/${name}", {
|
|
@@ -439,6 +493,7 @@ var Function = class extends Resource {
|
|
|
439
493
|
warmUp(concurrency) {
|
|
440
494
|
const source = new EventsEventSource(`${this._logicalId}-warmer`, this, {
|
|
441
495
|
schedule: "rate(5 minutes)",
|
|
496
|
+
enabled: true,
|
|
442
497
|
payload: {
|
|
443
498
|
warmer: true,
|
|
444
499
|
concurrency
|
|
@@ -497,6 +552,13 @@ var Function = class extends Resource {
|
|
|
497
552
|
EphemeralStorage: {
|
|
498
553
|
Size: this.props.ephemeralStorageSize?.toMegaBytes() ?? 512
|
|
499
554
|
},
|
|
555
|
+
...this.props.log ? {
|
|
556
|
+
LoggingConfig: {
|
|
557
|
+
LogFormat: this.logConfig.format === "text" ? "Text" : "JSON",
|
|
558
|
+
ApplicationLogLevel: constantCase3(this.logConfig.level ?? "error"),
|
|
559
|
+
SystemLogLevel: constantCase3(this.logConfig.system ?? "warn")
|
|
560
|
+
}
|
|
561
|
+
} : {},
|
|
500
562
|
...this.props.vpc ? {
|
|
501
563
|
VpcConfig: {
|
|
502
564
|
SecurityGroupIds: this.props.vpc.securityGroupIds,
|
|
@@ -630,11 +692,11 @@ var Stack = class {
|
|
|
630
692
|
// src/stack.ts
|
|
631
693
|
var toStack = ({ config: config2, app, stackConfig, bootstrap: bootstrap2, usEastBootstrap, plugins: plugins2, tests }) => {
|
|
632
694
|
const name = stackConfig.name;
|
|
633
|
-
const stack = new Stack(name, config2.app.region).tag("app", config2.app.name).tag("stage", config2.
|
|
695
|
+
const stack = new Stack(name, config2.app.region).tag("app", config2.app.name).tag("stage", config2.stage).tag("stack", name);
|
|
634
696
|
debug("Define stack:", style.info(name));
|
|
635
697
|
debug("Run plugin onStack listeners");
|
|
636
698
|
const bindings = [];
|
|
637
|
-
const
|
|
699
|
+
const bind2 = (cb) => {
|
|
638
700
|
bindings.push(cb);
|
|
639
701
|
};
|
|
640
702
|
for (const plugin of plugins2) {
|
|
@@ -646,16 +708,16 @@ var toStack = ({ config: config2, app, stackConfig, bootstrap: bootstrap2, usEas
|
|
|
646
708
|
bootstrap: bootstrap2,
|
|
647
709
|
usEastBootstrap,
|
|
648
710
|
tests,
|
|
649
|
-
bind
|
|
711
|
+
bind: bind2
|
|
650
712
|
});
|
|
651
713
|
}
|
|
652
714
|
if (stack.size === 0) {
|
|
653
715
|
throw new Error(`Stack ${style.info(name)} has no resources defined`);
|
|
654
716
|
}
|
|
655
717
|
const functions = stack.find(Function);
|
|
656
|
-
for (const
|
|
718
|
+
for (const bind3 of bindings) {
|
|
657
719
|
for (const fn of functions) {
|
|
658
|
-
|
|
720
|
+
bind3(fn);
|
|
659
721
|
}
|
|
660
722
|
}
|
|
661
723
|
return {
|
|
@@ -749,7 +811,7 @@ var fileExist = async (file) => {
|
|
|
749
811
|
|
|
750
812
|
// src/util/type-gen.ts
|
|
751
813
|
import { dirname, join as join2, relative } from "path";
|
|
752
|
-
import { camelCase, constantCase as
|
|
814
|
+
import { camelCase, constantCase as constantCase4 } from "change-case";
|
|
753
815
|
var generateResourceTypes = async (config2) => {
|
|
754
816
|
const files = [];
|
|
755
817
|
await Promise.all(
|
|
@@ -860,7 +922,7 @@ var TypeObject = class {
|
|
|
860
922
|
return this.add(camelCase(name), type);
|
|
861
923
|
}
|
|
862
924
|
addConst(name, type) {
|
|
863
|
-
return this.add(
|
|
925
|
+
return this.add(constantCase4(name), type);
|
|
864
926
|
}
|
|
865
927
|
toString() {
|
|
866
928
|
if (!this.types.size) {
|
|
@@ -883,43 +945,6 @@ var TypeObject = class {
|
|
|
883
945
|
}
|
|
884
946
|
};
|
|
885
947
|
|
|
886
|
-
// src/formation/property/duration.ts
|
|
887
|
-
var Duration = class _Duration {
|
|
888
|
-
constructor(value) {
|
|
889
|
-
this.value = value;
|
|
890
|
-
}
|
|
891
|
-
static milliseconds(value) {
|
|
892
|
-
return new _Duration(value);
|
|
893
|
-
}
|
|
894
|
-
static seconds(value) {
|
|
895
|
-
return new _Duration(value * 1e3 /* seconds */);
|
|
896
|
-
}
|
|
897
|
-
static minutes(value) {
|
|
898
|
-
return new _Duration(value * 6e4 /* minutes */);
|
|
899
|
-
}
|
|
900
|
-
static hours(value) {
|
|
901
|
-
return new _Duration(value * 36e5 /* hours */);
|
|
902
|
-
}
|
|
903
|
-
static days(value) {
|
|
904
|
-
return new _Duration(value * 864e5 /* days */);
|
|
905
|
-
}
|
|
906
|
-
toMilliseconds() {
|
|
907
|
-
return this.value;
|
|
908
|
-
}
|
|
909
|
-
toSeconds() {
|
|
910
|
-
return Math.floor(this.value / 1e3 /* seconds */);
|
|
911
|
-
}
|
|
912
|
-
toMinutes() {
|
|
913
|
-
return Math.floor(this.value / 6e4 /* minutes */);
|
|
914
|
-
}
|
|
915
|
-
toHours() {
|
|
916
|
-
return Math.floor(this.value / 36e5 /* hours */);
|
|
917
|
-
}
|
|
918
|
-
toDays() {
|
|
919
|
-
return Math.floor(this.value / 864e5 /* days */);
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
|
|
923
948
|
// src/util/byte-size.ts
|
|
924
949
|
import { filesize } from "filesize";
|
|
925
950
|
var formatByteSize = (size) => {
|
|
@@ -1414,10 +1439,7 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1414
1439
|
if (typeof fileOrProps === "object" && fileOrProps.permissions) {
|
|
1415
1440
|
lambda.addPermissions(fileOrProps.permissions);
|
|
1416
1441
|
}
|
|
1417
|
-
lambda.addEnvironment("APP", config2.app.name).addEnvironment("STAGE", config2.
|
|
1418
|
-
if (props.log) {
|
|
1419
|
-
lambda.enableLogs(props.log instanceof Duration ? props.log : void 0);
|
|
1420
|
-
}
|
|
1442
|
+
lambda.addEnvironment("APP", config2.app.name).addEnvironment("STAGE", config2.stage).addEnvironment("STACK", stack.name);
|
|
1421
1443
|
if (props.warm) {
|
|
1422
1444
|
lambda.warmUp(props.warm);
|
|
1423
1445
|
}
|
|
@@ -1444,7 +1466,7 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1444
1466
|
};
|
|
1445
1467
|
|
|
1446
1468
|
// src/formation/resource/cognito/user-pool.ts
|
|
1447
|
-
import { constantCase as
|
|
1469
|
+
import { constantCase as constantCase5 } from "change-case";
|
|
1448
1470
|
|
|
1449
1471
|
// src/formation/resource/cognito/user-pool-client.ts
|
|
1450
1472
|
var UserPoolClient = class extends Resource {
|
|
@@ -1683,7 +1705,7 @@ var UserPoolEmail = class _UserPoolEmail {
|
|
|
1683
1705
|
}
|
|
1684
1706
|
toJSON() {
|
|
1685
1707
|
return {
|
|
1686
|
-
...this.props.type ? { EmailSendingAccount:
|
|
1708
|
+
...this.props.type ? { EmailSendingAccount: constantCase5(this.props.type) } : {},
|
|
1687
1709
|
...this.props.from ? { From: this.props.from } : {},
|
|
1688
1710
|
...this.props.replyTo ? { ReplyToEmailAddress: this.props.replyTo } : {},
|
|
1689
1711
|
...this.props.sourceArn ? { SourceArn: this.props.sourceArn } : {}
|
|
@@ -1692,7 +1714,7 @@ var UserPoolEmail = class _UserPoolEmail {
|
|
|
1692
1714
|
};
|
|
1693
1715
|
|
|
1694
1716
|
// src/plugins/auth/index.ts
|
|
1695
|
-
import { constantCase as
|
|
1717
|
+
import { constantCase as constantCase6 } from "change-case";
|
|
1696
1718
|
|
|
1697
1719
|
// src/formation/resource/cloud-formation/custom-resource.ts
|
|
1698
1720
|
var CustomResource = class extends Resource {
|
|
@@ -1727,29 +1749,29 @@ var authPlugin = definePlugin({
|
|
|
1727
1749
|
gen.addInterface("AuthResources", resources);
|
|
1728
1750
|
await write("auth.d.ts", gen, true);
|
|
1729
1751
|
},
|
|
1730
|
-
onStack({ config
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
},
|
|
1752
|
+
// onStack({ config, bootstrap, stackConfig, bind }) {
|
|
1753
|
+
// for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
|
|
1754
|
+
// if (props.access) {
|
|
1755
|
+
// const userPoolId = bootstrap.import(`auth-${id}-user-pool-id`)
|
|
1756
|
+
// const clientId = bootstrap.import(`auth-${id}-client-id`)
|
|
1757
|
+
// const name = constantCase(id)
|
|
1758
|
+
// bind(lambda => {
|
|
1759
|
+
// lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId)
|
|
1760
|
+
// lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId)
|
|
1761
|
+
// if (config.app.defaults.auth?.[id]?.secret) {
|
|
1762
|
+
// const clientSecret = bootstrap.import(`auth-${id}-client-secret`)
|
|
1763
|
+
// lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret)
|
|
1764
|
+
// }
|
|
1765
|
+
// lambda.addPermissions({
|
|
1766
|
+
// actions: ['cognito:*'],
|
|
1767
|
+
// resources: ['*'],
|
|
1768
|
+
// })
|
|
1769
|
+
// })
|
|
1770
|
+
// }
|
|
1771
|
+
// }
|
|
1772
|
+
// },
|
|
1751
1773
|
onApp(ctx) {
|
|
1752
|
-
const { config: config2, bootstrap: bootstrap2 } = ctx;
|
|
1774
|
+
const { config: config2, bootstrap: bootstrap2, bind: bind2 } = ctx;
|
|
1753
1775
|
if (Object.keys(config2.app.defaults.auth).length === 0) {
|
|
1754
1776
|
return;
|
|
1755
1777
|
}
|
|
@@ -1835,6 +1857,22 @@ var authPlugin = definePlugin({
|
|
|
1835
1857
|
}).dependsOn(lambda);
|
|
1836
1858
|
bootstrap2.add(lambda, permission);
|
|
1837
1859
|
}
|
|
1860
|
+
bind2((lambda) => {
|
|
1861
|
+
const userPoolArn = bootstrap2.import(`auth-${id}-user-pool-arn`);
|
|
1862
|
+
const userPoolId = bootstrap2.import(`auth-${id}-user-pool-id`);
|
|
1863
|
+
const clientId = bootstrap2.import(`auth-${id}-client-id`);
|
|
1864
|
+
const name = constantCase6(id);
|
|
1865
|
+
lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
|
|
1866
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
|
|
1867
|
+
if (props.secret) {
|
|
1868
|
+
const clientSecret = bootstrap2.import(`auth-${id}-client-secret`);
|
|
1869
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret);
|
|
1870
|
+
}
|
|
1871
|
+
lambda.addPermissions({
|
|
1872
|
+
actions: ["cognito:*"],
|
|
1873
|
+
resources: [userPoolArn]
|
|
1874
|
+
});
|
|
1875
|
+
});
|
|
1838
1876
|
}
|
|
1839
1877
|
}
|
|
1840
1878
|
});
|
|
@@ -2042,7 +2080,7 @@ var Port = class _Port {
|
|
|
2042
2080
|
};
|
|
2043
2081
|
|
|
2044
2082
|
// src/plugins/cache/index.ts
|
|
2045
|
-
import { constantCase as
|
|
2083
|
+
import { constantCase as constantCase7 } from "change-case";
|
|
2046
2084
|
var typeGenCode2 = `
|
|
2047
2085
|
import { Cluster, CommandOptions } from '@awsless/redis'
|
|
2048
2086
|
|
|
@@ -2070,7 +2108,7 @@ var cachePlugin = definePlugin({
|
|
|
2070
2108
|
gen.addInterface("CacheResources", resources);
|
|
2071
2109
|
await write("cache.d.ts", gen, true);
|
|
2072
2110
|
},
|
|
2073
|
-
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind }) {
|
|
2111
|
+
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind: bind2 }) {
|
|
2074
2112
|
for (const [id, props] of Object.entries(stackConfig.caches || {})) {
|
|
2075
2113
|
const name = `${config2.app.name}-${stack.name}-${id}`;
|
|
2076
2114
|
const subnetGroup = new SubnetGroup(id, {
|
|
@@ -2093,9 +2131,9 @@ var cachePlugin = definePlugin({
|
|
|
2093
2131
|
...props
|
|
2094
2132
|
}).dependsOn(subnetGroup, securityGroup);
|
|
2095
2133
|
stack.add(subnetGroup, securityGroup, cluster);
|
|
2096
|
-
|
|
2097
|
-
lambda.addEnvironment(`CACHE_${
|
|
2098
|
-
`CACHE_${
|
|
2134
|
+
bind2((lambda) => {
|
|
2135
|
+
lambda.addEnvironment(`CACHE_${constantCase7(stack.name)}_${constantCase7(id)}_HOST`, cluster.address).addEnvironment(
|
|
2136
|
+
`CACHE_${constantCase7(stack.name)}_${constantCase7(id)}_PORT`,
|
|
2099
2137
|
props.port.toString()
|
|
2100
2138
|
);
|
|
2101
2139
|
});
|
|
@@ -2217,9 +2255,9 @@ var configPlugin = definePlugin({
|
|
|
2217
2255
|
gen.addInterface("ConfigResources", resources.toString());
|
|
2218
2256
|
await write("config.d.ts", gen, true);
|
|
2219
2257
|
},
|
|
2220
|
-
onStack({ bind, config: config2, stackConfig }) {
|
|
2258
|
+
onStack({ bind: bind2, config: config2, stackConfig }) {
|
|
2221
2259
|
const configs = stackConfig.configs;
|
|
2222
|
-
|
|
2260
|
+
bind2((lambda) => {
|
|
2223
2261
|
if (configs && configs.length) {
|
|
2224
2262
|
lambda.addEnvironment("CONFIG", configs.join(","));
|
|
2225
2263
|
lambda.addPermissions({
|
|
@@ -2247,6 +2285,7 @@ var cronPlugin = definePlugin({
|
|
|
2247
2285
|
const lambda = toLambdaFunction(ctx, id, props.consumer);
|
|
2248
2286
|
const source = new EventsEventSource(id, lambda, {
|
|
2249
2287
|
schedule: props.schedule,
|
|
2288
|
+
enabled: props.enabled,
|
|
2250
2289
|
payload: props.payload
|
|
2251
2290
|
});
|
|
2252
2291
|
stack.add(lambda, source);
|
|
@@ -2376,7 +2415,7 @@ var ConfigurationSet = class extends Resource {
|
|
|
2376
2415
|
};
|
|
2377
2416
|
|
|
2378
2417
|
// src/formation/resource/ses/email-identity.ts
|
|
2379
|
-
import { constantCase as
|
|
2418
|
+
import { constantCase as constantCase8 } from "change-case";
|
|
2380
2419
|
var EmailIdentity = class extends Resource {
|
|
2381
2420
|
constructor(logicalId, props) {
|
|
2382
2421
|
super("AWS::SES::EmailIdentity", logicalId);
|
|
@@ -2437,7 +2476,7 @@ var EmailIdentity = class extends Resource {
|
|
|
2437
2476
|
SigningEnabled: true
|
|
2438
2477
|
},
|
|
2439
2478
|
DkimSigningAttributes: {
|
|
2440
|
-
NextSigningKeyLength:
|
|
2479
|
+
NextSigningKeyLength: constantCase8(this.props.dkim)
|
|
2441
2480
|
}
|
|
2442
2481
|
} : {},
|
|
2443
2482
|
FeedbackAttributes: {
|
|
@@ -2454,7 +2493,7 @@ var EmailIdentity = class extends Resource {
|
|
|
2454
2493
|
// src/plugins/domain/index.ts
|
|
2455
2494
|
var domainPlugin = definePlugin({
|
|
2456
2495
|
name: "domain",
|
|
2457
|
-
onApp({ config: config2, app, bootstrap: bootstrap2, usEastBootstrap, bind }) {
|
|
2496
|
+
onApp({ config: config2, app, bootstrap: bootstrap2, usEastBootstrap, bind: bind2 }) {
|
|
2458
2497
|
const domains = Object.entries(config2.app.defaults.domains || {});
|
|
2459
2498
|
if (domains.length === 0) {
|
|
2460
2499
|
return;
|
|
@@ -2518,7 +2557,7 @@ var domainPlugin = definePlugin({
|
|
|
2518
2557
|
usEastBootstrap.add(group);
|
|
2519
2558
|
}
|
|
2520
2559
|
}
|
|
2521
|
-
|
|
2560
|
+
bind2(
|
|
2522
2561
|
(lambda) => lambda.addPermissions({
|
|
2523
2562
|
actions: ["ses:*"],
|
|
2524
2563
|
resources: ["*"]
|
|
@@ -3268,7 +3307,7 @@ var LoadBalancer = class extends Resource {
|
|
|
3268
3307
|
};
|
|
3269
3308
|
|
|
3270
3309
|
// src/formation/resource/elb/listener.ts
|
|
3271
|
-
import { constantCase as
|
|
3310
|
+
import { constantCase as constantCase9 } from "change-case";
|
|
3272
3311
|
var Listener = class extends Resource {
|
|
3273
3312
|
constructor(logicalId, props) {
|
|
3274
3313
|
super("AWS::ElasticLoadBalancingV2::Listener", logicalId);
|
|
@@ -3284,7 +3323,7 @@ var Listener = class extends Resource {
|
|
|
3284
3323
|
return {
|
|
3285
3324
|
LoadBalancerArn: this.props.loadBalancerArn,
|
|
3286
3325
|
Port: this.props.port,
|
|
3287
|
-
Protocol:
|
|
3326
|
+
Protocol: constantCase9(this.props.protocol),
|
|
3288
3327
|
Certificates: this.props.certificates.map((arn) => ({
|
|
3289
3328
|
CertificateArn: arn
|
|
3290
3329
|
})),
|
|
@@ -3637,7 +3676,7 @@ var httpPlugin = definePlugin({
|
|
|
3637
3676
|
});
|
|
3638
3677
|
|
|
3639
3678
|
// src/formation/resource/lambda/event-source-mapping.ts
|
|
3640
|
-
import { constantCase as
|
|
3679
|
+
import { constantCase as constantCase10 } from "change-case";
|
|
3641
3680
|
var EventSourceMapping = class extends Resource {
|
|
3642
3681
|
constructor(logicalId, props) {
|
|
3643
3682
|
super("AWS::Lambda::EventSourceMapping", logicalId);
|
|
@@ -3659,7 +3698,7 @@ var EventSourceMapping = class extends Resource {
|
|
|
3659
3698
|
...this.attr("ParallelizationFactor", this.props.parallelizationFactor),
|
|
3660
3699
|
...this.attr("TumblingWindowInSeconds", this.props.tumblingWindow?.toSeconds()),
|
|
3661
3700
|
...this.attr("BisectBatchOnFunctionError", this.props.bisectBatchOnError),
|
|
3662
|
-
...this.attr("StartingPosition", this.props.startingPosition &&
|
|
3701
|
+
...this.attr("StartingPosition", this.props.startingPosition && constantCase10(this.props.startingPosition)),
|
|
3663
3702
|
...this.attr("StartingPositionTimestamp", this.props.startingPositionTimestamp),
|
|
3664
3703
|
...this.props.maxConcurrency ? {
|
|
3665
3704
|
ScalingConfig: {
|
|
@@ -3832,8 +3871,8 @@ var IotEventSource = class extends Group {
|
|
|
3832
3871
|
// src/plugins/pubsub/index.ts
|
|
3833
3872
|
var pubsubPlugin = definePlugin({
|
|
3834
3873
|
name: "pubsub",
|
|
3835
|
-
onApp({ bind }) {
|
|
3836
|
-
|
|
3874
|
+
onApp({ bind: bind2 }) {
|
|
3875
|
+
bind2((lambda) => {
|
|
3837
3876
|
lambda.addPermissions({
|
|
3838
3877
|
actions: ["iot:publish"],
|
|
3839
3878
|
resources: ["*"]
|
|
@@ -3855,7 +3894,7 @@ var pubsubPlugin = definePlugin({
|
|
|
3855
3894
|
});
|
|
3856
3895
|
|
|
3857
3896
|
// src/plugins/queue/index.ts
|
|
3858
|
-
import { camelCase as camelCase4, constantCase as
|
|
3897
|
+
import { camelCase as camelCase4, constantCase as constantCase11 } from "change-case";
|
|
3859
3898
|
import { relative as relative4 } from "path";
|
|
3860
3899
|
var typeGenCode3 = `
|
|
3861
3900
|
import { SendMessageOptions, SendMessageBatchOptions, BatchItem } from '@awsless/sqs'
|
|
@@ -3866,7 +3905,7 @@ type Payload<F extends Func> = Parameters<F>[0]['Records'][number]['body']
|
|
|
3866
3905
|
|
|
3867
3906
|
type Send<Name extends string, F extends Func> = {
|
|
3868
3907
|
readonly name: Name
|
|
3869
|
-
|
|
3908
|
+
batch(items:BatchItem<Payload<F>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
|
|
3870
3909
|
(payload: Payload<F>, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
|
|
3871
3910
|
}
|
|
3872
3911
|
|
|
@@ -3906,7 +3945,7 @@ var queuePlugin = definePlugin({
|
|
|
3906
3945
|
await write("queue.d.ts", gen, true);
|
|
3907
3946
|
},
|
|
3908
3947
|
onStack(ctx) {
|
|
3909
|
-
const { stack, config: config2, stackConfig, bind } = ctx;
|
|
3948
|
+
const { stack, config: config2, stackConfig, bind: bind2 } = ctx;
|
|
3910
3949
|
for (const [id, functionOrProps] of Object.entries(stackConfig.queues || {})) {
|
|
3911
3950
|
const props = typeof functionOrProps === "string" ? { ...config2.app.defaults.queue, consumer: functionOrProps } : { ...config2.app.defaults.queue, ...functionOrProps };
|
|
3912
3951
|
const queue2 = new Queue(id, {
|
|
@@ -3922,9 +3961,9 @@ var queuePlugin = definePlugin({
|
|
|
3922
3961
|
maxBatchingWindow: props.maxBatchingWindow
|
|
3923
3962
|
});
|
|
3924
3963
|
stack.add(queue2, lambda, source);
|
|
3925
|
-
|
|
3964
|
+
bind2((lambda2) => {
|
|
3926
3965
|
lambda2.addPermissions(queue2.permissions);
|
|
3927
|
-
lambda2.addEnvironment(`QUEUE_${
|
|
3966
|
+
lambda2.addEnvironment(`QUEUE_${constantCase11(stack.name)}_${constantCase11(id)}_URL`, queue2.url);
|
|
3928
3967
|
});
|
|
3929
3968
|
}
|
|
3930
3969
|
}
|
|
@@ -4202,13 +4241,13 @@ var searchPlugin = definePlugin({
|
|
|
4202
4241
|
gen.addInterface("SearchResources", resources);
|
|
4203
4242
|
await write("search.d.ts", gen, true);
|
|
4204
4243
|
},
|
|
4205
|
-
onStack({ app, stack, stackConfig, bind }) {
|
|
4244
|
+
onStack({ app, stack, stackConfig, bind: bind2 }) {
|
|
4206
4245
|
for (const id of stackConfig.searchs || []) {
|
|
4207
4246
|
const collection = new Collection(id, {
|
|
4208
4247
|
name: `${app.name}-${stack.name}-${id}`,
|
|
4209
4248
|
type: "search"
|
|
4210
4249
|
});
|
|
4211
|
-
|
|
4250
|
+
bind2((lambda) => {
|
|
4212
4251
|
lambda.addPermissions(collection.permissions);
|
|
4213
4252
|
});
|
|
4214
4253
|
}
|
|
@@ -4235,6 +4274,9 @@ var Distribution = class extends Resource {
|
|
|
4235
4274
|
get domainName() {
|
|
4236
4275
|
return getAtt(this.logicalId, "DomainName");
|
|
4237
4276
|
}
|
|
4277
|
+
get hostedZoneId() {
|
|
4278
|
+
return "Z2FDTNDATAQYW2";
|
|
4279
|
+
}
|
|
4238
4280
|
properties() {
|
|
4239
4281
|
return {
|
|
4240
4282
|
DistributionConfig: {
|
|
@@ -4828,7 +4870,7 @@ var sitePlugin = definePlugin({
|
|
|
4828
4870
|
name: domainName,
|
|
4829
4871
|
alias: {
|
|
4830
4872
|
dnsName: distribution.domainName,
|
|
4831
|
-
hostedZoneId:
|
|
4873
|
+
hostedZoneId: distribution.hostedZoneId
|
|
4832
4874
|
}
|
|
4833
4875
|
}).dependsOn(distribution);
|
|
4834
4876
|
stack.add(distribution, invalidateCache, responseHeaders, originRequest, cache, record);
|
|
@@ -4853,7 +4895,7 @@ var storePlugin = definePlugin({
|
|
|
4853
4895
|
gen.addInterface("StoreResources", resources);
|
|
4854
4896
|
await write("store.d.ts", gen, true);
|
|
4855
4897
|
},
|
|
4856
|
-
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind }) {
|
|
4898
|
+
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind: bind2 }) {
|
|
4857
4899
|
for (const id of stackConfig.stores || []) {
|
|
4858
4900
|
const bucket = new Bucket(id, {
|
|
4859
4901
|
name: `store-${config2.app.name}-${stack.name}-${id}`,
|
|
@@ -4866,7 +4908,7 @@ var storePlugin = definePlugin({
|
|
|
4866
4908
|
}
|
|
4867
4909
|
}).dependsOn(bucket);
|
|
4868
4910
|
stack.add(bucket, custom);
|
|
4869
|
-
|
|
4911
|
+
bind2((lambda) => {
|
|
4870
4912
|
lambda.addPermissions(bucket.permissions);
|
|
4871
4913
|
});
|
|
4872
4914
|
}
|
|
@@ -4874,7 +4916,7 @@ var storePlugin = definePlugin({
|
|
|
4874
4916
|
});
|
|
4875
4917
|
|
|
4876
4918
|
// src/formation/resource/dynamodb/table.ts
|
|
4877
|
-
import { constantCase as
|
|
4919
|
+
import { constantCase as constantCase12 } from "change-case";
|
|
4878
4920
|
var Table = class extends Resource {
|
|
4879
4921
|
constructor(logicalId, props) {
|
|
4880
4922
|
super("AWS::DynamoDB::Table", logicalId);
|
|
@@ -4959,7 +5001,7 @@ var Table = class extends Resource {
|
|
|
4959
5001
|
return {
|
|
4960
5002
|
TableName: this.name,
|
|
4961
5003
|
BillingMode: "PAY_PER_REQUEST",
|
|
4962
|
-
TableClass:
|
|
5004
|
+
TableClass: constantCase12(this.props.class || "standard"),
|
|
4963
5005
|
PointInTimeRecoverySpecification: {
|
|
4964
5006
|
PointInTimeRecoveryEnabled: this.props.pointInTimeRecovery || false
|
|
4965
5007
|
},
|
|
@@ -4970,7 +5012,7 @@ var Table = class extends Resource {
|
|
|
4970
5012
|
AttributeDefinitions: this.attributeDefinitions(),
|
|
4971
5013
|
...this.props.stream ? {
|
|
4972
5014
|
StreamSpecification: {
|
|
4973
|
-
StreamViewType:
|
|
5015
|
+
StreamViewType: constantCase12(this.props.stream)
|
|
4974
5016
|
}
|
|
4975
5017
|
} : {},
|
|
4976
5018
|
...this.props.timeToLiveAttribute ? {
|
|
@@ -4987,7 +5029,7 @@ var Table = class extends Resource {
|
|
|
4987
5029
|
...props.sort ? [{ KeyType: "RANGE", AttributeName: props.sort }] : []
|
|
4988
5030
|
],
|
|
4989
5031
|
Projection: {
|
|
4990
|
-
ProjectionType:
|
|
5032
|
+
ProjectionType: constantCase12(props.projection || "all")
|
|
4991
5033
|
}
|
|
4992
5034
|
}))
|
|
4993
5035
|
} : {}
|
|
@@ -5043,7 +5085,7 @@ var tablePlugin = definePlugin({
|
|
|
5043
5085
|
await write("table.d.ts", gen, true);
|
|
5044
5086
|
},
|
|
5045
5087
|
onStack(ctx) {
|
|
5046
|
-
const { config: config2, stack, stackConfig, bind } = ctx;
|
|
5088
|
+
const { config: config2, stack, stackConfig, bind: bind2 } = ctx;
|
|
5047
5089
|
for (const [id, props] of Object.entries(stackConfig.tables || {})) {
|
|
5048
5090
|
const table = new Table(id, {
|
|
5049
5091
|
...props,
|
|
@@ -5068,7 +5110,7 @@ var tablePlugin = definePlugin({
|
|
|
5068
5110
|
}
|
|
5069
5111
|
stack.add(lambda, source);
|
|
5070
5112
|
}
|
|
5071
|
-
|
|
5113
|
+
bind2((lambda) => {
|
|
5072
5114
|
lambda.addPermissions(table.permissions);
|
|
5073
5115
|
});
|
|
5074
5116
|
}
|
|
@@ -5203,9 +5245,9 @@ var topicPlugin = definePlugin({
|
|
|
5203
5245
|
}
|
|
5204
5246
|
},
|
|
5205
5247
|
onStack(ctx) {
|
|
5206
|
-
const { config: config2, stack, stackConfig, bootstrap: bootstrap2, bind } = ctx;
|
|
5248
|
+
const { config: config2, stack, stackConfig, bootstrap: bootstrap2, bind: bind2 } = ctx;
|
|
5207
5249
|
for (const id of stackConfig.topics || []) {
|
|
5208
|
-
|
|
5250
|
+
bind2((lambda) => {
|
|
5209
5251
|
lambda.addPermissions({
|
|
5210
5252
|
actions: ["sns:Publish"],
|
|
5211
5253
|
resources: [
|
|
@@ -5480,7 +5522,7 @@ var toApp = async (config2, filters) => {
|
|
|
5480
5522
|
const usEastBootstrap = new Stack("us-east-bootstrap", "us-east-1");
|
|
5481
5523
|
debug("Run plugin onApp listeners");
|
|
5482
5524
|
const bindings = [];
|
|
5483
|
-
const
|
|
5525
|
+
const bind2 = (cb) => {
|
|
5484
5526
|
bindings.push(cb);
|
|
5485
5527
|
};
|
|
5486
5528
|
for (const plugin of plugins) {
|
|
@@ -5489,7 +5531,7 @@ var toApp = async (config2, filters) => {
|
|
|
5489
5531
|
app,
|
|
5490
5532
|
bootstrap: bootstrap2,
|
|
5491
5533
|
usEastBootstrap,
|
|
5492
|
-
bind,
|
|
5534
|
+
bind: bind2,
|
|
5493
5535
|
tests
|
|
5494
5536
|
});
|
|
5495
5537
|
}
|
|
@@ -5520,9 +5562,9 @@ var toApp = async (config2, filters) => {
|
|
|
5520
5562
|
app.add(usEastBootstrap);
|
|
5521
5563
|
}
|
|
5522
5564
|
const functions = app.find(Function);
|
|
5523
|
-
for (const
|
|
5565
|
+
for (const bind3 of bindings) {
|
|
5524
5566
|
for (const fn of functions) {
|
|
5525
|
-
|
|
5567
|
+
bind3(fn);
|
|
5526
5568
|
}
|
|
5527
5569
|
}
|
|
5528
5570
|
for (const entry of stacks) {
|
|
@@ -5532,9 +5574,9 @@ var toApp = async (config2, filters) => {
|
|
|
5532
5574
|
throw new Error(`Stack dependency not found: ${dep}`);
|
|
5533
5575
|
}
|
|
5534
5576
|
const functions2 = entry.stack.find(Function);
|
|
5535
|
-
for (const
|
|
5577
|
+
for (const bind3 of depStack.bindings) {
|
|
5536
5578
|
for (const fn of functions2) {
|
|
5537
|
-
|
|
5579
|
+
bind3(fn);
|
|
5538
5580
|
}
|
|
5539
5581
|
}
|
|
5540
5582
|
}
|
|
@@ -5726,9 +5768,6 @@ var PermissionSchema = z7.object({
|
|
|
5726
5768
|
resources: z7.string().array()
|
|
5727
5769
|
});
|
|
5728
5770
|
var PermissionsSchema = z7.union([PermissionSchema, PermissionSchema.array()]).describe("Add IAM permissions to your function.");
|
|
5729
|
-
var LogSchema = z7.union([z7.boolean(), DurationSchema.refine(durationMin(Duration.days(1)), "Minimum log retention is 1 day")]).describe(
|
|
5730
|
-
"Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time."
|
|
5731
|
-
);
|
|
5732
5771
|
var WarmSchema = z7.number().int().min(0).max(10).describe(
|
|
5733
5772
|
"Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10."
|
|
5734
5773
|
);
|
|
@@ -5736,6 +5775,25 @@ var VPCSchema = z7.boolean().describe("Put the function inside your global VPC."
|
|
|
5736
5775
|
var MinifySchema = z7.boolean().describe("Minify the function code.");
|
|
5737
5776
|
var HandlerSchema = z7.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
|
|
5738
5777
|
var FileSchema = LocalFileSchema.describe("The file path of the function code.");
|
|
5778
|
+
var LogRetentionSchema = DurationSchema.refine(durationMin(Duration.days(1)), "Minimum log retention is 1 day");
|
|
5779
|
+
var LogSchema = z7.union([
|
|
5780
|
+
z7.boolean(),
|
|
5781
|
+
LogRetentionSchema,
|
|
5782
|
+
z7.object({
|
|
5783
|
+
retention: LogRetentionSchema.describe("The log retention duration."),
|
|
5784
|
+
format: z7.enum(["text", "json"]).describe(
|
|
5785
|
+
`The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.`
|
|
5786
|
+
).optional(),
|
|
5787
|
+
system: z7.enum(["debug", "info", "warn"]).describe(
|
|
5788
|
+
"Set this property to filter the system logs for your function that Lambda sends to CloudWatch. Lambda only sends system logs at the selected level of detail and lower, where DEBUG is the highest level and WARN is the lowest."
|
|
5789
|
+
).optional(),
|
|
5790
|
+
level: z7.enum(["trace", "debug", "info", "warn", "error", "fatal"]).describe(
|
|
5791
|
+
"Set this property to filter the application logs for your function that Lambda sends to CloudWatch. Lambda only sends application logs at the selected level of detail and lower, where TRACE is the highest level and FATAL is the lowest."
|
|
5792
|
+
).optional()
|
|
5793
|
+
})
|
|
5794
|
+
]).describe(
|
|
5795
|
+
"Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time."
|
|
5796
|
+
);
|
|
5739
5797
|
var FunctionSchema = z7.union([
|
|
5740
5798
|
LocalFileSchema,
|
|
5741
5799
|
z7.object({
|
|
@@ -5762,7 +5820,12 @@ var FunctionDefaultSchema = z7.object({
|
|
|
5762
5820
|
minify: MinifySchema.default(true),
|
|
5763
5821
|
warm: WarmSchema.default(0),
|
|
5764
5822
|
vpc: VPCSchema.default(false),
|
|
5765
|
-
log: LogSchema.default(
|
|
5823
|
+
log: LogSchema.default({
|
|
5824
|
+
retention: "7 days",
|
|
5825
|
+
level: "error",
|
|
5826
|
+
system: "warn",
|
|
5827
|
+
format: "json"
|
|
5828
|
+
}),
|
|
5766
5829
|
timeout: TimeoutSchema.default("10 seconds"),
|
|
5767
5830
|
runtime: RuntimeSchema.default("nodejs20.x"),
|
|
5768
5831
|
memorySize: MemorySizeSchema.default("128 MB"),
|
|
@@ -5791,7 +5854,10 @@ var TriggersSchema = z8.object({
|
|
|
5791
5854
|
var AuthSchema = z8.record(
|
|
5792
5855
|
ResourceIdSchema,
|
|
5793
5856
|
z8.object({
|
|
5794
|
-
access:
|
|
5857
|
+
// access: z
|
|
5858
|
+
// .boolean()
|
|
5859
|
+
// .default(false)
|
|
5860
|
+
// .describe('Give access to every function in this stack to your cognito instance.'),
|
|
5795
5861
|
triggers: TriggersSchema.optional()
|
|
5796
5862
|
})
|
|
5797
5863
|
).optional().describe("Define the auth triggers in your stack.");
|
|
@@ -6004,7 +6070,11 @@ var AppSchema = z15.object({
|
|
|
6004
6070
|
name: ResourceIdSchema.describe("App name."),
|
|
6005
6071
|
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
6006
6072
|
profile: z15.string().describe("The AWS profile to deploy to."),
|
|
6007
|
-
stage:
|
|
6073
|
+
// stage: z
|
|
6074
|
+
// .string()
|
|
6075
|
+
// .regex(/^[a-z]+$/)
|
|
6076
|
+
// .default('prod')
|
|
6077
|
+
// .describe('The deployment stage.'),
|
|
6008
6078
|
defaults: z15.object({
|
|
6009
6079
|
auth: AuthDefaultSchema,
|
|
6010
6080
|
domains: DomainsDefaultSchema,
|
|
@@ -6078,6 +6148,7 @@ var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
|
|
|
6078
6148
|
var CronsSchema = z17.record(
|
|
6079
6149
|
ResourceIdSchema,
|
|
6080
6150
|
z17.object({
|
|
6151
|
+
enabled: z17.boolean().default(true).describe("If the cron is enabled."),
|
|
6081
6152
|
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
6082
6153
|
schedule: ScheduleExpressionSchema.describe(
|
|
6083
6154
|
'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
|
|
@@ -6243,6 +6314,10 @@ var SitesSchema = z26.record(
|
|
|
6243
6314
|
subDomain: z26.string().optional(),
|
|
6244
6315
|
static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
|
|
6245
6316
|
ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
|
|
6317
|
+
// bind: z.object({
|
|
6318
|
+
// auth:
|
|
6319
|
+
// h
|
|
6320
|
+
// }).optional(),
|
|
6246
6321
|
// ssr: z.union([
|
|
6247
6322
|
// FunctionSchema.optional(),
|
|
6248
6323
|
// z.object({
|
|
@@ -6447,13 +6522,17 @@ var loadConfig = async (options) => {
|
|
|
6447
6522
|
const stackConfig = await readConfigWithStage(file, options.stage);
|
|
6448
6523
|
setLocalBasePath(join7(process.cwd(), dirname5(file)));
|
|
6449
6524
|
const stack = await parseConfig(StackSchema, file, stackConfig);
|
|
6450
|
-
stacks.push(
|
|
6525
|
+
stacks.push({
|
|
6526
|
+
...stack,
|
|
6527
|
+
file
|
|
6528
|
+
});
|
|
6451
6529
|
}
|
|
6452
6530
|
return {
|
|
6453
6531
|
app,
|
|
6454
6532
|
stacks,
|
|
6455
6533
|
account,
|
|
6456
|
-
credentials
|
|
6534
|
+
credentials,
|
|
6535
|
+
stage: options.stage
|
|
6457
6536
|
};
|
|
6458
6537
|
};
|
|
6459
6538
|
|
|
@@ -6494,12 +6573,12 @@ var list = (data) => {
|
|
|
6494
6573
|
};
|
|
6495
6574
|
|
|
6496
6575
|
// src/cli/ui/layout/header.ts
|
|
6497
|
-
var header = (
|
|
6576
|
+
var header = (config2) => {
|
|
6498
6577
|
return list({
|
|
6499
|
-
App: app.name,
|
|
6500
|
-
Stage:
|
|
6501
|
-
Region: app.region,
|
|
6502
|
-
Profile: app.profile
|
|
6578
|
+
App: config2.app.name,
|
|
6579
|
+
Stage: config2.stage,
|
|
6580
|
+
Region: config2.app.region,
|
|
6581
|
+
Profile: config2.app.profile
|
|
6503
6582
|
});
|
|
6504
6583
|
};
|
|
6505
6584
|
|
|
@@ -7017,7 +7096,7 @@ var layout = async (cb) => {
|
|
|
7017
7096
|
try {
|
|
7018
7097
|
const options = program.optsWithGlobals();
|
|
7019
7098
|
const config2 = await loadConfig(options);
|
|
7020
|
-
term.out.write(header(config2
|
|
7099
|
+
term.out.write(header(config2));
|
|
7021
7100
|
term.out.gap();
|
|
7022
7101
|
await cb(config2, term.out.write.bind(term.out), term);
|
|
7023
7102
|
} catch (error) {
|
|
@@ -8471,7 +8550,7 @@ var dev = (program2) => {
|
|
|
8471
8550
|
const options = program2.optsWithGlobals();
|
|
8472
8551
|
await cleanUp();
|
|
8473
8552
|
await write(typesGenerator(config2));
|
|
8474
|
-
|
|
8553
|
+
await watchConfig(
|
|
8475
8554
|
options,
|
|
8476
8555
|
async (config3) => {
|
|
8477
8556
|
await cleanUp();
|
|
@@ -8553,6 +8632,70 @@ var del2 = (program2) => {
|
|
|
8553
8632
|
});
|
|
8554
8633
|
};
|
|
8555
8634
|
|
|
8635
|
+
// src/cli/command/bind.ts
|
|
8636
|
+
import { spawn } from "child_process";
|
|
8637
|
+
import { paramCase as paramCase8 } from "change-case";
|
|
8638
|
+
import { GetFunctionCommand, LambdaClient } from "@aws-sdk/client-lambda";
|
|
8639
|
+
var bind = (program2) => {
|
|
8640
|
+
program2.command("bind").argument("stack", "The stack name").argument("site", "The site name").argument("<command...>", "The command to execute").description(`Bind your site environment variables to a command`).action(async (stack, site, commands3) => {
|
|
8641
|
+
await layout(async (config2, write) => {
|
|
8642
|
+
const command = commands3.join(" ");
|
|
8643
|
+
const stackConfig = config2.stacks.find((s) => s.name === stack);
|
|
8644
|
+
if (!stackConfig) {
|
|
8645
|
+
throw new Error(`[${stack}] Stack doesn't exist.`);
|
|
8646
|
+
}
|
|
8647
|
+
const siteConfig = stackConfig.sites?.[site];
|
|
8648
|
+
if (!siteConfig) {
|
|
8649
|
+
throw new Error(`[${site}] Site doesn't exist.`);
|
|
8650
|
+
}
|
|
8651
|
+
let functionEnv = {};
|
|
8652
|
+
if (siteConfig.ssr) {
|
|
8653
|
+
const client = new LambdaClient({
|
|
8654
|
+
credentials: config2.credentials,
|
|
8655
|
+
region: config2.app.region
|
|
8656
|
+
});
|
|
8657
|
+
const lambdaLoader = write(loadingDialog("Loading SSR lambda environment variables..."));
|
|
8658
|
+
try {
|
|
8659
|
+
const result = await client.send(
|
|
8660
|
+
new GetFunctionCommand({
|
|
8661
|
+
FunctionName: paramCase8(`${config2.app.name}-${stack}-site-${site}`)
|
|
8662
|
+
})
|
|
8663
|
+
);
|
|
8664
|
+
functionEnv = result.Configuration?.Environment?.Variables ?? {};
|
|
8665
|
+
} catch (error) {
|
|
8666
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
8667
|
+
write(dialog("warning", [`The SSR lambda hasn't been deployed yet.`]));
|
|
8668
|
+
} else {
|
|
8669
|
+
throw error;
|
|
8670
|
+
}
|
|
8671
|
+
} finally {
|
|
8672
|
+
lambdaLoader("Done loading SSR lambda environment variables");
|
|
8673
|
+
}
|
|
8674
|
+
}
|
|
8675
|
+
const credentialsLoader = write(loadingDialog("Loading AWS credentials..."));
|
|
8676
|
+
const credentials = await config2.credentials();
|
|
8677
|
+
credentialsLoader("Done loading AWS credentials");
|
|
8678
|
+
spawn(command, {
|
|
8679
|
+
env: {
|
|
8680
|
+
// Pass the process env vars
|
|
8681
|
+
...process.env,
|
|
8682
|
+
// Pass the lambda env vars
|
|
8683
|
+
...functionEnv,
|
|
8684
|
+
// Basic info
|
|
8685
|
+
AWS_REGION: config2.app.region,
|
|
8686
|
+
AWS_ACCOUNT_ID: config2.account,
|
|
8687
|
+
// Give AWS access
|
|
8688
|
+
AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
8689
|
+
AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
8690
|
+
AWS_SESSION_TOKEN: credentials.sessionToken
|
|
8691
|
+
},
|
|
8692
|
+
stdio: "inherit",
|
|
8693
|
+
shell: true
|
|
8694
|
+
});
|
|
8695
|
+
});
|
|
8696
|
+
});
|
|
8697
|
+
};
|
|
8698
|
+
|
|
8556
8699
|
// src/cli/program.ts
|
|
8557
8700
|
var program = new Command();
|
|
8558
8701
|
program.name(logo().join("").replace(/\s+/, ""));
|
|
@@ -8581,6 +8724,7 @@ var commands2 = [
|
|
|
8581
8724
|
deploy,
|
|
8582
8725
|
del2,
|
|
8583
8726
|
dev,
|
|
8727
|
+
bind,
|
|
8584
8728
|
config,
|
|
8585
8729
|
test
|
|
8586
8730
|
// draw,
|