@awsless/awsless 0.0.147 → 0.0.149
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 +227 -121
- 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 +7 -12
- package/dist/index.js +3 -0
- package/dist/json.js +13 -2
- package/dist/stack.json +1 -1
- package/package.json +5 -4
package/dist/bin.js
CHANGED
|
@@ -311,13 +311,15 @@ var Role = class extends Resource {
|
|
|
311
311
|
...this.props.assumedBy ? {
|
|
312
312
|
AssumeRolePolicyDocument: {
|
|
313
313
|
Version: "2012-10-17",
|
|
314
|
-
Statement: [
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
314
|
+
Statement: [
|
|
315
|
+
{
|
|
316
|
+
Action: "sts:AssumeRole",
|
|
317
|
+
Effect: "Allow",
|
|
318
|
+
Principal: {
|
|
319
|
+
Service: this.props.assumedBy
|
|
320
|
+
}
|
|
319
321
|
}
|
|
320
|
-
|
|
322
|
+
]
|
|
321
323
|
}
|
|
322
324
|
} : {},
|
|
323
325
|
ManagedPolicyArns: [...this.managedPolicies].map((policy) => policy.arn),
|
|
@@ -692,11 +694,11 @@ var Stack = class {
|
|
|
692
694
|
// src/stack.ts
|
|
693
695
|
var toStack = ({ config: config2, app, stackConfig, bootstrap: bootstrap2, usEastBootstrap, plugins: plugins2, tests }) => {
|
|
694
696
|
const name = stackConfig.name;
|
|
695
|
-
const stack = new Stack(name, config2.app.region).tag("app", config2.app.name).tag("stage", config2.
|
|
697
|
+
const stack = new Stack(name, config2.app.region).tag("app", config2.app.name).tag("stage", config2.stage).tag("stack", name);
|
|
696
698
|
debug("Define stack:", style.info(name));
|
|
697
699
|
debug("Run plugin onStack listeners");
|
|
698
700
|
const bindings = [];
|
|
699
|
-
const
|
|
701
|
+
const bind2 = (cb) => {
|
|
700
702
|
bindings.push(cb);
|
|
701
703
|
};
|
|
702
704
|
for (const plugin of plugins2) {
|
|
@@ -708,16 +710,16 @@ var toStack = ({ config: config2, app, stackConfig, bootstrap: bootstrap2, usEas
|
|
|
708
710
|
bootstrap: bootstrap2,
|
|
709
711
|
usEastBootstrap,
|
|
710
712
|
tests,
|
|
711
|
-
bind
|
|
713
|
+
bind: bind2
|
|
712
714
|
});
|
|
713
715
|
}
|
|
714
716
|
if (stack.size === 0) {
|
|
715
717
|
throw new Error(`Stack ${style.info(name)} has no resources defined`);
|
|
716
718
|
}
|
|
717
719
|
const functions = stack.find(Function);
|
|
718
|
-
for (const
|
|
720
|
+
for (const bind3 of bindings) {
|
|
719
721
|
for (const fn of functions) {
|
|
720
|
-
|
|
722
|
+
bind3(fn);
|
|
721
723
|
}
|
|
722
724
|
}
|
|
723
725
|
return {
|
|
@@ -1439,7 +1441,7 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1439
1441
|
if (typeof fileOrProps === "object" && fileOrProps.permissions) {
|
|
1440
1442
|
lambda.addPermissions(fileOrProps.permissions);
|
|
1441
1443
|
}
|
|
1442
|
-
lambda.addEnvironment("APP", config2.app.name).addEnvironment("STAGE", config2.
|
|
1444
|
+
lambda.addEnvironment("APP", config2.app.name).addEnvironment("STAGE", config2.stage).addEnvironment("STACK", stack.name);
|
|
1443
1445
|
if (props.warm) {
|
|
1444
1446
|
lambda.warmUp(props.warm);
|
|
1445
1447
|
}
|
|
@@ -1749,25 +1751,45 @@ var authPlugin = definePlugin({
|
|
|
1749
1751
|
gen.addInterface("AuthResources", resources);
|
|
1750
1752
|
await write("auth.d.ts", gen, true);
|
|
1751
1753
|
},
|
|
1752
|
-
onStack({ config
|
|
1753
|
-
|
|
1754
|
-
|
|
1754
|
+
// onStack({ config, bootstrap, stackConfig, bind }) {
|
|
1755
|
+
// for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
|
|
1756
|
+
// if (props.access) {
|
|
1757
|
+
// const userPoolId = bootstrap.import(`auth-${id}-user-pool-id`)
|
|
1758
|
+
// const clientId = bootstrap.import(`auth-${id}-client-id`)
|
|
1759
|
+
// const name = constantCase(id)
|
|
1760
|
+
// bind(lambda => {
|
|
1761
|
+
// lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId)
|
|
1762
|
+
// lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId)
|
|
1763
|
+
// if (config.app.defaults.auth?.[id]?.secret) {
|
|
1764
|
+
// const clientSecret = bootstrap.import(`auth-${id}-client-secret`)
|
|
1765
|
+
// lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret)
|
|
1766
|
+
// }
|
|
1767
|
+
// lambda.addPermissions({
|
|
1768
|
+
// actions: ['cognito:*'],
|
|
1769
|
+
// resources: ['*'],
|
|
1770
|
+
// })
|
|
1771
|
+
// })
|
|
1772
|
+
// }
|
|
1773
|
+
// }
|
|
1774
|
+
// },
|
|
1775
|
+
onStack({ config: config2, bootstrap: bootstrap2, bind: bind2 }) {
|
|
1776
|
+
for (const [id, props] of Object.entries(config2.app.defaults.auth)) {
|
|
1777
|
+
bind2((lambda) => {
|
|
1778
|
+
const userPoolArn = bootstrap2.import(`auth-${id}-user-pool-arn`);
|
|
1755
1779
|
const userPoolId = bootstrap2.import(`auth-${id}-user-pool-id`);
|
|
1756
1780
|
const clientId = bootstrap2.import(`auth-${id}-client-id`);
|
|
1757
1781
|
const name = constantCase6(id);
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
resources: ["*"]
|
|
1768
|
-
});
|
|
1782
|
+
lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
|
|
1783
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
|
|
1784
|
+
if (props.secret) {
|
|
1785
|
+
const clientSecret = bootstrap2.import(`auth-${id}-client-secret`);
|
|
1786
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret);
|
|
1787
|
+
}
|
|
1788
|
+
lambda.addPermissions({
|
|
1789
|
+
actions: ["cognito:*"],
|
|
1790
|
+
resources: [userPoolArn]
|
|
1769
1791
|
});
|
|
1770
|
-
}
|
|
1792
|
+
});
|
|
1771
1793
|
}
|
|
1772
1794
|
},
|
|
1773
1795
|
onApp(ctx) {
|
|
@@ -2092,7 +2114,7 @@ var cachePlugin = definePlugin({
|
|
|
2092
2114
|
gen.addInterface("CacheResources", resources);
|
|
2093
2115
|
await write("cache.d.ts", gen, true);
|
|
2094
2116
|
},
|
|
2095
|
-
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind }) {
|
|
2117
|
+
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind: bind2 }) {
|
|
2096
2118
|
for (const [id, props] of Object.entries(stackConfig.caches || {})) {
|
|
2097
2119
|
const name = `${config2.app.name}-${stack.name}-${id}`;
|
|
2098
2120
|
const subnetGroup = new SubnetGroup(id, {
|
|
@@ -2115,7 +2137,7 @@ var cachePlugin = definePlugin({
|
|
|
2115
2137
|
...props
|
|
2116
2138
|
}).dependsOn(subnetGroup, securityGroup);
|
|
2117
2139
|
stack.add(subnetGroup, securityGroup, cluster);
|
|
2118
|
-
|
|
2140
|
+
bind2((lambda) => {
|
|
2119
2141
|
lambda.addEnvironment(`CACHE_${constantCase7(stack.name)}_${constantCase7(id)}_HOST`, cluster.address).addEnvironment(
|
|
2120
2142
|
`CACHE_${constantCase7(stack.name)}_${constantCase7(id)}_PORT`,
|
|
2121
2143
|
props.port.toString()
|
|
@@ -2239,9 +2261,9 @@ var configPlugin = definePlugin({
|
|
|
2239
2261
|
gen.addInterface("ConfigResources", resources.toString());
|
|
2240
2262
|
await write("config.d.ts", gen, true);
|
|
2241
2263
|
},
|
|
2242
|
-
onStack({ bind, config: config2, stackConfig }) {
|
|
2264
|
+
onStack({ bind: bind2, config: config2, stackConfig }) {
|
|
2243
2265
|
const configs = stackConfig.configs;
|
|
2244
|
-
|
|
2266
|
+
bind2((lambda) => {
|
|
2245
2267
|
if (configs && configs.length) {
|
|
2246
2268
|
lambda.addEnvironment("CONFIG", configs.join(","));
|
|
2247
2269
|
lambda.addPermissions({
|
|
@@ -2477,7 +2499,7 @@ var EmailIdentity = class extends Resource {
|
|
|
2477
2499
|
// src/plugins/domain/index.ts
|
|
2478
2500
|
var domainPlugin = definePlugin({
|
|
2479
2501
|
name: "domain",
|
|
2480
|
-
onApp({ config: config2, app, bootstrap: bootstrap2, usEastBootstrap, bind }) {
|
|
2502
|
+
onApp({ config: config2, app, bootstrap: bootstrap2, usEastBootstrap, bind: bind2 }) {
|
|
2481
2503
|
const domains = Object.entries(config2.app.defaults.domains || {});
|
|
2482
2504
|
if (domains.length === 0) {
|
|
2483
2505
|
return;
|
|
@@ -2541,7 +2563,7 @@ var domainPlugin = definePlugin({
|
|
|
2541
2563
|
usEastBootstrap.add(group);
|
|
2542
2564
|
}
|
|
2543
2565
|
}
|
|
2544
|
-
|
|
2566
|
+
bind2(
|
|
2545
2567
|
(lambda) => lambda.addPermissions({
|
|
2546
2568
|
actions: ["ses:*"],
|
|
2547
2569
|
resources: ["*"]
|
|
@@ -3311,12 +3333,15 @@ var Listener = class extends Resource {
|
|
|
3311
3333
|
Certificates: this.props.certificates.map((arn) => ({
|
|
3312
3334
|
CertificateArn: arn
|
|
3313
3335
|
})),
|
|
3314
|
-
...this.attr(
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3336
|
+
...this.attr(
|
|
3337
|
+
"DefaultActions",
|
|
3338
|
+
this.props.defaultActions?.map((action, i) => {
|
|
3339
|
+
return {
|
|
3340
|
+
Order: i + 1,
|
|
3341
|
+
...action.toJSON()
|
|
3342
|
+
};
|
|
3343
|
+
})
|
|
3344
|
+
)
|
|
3320
3345
|
};
|
|
3321
3346
|
}
|
|
3322
3347
|
};
|
|
@@ -3682,7 +3707,10 @@ var EventSourceMapping = class extends Resource {
|
|
|
3682
3707
|
...this.attr("ParallelizationFactor", this.props.parallelizationFactor),
|
|
3683
3708
|
...this.attr("TumblingWindowInSeconds", this.props.tumblingWindow?.toSeconds()),
|
|
3684
3709
|
...this.attr("BisectBatchOnFunctionError", this.props.bisectBatchOnError),
|
|
3685
|
-
...this.attr(
|
|
3710
|
+
...this.attr(
|
|
3711
|
+
"StartingPosition",
|
|
3712
|
+
this.props.startingPosition && constantCase10(this.props.startingPosition)
|
|
3713
|
+
),
|
|
3686
3714
|
...this.attr("StartingPositionTimestamp", this.props.startingPositionTimestamp),
|
|
3687
3715
|
...this.props.maxConcurrency ? {
|
|
3688
3716
|
ScalingConfig: {
|
|
@@ -3743,12 +3771,7 @@ var Queue = class extends Resource {
|
|
|
3743
3771
|
}
|
|
3744
3772
|
get permissions() {
|
|
3745
3773
|
return {
|
|
3746
|
-
actions: [
|
|
3747
|
-
"sqs:SendMessage",
|
|
3748
|
-
"sqs:ReceiveMessage",
|
|
3749
|
-
"sqs:GetQueueUrl",
|
|
3750
|
-
"sqs:GetQueueAttributes"
|
|
3751
|
-
],
|
|
3774
|
+
actions: ["sqs:SendMessage", "sqs:ReceiveMessage", "sqs:GetQueueUrl", "sqs:GetQueueAttributes"],
|
|
3752
3775
|
resources: [
|
|
3753
3776
|
formatArn({
|
|
3754
3777
|
service: "sqs",
|
|
@@ -3855,8 +3878,8 @@ var IotEventSource = class extends Group {
|
|
|
3855
3878
|
// src/plugins/pubsub/index.ts
|
|
3856
3879
|
var pubsubPlugin = definePlugin({
|
|
3857
3880
|
name: "pubsub",
|
|
3858
|
-
onApp({ bind }) {
|
|
3859
|
-
|
|
3881
|
+
onApp({ bind: bind2 }) {
|
|
3882
|
+
bind2((lambda) => {
|
|
3860
3883
|
lambda.addPermissions({
|
|
3861
3884
|
actions: ["iot:publish"],
|
|
3862
3885
|
resources: ["*"]
|
|
@@ -3889,7 +3912,7 @@ type Payload<F extends Func> = Parameters<F>[0]['Records'][number]['body']
|
|
|
3889
3912
|
|
|
3890
3913
|
type Send<Name extends string, F extends Func> = {
|
|
3891
3914
|
readonly name: Name
|
|
3892
|
-
|
|
3915
|
+
batch(items:BatchItem<Payload<F>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
|
|
3893
3916
|
(payload: Payload<F>, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
|
|
3894
3917
|
}
|
|
3895
3918
|
|
|
@@ -3929,7 +3952,7 @@ var queuePlugin = definePlugin({
|
|
|
3929
3952
|
await write("queue.d.ts", gen, true);
|
|
3930
3953
|
},
|
|
3931
3954
|
onStack(ctx) {
|
|
3932
|
-
const { stack, config: config2, stackConfig, bind } = ctx;
|
|
3955
|
+
const { stack, config: config2, stackConfig, bind: bind2 } = ctx;
|
|
3933
3956
|
for (const [id, functionOrProps] of Object.entries(stackConfig.queues || {})) {
|
|
3934
3957
|
const props = typeof functionOrProps === "string" ? { ...config2.app.defaults.queue, consumer: functionOrProps } : { ...config2.app.defaults.queue, ...functionOrProps };
|
|
3935
3958
|
const queue2 = new Queue(id, {
|
|
@@ -3945,7 +3968,7 @@ var queuePlugin = definePlugin({
|
|
|
3945
3968
|
maxBatchingWindow: props.maxBatchingWindow
|
|
3946
3969
|
});
|
|
3947
3970
|
stack.add(queue2, lambda, source);
|
|
3948
|
-
|
|
3971
|
+
bind2((lambda2) => {
|
|
3949
3972
|
lambda2.addPermissions(queue2.permissions);
|
|
3950
3973
|
lambda2.addEnvironment(`QUEUE_${constantCase11(stack.name)}_${constantCase11(id)}_URL`, queue2.url);
|
|
3951
3974
|
});
|
|
@@ -4069,9 +4092,11 @@ var DomainName2 = class extends Resource {
|
|
|
4069
4092
|
properties() {
|
|
4070
4093
|
return {
|
|
4071
4094
|
DomainName: this.props.name,
|
|
4072
|
-
DomainNameConfigurations: [
|
|
4073
|
-
|
|
4074
|
-
|
|
4095
|
+
DomainNameConfigurations: [
|
|
4096
|
+
{
|
|
4097
|
+
CertificateArn: this.props.certificateArn
|
|
4098
|
+
}
|
|
4099
|
+
]
|
|
4075
4100
|
};
|
|
4076
4101
|
}
|
|
4077
4102
|
};
|
|
@@ -4225,13 +4250,13 @@ var searchPlugin = definePlugin({
|
|
|
4225
4250
|
gen.addInterface("SearchResources", resources);
|
|
4226
4251
|
await write("search.d.ts", gen, true);
|
|
4227
4252
|
},
|
|
4228
|
-
onStack({ app, stack, stackConfig, bind }) {
|
|
4253
|
+
onStack({ app, stack, stackConfig, bind: bind2 }) {
|
|
4229
4254
|
for (const id of stackConfig.searchs || []) {
|
|
4230
4255
|
const collection = new Collection(id, {
|
|
4231
4256
|
name: `${app.name}-${stack.name}-${id}`,
|
|
4232
4257
|
type: "search"
|
|
4233
4258
|
});
|
|
4234
|
-
|
|
4259
|
+
bind2((lambda) => {
|
|
4235
4260
|
lambda.addPermissions(collection.permissions);
|
|
4236
4261
|
});
|
|
4237
4262
|
}
|
|
@@ -4258,6 +4283,9 @@ var Distribution = class extends Resource {
|
|
|
4258
4283
|
get domainName() {
|
|
4259
4284
|
return getAtt(this.logicalId, "DomainName");
|
|
4260
4285
|
}
|
|
4286
|
+
get hostedZoneId() {
|
|
4287
|
+
return "Z2FDTNDATAQYW2";
|
|
4288
|
+
}
|
|
4261
4289
|
properties() {
|
|
4262
4290
|
return {
|
|
4263
4291
|
DistributionConfig: {
|
|
@@ -4388,12 +4416,7 @@ var Bucket = class extends Resource {
|
|
|
4388
4416
|
}
|
|
4389
4417
|
get permissions() {
|
|
4390
4418
|
return {
|
|
4391
|
-
actions: [
|
|
4392
|
-
"s3:SendMessage",
|
|
4393
|
-
"s3:ReceiveMessage",
|
|
4394
|
-
"s3:GetQueueUrl",
|
|
4395
|
-
"s3:GetQueueAttributes"
|
|
4396
|
-
],
|
|
4419
|
+
actions: ["s3:SendMessage", "s3:ReceiveMessage", "s3:GetQueueUrl", "s3:GetQueueAttributes"],
|
|
4397
4420
|
resources: [
|
|
4398
4421
|
formatArn({
|
|
4399
4422
|
service: "s3",
|
|
@@ -4508,7 +4531,7 @@ var Files = class extends Asset {
|
|
|
4508
4531
|
hash;
|
|
4509
4532
|
bundle;
|
|
4510
4533
|
s3;
|
|
4511
|
-
async build({
|
|
4534
|
+
async build({ write }) {
|
|
4512
4535
|
const glob2 = new Glob(this.props.pattern ?? "**/*", {
|
|
4513
4536
|
nodir: true,
|
|
4514
4537
|
cwd: this.props.directory
|
|
@@ -4851,7 +4874,7 @@ var sitePlugin = definePlugin({
|
|
|
4851
4874
|
name: domainName,
|
|
4852
4875
|
alias: {
|
|
4853
4876
|
dnsName: distribution.domainName,
|
|
4854
|
-
hostedZoneId:
|
|
4877
|
+
hostedZoneId: distribution.hostedZoneId
|
|
4855
4878
|
}
|
|
4856
4879
|
}).dependsOn(distribution);
|
|
4857
4880
|
stack.add(distribution, invalidateCache, responseHeaders, originRequest, cache, record);
|
|
@@ -4876,7 +4899,7 @@ var storePlugin = definePlugin({
|
|
|
4876
4899
|
gen.addInterface("StoreResources", resources);
|
|
4877
4900
|
await write("store.d.ts", gen, true);
|
|
4878
4901
|
},
|
|
4879
|
-
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind }) {
|
|
4902
|
+
onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind: bind2 }) {
|
|
4880
4903
|
for (const id of stackConfig.stores || []) {
|
|
4881
4904
|
const bucket = new Bucket(id, {
|
|
4882
4905
|
name: `store-${config2.app.name}-${stack.name}-${id}`,
|
|
@@ -4889,7 +4912,7 @@ var storePlugin = definePlugin({
|
|
|
4889
4912
|
}
|
|
4890
4913
|
}).dependsOn(bucket);
|
|
4891
4914
|
stack.add(bucket, custom);
|
|
4892
|
-
|
|
4915
|
+
bind2((lambda) => {
|
|
4893
4916
|
lambda.addPermissions(bucket.permissions);
|
|
4894
4917
|
});
|
|
4895
4918
|
}
|
|
@@ -4924,50 +4947,53 @@ var Table = class extends Resource {
|
|
|
4924
4947
|
return getAtt(this.logicalId, "StreamArn");
|
|
4925
4948
|
}
|
|
4926
4949
|
get permissions() {
|
|
4927
|
-
const permissions = [
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4950
|
+
const permissions = [
|
|
4951
|
+
{
|
|
4952
|
+
actions: [
|
|
4953
|
+
"dynamodb:DescribeTable",
|
|
4954
|
+
"dynamodb:PutItem",
|
|
4955
|
+
"dynamodb:GetItem",
|
|
4956
|
+
"dynamodb:DeleteItem",
|
|
4957
|
+
"dynamodb:TransactWrite",
|
|
4958
|
+
"dynamodb:BatchWriteItem",
|
|
4959
|
+
"dynamodb:BatchGetItem",
|
|
4960
|
+
"dynamodb:ConditionCheckItem",
|
|
4961
|
+
"dynamodb:Query",
|
|
4962
|
+
"dynamodb:Scan"
|
|
4963
|
+
],
|
|
4964
|
+
resources: [
|
|
4965
|
+
formatArn({
|
|
4966
|
+
service: "dynamodb",
|
|
4967
|
+
resource: "table",
|
|
4968
|
+
resourceName: this.name
|
|
4969
|
+
})
|
|
4970
|
+
]
|
|
4971
|
+
}
|
|
4972
|
+
];
|
|
4948
4973
|
const indexNames = Object.keys(this.indexes ?? {});
|
|
4949
4974
|
if (indexNames.length > 0) {
|
|
4950
4975
|
permissions.push({
|
|
4951
4976
|
actions: ["dynamodb:Query"],
|
|
4952
|
-
resources: indexNames.map(
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4977
|
+
resources: indexNames.map(
|
|
4978
|
+
(indexName) => formatArn({
|
|
4979
|
+
service: "dynamodb",
|
|
4980
|
+
resource: "table",
|
|
4981
|
+
resourceName: `${this.name}/index/${indexName}`
|
|
4982
|
+
})
|
|
4983
|
+
)
|
|
4957
4984
|
});
|
|
4958
4985
|
}
|
|
4959
4986
|
return permissions;
|
|
4960
4987
|
}
|
|
4961
4988
|
attributeDefinitions() {
|
|
4962
4989
|
const fields = this.props.fields || {};
|
|
4963
|
-
const attributes = new Set(
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
index.hash,
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
].flat().filter(Boolean));
|
|
4990
|
+
const attributes = new Set(
|
|
4991
|
+
[
|
|
4992
|
+
this.props.hash,
|
|
4993
|
+
this.props.sort,
|
|
4994
|
+
...Object.values(this.props.indexes || {}).map((index) => [index.hash, index.sort])
|
|
4995
|
+
].flat().filter(Boolean)
|
|
4996
|
+
);
|
|
4971
4997
|
const types2 = {
|
|
4972
4998
|
string: "S",
|
|
4973
4999
|
number: "N",
|
|
@@ -5066,7 +5092,7 @@ var tablePlugin = definePlugin({
|
|
|
5066
5092
|
await write("table.d.ts", gen, true);
|
|
5067
5093
|
},
|
|
5068
5094
|
onStack(ctx) {
|
|
5069
|
-
const { config: config2, stack, stackConfig, bind } = ctx;
|
|
5095
|
+
const { config: config2, stack, stackConfig, bind: bind2 } = ctx;
|
|
5070
5096
|
for (const [id, props] of Object.entries(stackConfig.tables || {})) {
|
|
5071
5097
|
const table = new Table(id, {
|
|
5072
5098
|
...props,
|
|
@@ -5091,7 +5117,7 @@ var tablePlugin = definePlugin({
|
|
|
5091
5117
|
}
|
|
5092
5118
|
stack.add(lambda, source);
|
|
5093
5119
|
}
|
|
5094
|
-
|
|
5120
|
+
bind2((lambda) => {
|
|
5095
5121
|
lambda.addPermissions(table.permissions);
|
|
5096
5122
|
});
|
|
5097
5123
|
}
|
|
@@ -5226,9 +5252,9 @@ var topicPlugin = definePlugin({
|
|
|
5226
5252
|
}
|
|
5227
5253
|
},
|
|
5228
5254
|
onStack(ctx) {
|
|
5229
|
-
const { config: config2, stack, stackConfig, bootstrap: bootstrap2, bind } = ctx;
|
|
5255
|
+
const { config: config2, stack, stackConfig, bootstrap: bootstrap2, bind: bind2 } = ctx;
|
|
5230
5256
|
for (const id of stackConfig.topics || []) {
|
|
5231
|
-
|
|
5257
|
+
bind2((lambda) => {
|
|
5232
5258
|
lambda.addPermissions({
|
|
5233
5259
|
actions: ["sns:Publish"],
|
|
5234
5260
|
resources: [
|
|
@@ -5503,7 +5529,7 @@ var toApp = async (config2, filters) => {
|
|
|
5503
5529
|
const usEastBootstrap = new Stack("us-east-bootstrap", "us-east-1");
|
|
5504
5530
|
debug("Run plugin onApp listeners");
|
|
5505
5531
|
const bindings = [];
|
|
5506
|
-
const
|
|
5532
|
+
const bind2 = (cb) => {
|
|
5507
5533
|
bindings.push(cb);
|
|
5508
5534
|
};
|
|
5509
5535
|
for (const plugin of plugins) {
|
|
@@ -5512,7 +5538,7 @@ var toApp = async (config2, filters) => {
|
|
|
5512
5538
|
app,
|
|
5513
5539
|
bootstrap: bootstrap2,
|
|
5514
5540
|
usEastBootstrap,
|
|
5515
|
-
bind,
|
|
5541
|
+
bind: bind2,
|
|
5516
5542
|
tests
|
|
5517
5543
|
});
|
|
5518
5544
|
}
|
|
@@ -5543,9 +5569,9 @@ var toApp = async (config2, filters) => {
|
|
|
5543
5569
|
app.add(usEastBootstrap);
|
|
5544
5570
|
}
|
|
5545
5571
|
const functions = app.find(Function);
|
|
5546
|
-
for (const
|
|
5572
|
+
for (const bind3 of bindings) {
|
|
5547
5573
|
for (const fn of functions) {
|
|
5548
|
-
|
|
5574
|
+
bind3(fn);
|
|
5549
5575
|
}
|
|
5550
5576
|
}
|
|
5551
5577
|
for (const entry of stacks) {
|
|
@@ -5555,9 +5581,9 @@ var toApp = async (config2, filters) => {
|
|
|
5555
5581
|
throw new Error(`Stack dependency not found: ${dep}`);
|
|
5556
5582
|
}
|
|
5557
5583
|
const functions2 = entry.stack.find(Function);
|
|
5558
|
-
for (const
|
|
5584
|
+
for (const bind3 of depStack.bindings) {
|
|
5559
5585
|
for (const fn of functions2) {
|
|
5560
|
-
|
|
5586
|
+
bind3(fn);
|
|
5561
5587
|
}
|
|
5562
5588
|
}
|
|
5563
5589
|
}
|
|
@@ -5835,7 +5861,10 @@ var TriggersSchema = z8.object({
|
|
|
5835
5861
|
var AuthSchema = z8.record(
|
|
5836
5862
|
ResourceIdSchema,
|
|
5837
5863
|
z8.object({
|
|
5838
|
-
access:
|
|
5864
|
+
// access: z
|
|
5865
|
+
// .boolean()
|
|
5866
|
+
// .default(false)
|
|
5867
|
+
// .describe('Give access to every function in this stack to your cognito instance.'),
|
|
5839
5868
|
triggers: TriggersSchema.optional()
|
|
5840
5869
|
})
|
|
5841
5870
|
).optional().describe("Define the auth triggers in your stack.");
|
|
@@ -6048,7 +6077,11 @@ var AppSchema = z15.object({
|
|
|
6048
6077
|
name: ResourceIdSchema.describe("App name."),
|
|
6049
6078
|
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
6050
6079
|
profile: z15.string().describe("The AWS profile to deploy to."),
|
|
6051
|
-
stage:
|
|
6080
|
+
// stage: z
|
|
6081
|
+
// .string()
|
|
6082
|
+
// .regex(/^[a-z]+$/)
|
|
6083
|
+
// .default('prod')
|
|
6084
|
+
// .describe('The deployment stage.'),
|
|
6052
6085
|
defaults: z15.object({
|
|
6053
6086
|
auth: AuthDefaultSchema,
|
|
6054
6087
|
domains: DomainsDefaultSchema,
|
|
@@ -6288,6 +6321,10 @@ var SitesSchema = z26.record(
|
|
|
6288
6321
|
subDomain: z26.string().optional(),
|
|
6289
6322
|
static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
|
|
6290
6323
|
ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
|
|
6324
|
+
// bind: z.object({
|
|
6325
|
+
// auth:
|
|
6326
|
+
// h
|
|
6327
|
+
// }).optional(),
|
|
6291
6328
|
// ssr: z.union([
|
|
6292
6329
|
// FunctionSchema.optional(),
|
|
6293
6330
|
// z.object({
|
|
@@ -6492,13 +6529,17 @@ var loadConfig = async (options) => {
|
|
|
6492
6529
|
const stackConfig = await readConfigWithStage(file, options.stage);
|
|
6493
6530
|
setLocalBasePath(join7(process.cwd(), dirname5(file)));
|
|
6494
6531
|
const stack = await parseConfig(StackSchema, file, stackConfig);
|
|
6495
|
-
stacks.push(
|
|
6532
|
+
stacks.push({
|
|
6533
|
+
...stack,
|
|
6534
|
+
file
|
|
6535
|
+
});
|
|
6496
6536
|
}
|
|
6497
6537
|
return {
|
|
6498
6538
|
app,
|
|
6499
6539
|
stacks,
|
|
6500
6540
|
account,
|
|
6501
|
-
credentials
|
|
6541
|
+
credentials,
|
|
6542
|
+
stage: options.stage
|
|
6502
6543
|
};
|
|
6503
6544
|
};
|
|
6504
6545
|
|
|
@@ -6539,12 +6580,12 @@ var list = (data) => {
|
|
|
6539
6580
|
};
|
|
6540
6581
|
|
|
6541
6582
|
// src/cli/ui/layout/header.ts
|
|
6542
|
-
var header = (
|
|
6583
|
+
var header = (config2) => {
|
|
6543
6584
|
return list({
|
|
6544
|
-
App: app.name,
|
|
6545
|
-
Stage:
|
|
6546
|
-
Region: app.region,
|
|
6547
|
-
Profile: app.profile
|
|
6585
|
+
App: config2.app.name,
|
|
6586
|
+
Stage: config2.stage,
|
|
6587
|
+
Region: config2.app.region,
|
|
6588
|
+
Profile: config2.app.profile
|
|
6548
6589
|
});
|
|
6549
6590
|
};
|
|
6550
6591
|
|
|
@@ -7062,7 +7103,7 @@ var layout = async (cb) => {
|
|
|
7062
7103
|
try {
|
|
7063
7104
|
const options = program.optsWithGlobals();
|
|
7064
7105
|
const config2 = await loadConfig(options);
|
|
7065
|
-
term.out.write(header(config2
|
|
7106
|
+
term.out.write(header(config2));
|
|
7066
7107
|
term.out.gap();
|
|
7067
7108
|
await cb(config2, term.out.write.bind(term.out), term);
|
|
7068
7109
|
} catch (error) {
|
|
@@ -8516,7 +8557,7 @@ var dev = (program2) => {
|
|
|
8516
8557
|
const options = program2.optsWithGlobals();
|
|
8517
8558
|
await cleanUp();
|
|
8518
8559
|
await write(typesGenerator(config2));
|
|
8519
|
-
|
|
8560
|
+
await watchConfig(
|
|
8520
8561
|
options,
|
|
8521
8562
|
async (config3) => {
|
|
8522
8563
|
await cleanUp();
|
|
@@ -8598,6 +8639,70 @@ var del2 = (program2) => {
|
|
|
8598
8639
|
});
|
|
8599
8640
|
};
|
|
8600
8641
|
|
|
8642
|
+
// src/cli/command/bind.ts
|
|
8643
|
+
import { spawn } from "child_process";
|
|
8644
|
+
import { paramCase as paramCase8 } from "change-case";
|
|
8645
|
+
import { GetFunctionCommand, LambdaClient } from "@aws-sdk/client-lambda";
|
|
8646
|
+
var bind = (program2) => {
|
|
8647
|
+
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) => {
|
|
8648
|
+
await layout(async (config2, write) => {
|
|
8649
|
+
const command = commands3.join(" ");
|
|
8650
|
+
const stackConfig = config2.stacks.find((s) => s.name === stack);
|
|
8651
|
+
if (!stackConfig) {
|
|
8652
|
+
throw new Error(`[${stack}] Stack doesn't exist.`);
|
|
8653
|
+
}
|
|
8654
|
+
const siteConfig = stackConfig.sites?.[site];
|
|
8655
|
+
if (!siteConfig) {
|
|
8656
|
+
throw new Error(`[${site}] Site doesn't exist.`);
|
|
8657
|
+
}
|
|
8658
|
+
let functionEnv = {};
|
|
8659
|
+
if (siteConfig.ssr) {
|
|
8660
|
+
const client = new LambdaClient({
|
|
8661
|
+
credentials: config2.credentials,
|
|
8662
|
+
region: config2.app.region
|
|
8663
|
+
});
|
|
8664
|
+
const lambdaLoader = write(loadingDialog("Loading SSR lambda environment variables..."));
|
|
8665
|
+
try {
|
|
8666
|
+
const result = await client.send(
|
|
8667
|
+
new GetFunctionCommand({
|
|
8668
|
+
FunctionName: paramCase8(`${config2.app.name}-${stack}-site-${site}`)
|
|
8669
|
+
})
|
|
8670
|
+
);
|
|
8671
|
+
functionEnv = result.Configuration?.Environment?.Variables ?? {};
|
|
8672
|
+
} catch (error) {
|
|
8673
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
8674
|
+
write(dialog("warning", [`The SSR lambda hasn't been deployed yet.`]));
|
|
8675
|
+
} else {
|
|
8676
|
+
throw error;
|
|
8677
|
+
}
|
|
8678
|
+
} finally {
|
|
8679
|
+
lambdaLoader("Done loading SSR lambda environment variables");
|
|
8680
|
+
}
|
|
8681
|
+
}
|
|
8682
|
+
const credentialsLoader = write(loadingDialog("Loading AWS credentials..."));
|
|
8683
|
+
const credentials = await config2.credentials();
|
|
8684
|
+
credentialsLoader("Done loading AWS credentials");
|
|
8685
|
+
spawn(command, {
|
|
8686
|
+
env: {
|
|
8687
|
+
// Pass the process env vars
|
|
8688
|
+
...process.env,
|
|
8689
|
+
// Pass the lambda env vars
|
|
8690
|
+
...functionEnv,
|
|
8691
|
+
// Basic info
|
|
8692
|
+
AWS_REGION: config2.app.region,
|
|
8693
|
+
AWS_ACCOUNT_ID: config2.account,
|
|
8694
|
+
// Give AWS access
|
|
8695
|
+
AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
8696
|
+
AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
8697
|
+
AWS_SESSION_TOKEN: credentials.sessionToken
|
|
8698
|
+
},
|
|
8699
|
+
stdio: "inherit",
|
|
8700
|
+
shell: true
|
|
8701
|
+
});
|
|
8702
|
+
});
|
|
8703
|
+
});
|
|
8704
|
+
};
|
|
8705
|
+
|
|
8601
8706
|
// src/cli/program.ts
|
|
8602
8707
|
var program = new Command();
|
|
8603
8708
|
program.name(logo().join("").replace(/\s+/, ""));
|
|
@@ -8626,6 +8731,7 @@ var commands2 = [
|
|
|
8626
8731
|
deploy,
|
|
8627
8732
|
del2,
|
|
8628
8733
|
dev,
|
|
8734
|
+
bind,
|
|
8629
8735
|
config,
|
|
8630
8736
|
test
|
|
8631
8737
|
// draw,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|