sst 2.5.6 → 2.5.8
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/cli/commands/bind.js +17 -5
- package/cli/commands/secrets/load.d.ts +15 -0
- package/cli/commands/secrets/load.js +41 -0
- package/cli/commands/secrets/secrets.js +2 -0
- package/cli/commands/secrets/set.js +1 -1
- package/config.d.ts +1 -1
- package/config.js +3 -3
- package/constructs/NextjsSite.js +5 -1
- package/constructs/SsrSite.d.ts +7 -2
- package/constructs/SsrSite.js +14 -9
- package/credentials.js +1 -0
- package/node/job/index.d.ts +1 -1
- package/node/job/index.js +1 -1
- package/package.json +2 -1
- package/sst.mjs +74 -9
package/cli/commands/bind.js
CHANGED
|
@@ -8,6 +8,7 @@ export const bind = (program) => program
|
|
|
8
8
|
.example(`sst bind "vitest run"`, "Bind your resources to your tests")
|
|
9
9
|
.example(`sst bind "tsx scripts/myscript.ts"`, "Bind your resources to a script"), async (args) => {
|
|
10
10
|
const { spawn } = await import("child_process");
|
|
11
|
+
const kill = await import("tree-kill");
|
|
11
12
|
const { useProject } = await import("../../project.js");
|
|
12
13
|
const { useBus } = await import("../../bus.js");
|
|
13
14
|
const { useIOT } = await import("../../iot.js");
|
|
@@ -112,7 +113,7 @@ export const bind = (program) => program
|
|
|
112
113
|
Colors.line(`\n`, `Your AWS session is about to expire. Creating a new session and restarting \`${command}\`...`);
|
|
113
114
|
bindSite("iam_expired");
|
|
114
115
|
}, expireAt - Date.now());
|
|
115
|
-
runCommand({
|
|
116
|
+
await runCommand({
|
|
116
117
|
...siteConfig.envs,
|
|
117
118
|
AWS_ACCESS_KEY_ID: credentials.AccessKeyId,
|
|
118
119
|
AWS_SECRET_ACCESS_KEY: credentials.SecretAccessKey,
|
|
@@ -122,14 +123,14 @@ export const bind = (program) => program
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
// Fallback to use local IAM credentials
|
|
125
|
-
runCommand({
|
|
126
|
+
await runCommand({
|
|
126
127
|
...siteConfig.envs,
|
|
127
128
|
...(await localIamCredentials()),
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
131
|
async function bindScript() {
|
|
131
132
|
const { Config } = await import("../../config.js");
|
|
132
|
-
runCommand({
|
|
133
|
+
await runCommand({
|
|
133
134
|
...(await Config.env()),
|
|
134
135
|
...(await localIamCredentials()),
|
|
135
136
|
});
|
|
@@ -234,10 +235,21 @@ export const bind = (program) => program
|
|
|
234
235
|
AWS_SESSION_TOKEN: credentials.sessionToken,
|
|
235
236
|
};
|
|
236
237
|
}
|
|
237
|
-
function runCommand(envs) {
|
|
238
|
+
async function runCommand(envs) {
|
|
238
239
|
Colors.gap();
|
|
239
240
|
if (p) {
|
|
240
|
-
p.
|
|
241
|
+
p.removeAllListeners("exit");
|
|
242
|
+
// Note: calling p.kill() does not kill child processes. And in the
|
|
243
|
+
// cases of Next.js and CRA, servers are child processes. Need to
|
|
244
|
+
// kill the entire process tree to free up port ie. 3000.
|
|
245
|
+
await new Promise((resolve, reject) => {
|
|
246
|
+
kill.default(p?.pid, (error) => {
|
|
247
|
+
if (error) {
|
|
248
|
+
return reject(error);
|
|
249
|
+
}
|
|
250
|
+
resolve(true);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
241
253
|
}
|
|
242
254
|
p = spawn(command, {
|
|
243
255
|
env: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
import type { Program } from "../../program.js";
|
|
3
|
+
export declare const load: (program: Program) => import("yargs").Argv<{
|
|
4
|
+
stage: string | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
profile: string | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
filename: string;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const load = (program) => program.command("load <filename>", "Loads secrets from an .env file", (yargs) => yargs.positional("filename", {
|
|
2
|
+
type: "string",
|
|
3
|
+
demandOption: true,
|
|
4
|
+
}), async (args) => {
|
|
5
|
+
const { Config } = await import("../../../config.js");
|
|
6
|
+
const { Colors } = await import("../../colors.js");
|
|
7
|
+
const { blue } = await import("colorette");
|
|
8
|
+
const { createSpinner } = await import("../../spinner.js");
|
|
9
|
+
const { parse } = await import("dotenv");
|
|
10
|
+
const fs = await import("fs/promises");
|
|
11
|
+
// Parse .env file
|
|
12
|
+
const fileContent = await fs.readFile(args.filename, "utf-8");
|
|
13
|
+
const envVars = parse(fileContent);
|
|
14
|
+
// Set secrets
|
|
15
|
+
const setting = createSpinner(` Setting secrets from "${args.filename}"`).start();
|
|
16
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
17
|
+
await Config.setSecret({ key, value });
|
|
18
|
+
}
|
|
19
|
+
setting.succeed();
|
|
20
|
+
// Restart functions & sites
|
|
21
|
+
const envNames = Object.keys(envVars);
|
|
22
|
+
const restarting = createSpinner(` Restarting all resources using ${blue(envNames.join(", "))}...`).start();
|
|
23
|
+
const { edgeSites, sites, placeholderSites, functions } = await Config.restart(envNames);
|
|
24
|
+
restarting.stop().clear();
|
|
25
|
+
const siteCount = sites.length + placeholderSites.length;
|
|
26
|
+
if (siteCount > 0) {
|
|
27
|
+
Colors.line(Colors.success(`✔ `), siteCount === 1
|
|
28
|
+
? `Reloaded ${siteCount} site`
|
|
29
|
+
: `Reloaded ${siteCount} sites`);
|
|
30
|
+
}
|
|
31
|
+
const functionCount = functions.length;
|
|
32
|
+
if (functionCount > 0) {
|
|
33
|
+
Colors.line(Colors.success(`✔ `), functionCount === 1
|
|
34
|
+
? `Reloaded ${functionCount} function`
|
|
35
|
+
: `Reloaded ${functionCount} functions`);
|
|
36
|
+
}
|
|
37
|
+
edgeSites.forEach(({ id, type }) => {
|
|
38
|
+
Colors.line(Colors.primary(`➜ `), `Redeploy the "${id}" ${type} to use the new secret`);
|
|
39
|
+
});
|
|
40
|
+
process.exit(0);
|
|
41
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { get } from "./get.js";
|
|
2
2
|
import { list } from "./list.js";
|
|
3
|
+
import { load } from "./load.js";
|
|
3
4
|
import { remove } from "./remove.js";
|
|
4
5
|
import { set } from "./set.js";
|
|
5
6
|
export function secrets(program) {
|
|
@@ -7,6 +8,7 @@ export function secrets(program) {
|
|
|
7
8
|
yargs.demandCommand(1);
|
|
8
9
|
set(yargs);
|
|
9
10
|
get(yargs);
|
|
11
|
+
load(yargs);
|
|
10
12
|
list(yargs);
|
|
11
13
|
remove(yargs);
|
|
12
14
|
return yargs;
|
|
@@ -27,7 +27,7 @@ export const set = (program) => program.command("set <name> <value>", "Set the v
|
|
|
27
27
|
setting.succeed();
|
|
28
28
|
// Restart functions & sites
|
|
29
29
|
const restarting = createSpinner(` Reloading all resources using ${blue(args.name)}...`).start();
|
|
30
|
-
const { edgeSites, sites, placeholderSites, functions } = await Config.restart(args.name);
|
|
30
|
+
const { edgeSites, sites, placeholderSites, functions } = await Config.restart([args.name]);
|
|
31
31
|
restarting.stop().clear();
|
|
32
32
|
const siteCount = sites.length + placeholderSites.length;
|
|
33
33
|
if (siteCount > 0) {
|
package/config.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare namespace Config {
|
|
|
46
46
|
key: string;
|
|
47
47
|
fallback?: boolean;
|
|
48
48
|
}): Promise<void>;
|
|
49
|
-
function restart(
|
|
49
|
+
function restart(keys: string[]): Promise<{
|
|
50
50
|
edgeSites: SsrSiteMetadata[];
|
|
51
51
|
sites: SsrSiteMetadata[];
|
|
52
52
|
placeholderSites: SsrSiteMetadata[];
|
package/config.js
CHANGED
|
@@ -115,7 +115,7 @@ export var Config;
|
|
|
115
115
|
}));
|
|
116
116
|
}
|
|
117
117
|
Config.removeSecret = removeSecret;
|
|
118
|
-
async function restart(
|
|
118
|
+
async function restart(keys) {
|
|
119
119
|
const metadata = await Stacks.metadata();
|
|
120
120
|
const siteData = Object.values(metadata)
|
|
121
121
|
.flat()
|
|
@@ -123,7 +123,7 @@ export var Config;
|
|
|
123
123
|
c.type === "NextjsSite" ||
|
|
124
124
|
c.type === "RemixSite" ||
|
|
125
125
|
c.type === "SolidStartSite")
|
|
126
|
-
.filter((c) => c.data.secrets.includes(key));
|
|
126
|
+
.filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
127
127
|
const siteDataPlaceholder = siteData.filter((c) => c.data.mode === "placeholder");
|
|
128
128
|
const siteDataEdge = siteData
|
|
129
129
|
.filter((c) => c.data.mode === "deployed")
|
|
@@ -137,7 +137,7 @@ export var Config;
|
|
|
137
137
|
.filter((c) => c.type === "Function")
|
|
138
138
|
// filter out SSR functions for sites
|
|
139
139
|
.filter((c) => !regionalSiteArns.includes(c.data.arn))
|
|
140
|
-
.filter((c) => c.data.secrets.includes(key));
|
|
140
|
+
.filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
141
141
|
// Restart sites
|
|
142
142
|
const restartedSites = (await Promise.all(siteDataRegional.map(async (s) => {
|
|
143
143
|
const restarted = await restartFunction(s.data.server);
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -26,7 +26,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
|
26
26
|
export class NextjsSite extends SsrSite {
|
|
27
27
|
constructor(scope, id, props) {
|
|
28
28
|
super(scope, id, {
|
|
29
|
-
buildCommand: "npx --yes open-next
|
|
29
|
+
buildCommand: "npx --yes open-next@~1.1.0 build",
|
|
30
30
|
...props,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -203,6 +203,7 @@ export class NextjsSite extends SsrSite {
|
|
|
203
203
|
buildServerBehaviorForRegional(serverOrigin, cachePolicy, originRequestPolicy) {
|
|
204
204
|
return {
|
|
205
205
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
206
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
206
207
|
origin: serverOrigin,
|
|
207
208
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
208
209
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
@@ -214,6 +215,7 @@ export class NextjsSite extends SsrSite {
|
|
|
214
215
|
buildServerBehaviorForEdge(functionVersion, s3Origin, cachePolicy, originRequestPolicy) {
|
|
215
216
|
return {
|
|
216
217
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
218
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
217
219
|
origin: s3Origin,
|
|
218
220
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
219
221
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
@@ -268,6 +270,7 @@ export class NextjsSite extends SsrSite {
|
|
|
268
270
|
return {
|
|
269
271
|
origin: fallbackOriginGroup,
|
|
270
272
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
273
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
271
274
|
compress: true,
|
|
272
275
|
cachePolicy,
|
|
273
276
|
originRequestPolicy,
|
|
@@ -279,6 +282,7 @@ export class NextjsSite extends SsrSite {
|
|
|
279
282
|
const cfDistributionProps = cdk?.distribution || {};
|
|
280
283
|
return {
|
|
281
284
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
285
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
282
286
|
origin: s3Origin,
|
|
283
287
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
284
288
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Construct } from "constructs";
|
|
|
2
2
|
import { Bucket, BucketProps, IBucket } from "aws-cdk-lib/aws-s3";
|
|
3
3
|
import { Function as CdkFunction, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
4
4
|
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
5
|
-
import { Distribution, ICachePolicy, BehaviorOptions, CachePolicy } from "aws-cdk-lib/aws-cloudfront";
|
|
5
|
+
import { Distribution, ICachePolicy, BehaviorOptions, CachePolicy, Function as CfFunction, FunctionEventType as CfFunctionEventType } from "aws-cdk-lib/aws-cloudfront";
|
|
6
6
|
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
7
7
|
import { SSTConstruct } from "./Construct.js";
|
|
8
8
|
import { NodeJSProps, Function } from "./Function.js";
|
|
@@ -201,6 +201,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
201
201
|
protected serverLambdaForRegional?: CdkFunction;
|
|
202
202
|
private serverLambdaForDev?;
|
|
203
203
|
private bucket;
|
|
204
|
+
private cfFunction;
|
|
204
205
|
private distribution;
|
|
205
206
|
private hostedZone?;
|
|
206
207
|
private certificate?;
|
|
@@ -262,12 +263,16 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
262
263
|
private createFunctionPermissionsForRegional;
|
|
263
264
|
private createFunctionPermissionsForEdge;
|
|
264
265
|
private validateCloudFrontDistributionSettings;
|
|
266
|
+
private createCloudFrontFunction;
|
|
265
267
|
protected createCloudFrontDistributionForRegional(): Distribution;
|
|
266
268
|
protected createCloudFrontDistributionForEdge(): Distribution;
|
|
267
269
|
protected buildDistributionDomainNames(): string[];
|
|
268
270
|
protected buildDefaultBehaviorForRegional(): BehaviorOptions;
|
|
269
271
|
private buildDefaultBehaviorForEdge;
|
|
270
|
-
|
|
272
|
+
protected buildBehaviorFunctionAssociations(): {
|
|
273
|
+
eventType: CfFunctionEventType;
|
|
274
|
+
function: CfFunction;
|
|
275
|
+
}[];
|
|
271
276
|
private buildStaticFileBehaviors;
|
|
272
277
|
protected buildServerCachePolicy(): CachePolicy;
|
|
273
278
|
protected buildServerOriginRequestPolicy(): import("aws-cdk-lib/aws-cloudfront").IOriginRequestPolicy;
|
package/constructs/SsrSite.js
CHANGED
|
@@ -49,6 +49,7 @@ export class SsrSite extends Construct {
|
|
|
49
49
|
serverLambdaForRegional;
|
|
50
50
|
serverLambdaForDev;
|
|
51
51
|
bucket;
|
|
52
|
+
cfFunction;
|
|
52
53
|
distribution;
|
|
53
54
|
hostedZone;
|
|
54
55
|
certificate;
|
|
@@ -73,7 +74,7 @@ export class SsrSite extends Construct {
|
|
|
73
74
|
useSites().add(id, this.constructor.name, this.props);
|
|
74
75
|
if (this.doNotDeploy) {
|
|
75
76
|
// @ts-ignore
|
|
76
|
-
this.bucket = this.distribution = null;
|
|
77
|
+
this.cfFunction = this.bucket = this.distribution = null;
|
|
77
78
|
this.serverLambdaForDev = this.createFunctionForDev();
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -101,6 +102,7 @@ export class SsrSite extends Construct {
|
|
|
101
102
|
const s3deployCR = this.createS3Deployment(cliLayer, assets, assetFileOptions);
|
|
102
103
|
// Create CloudFront
|
|
103
104
|
this.validateCloudFrontDistributionSettings();
|
|
105
|
+
this.cfFunction = this.createCloudFrontFunction();
|
|
104
106
|
this.distribution = this.props.edge
|
|
105
107
|
? this.createCloudFrontDistributionForEdge()
|
|
106
108
|
: this.createCloudFrontDistributionForRegional();
|
|
@@ -458,6 +460,16 @@ export class SsrSite extends Construct {
|
|
|
458
460
|
throw new Error(`Do not configure the "cfDistribution.domainNames". Use the "customDomain" to configure the domain name.`);
|
|
459
461
|
}
|
|
460
462
|
}
|
|
463
|
+
createCloudFrontFunction() {
|
|
464
|
+
return new CfFunction(this, "CloudFrontFunction", {
|
|
465
|
+
code: CfFunctionCode.fromInline(`
|
|
466
|
+
function handler(event) {
|
|
467
|
+
var request = event.request;
|
|
468
|
+
request.headers["x-forwarded-host"] = request.headers.host;
|
|
469
|
+
return request;
|
|
470
|
+
}`),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
461
473
|
createCloudFrontDistributionForRegional() {
|
|
462
474
|
const { cdk } = this.props;
|
|
463
475
|
const cfDistributionProps = cdk?.distribution || {};
|
|
@@ -560,14 +572,7 @@ export class SsrSite extends Construct {
|
|
|
560
572
|
return [
|
|
561
573
|
{
|
|
562
574
|
eventType: CfFunctionEventType.VIEWER_REQUEST,
|
|
563
|
-
function:
|
|
564
|
-
code: CfFunctionCode.fromInline(`
|
|
565
|
-
function handler(event) {
|
|
566
|
-
var request = event.request;
|
|
567
|
-
request.headers["x-forwarded-host"] = request.headers.host;
|
|
568
|
-
return request;
|
|
569
|
-
}`),
|
|
570
|
-
}),
|
|
575
|
+
function: this.cfFunction,
|
|
571
576
|
},
|
|
572
577
|
];
|
|
573
578
|
}
|
package/credentials.js
CHANGED
package/node/job/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare function JobControl<Name extends keyof JobResources>(name: Name): {
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
|
-
* declare module "
|
|
20
|
+
* declare module "sst/node/job" {
|
|
21
21
|
* export interface JobTypes {
|
|
22
22
|
* MyJob: {
|
|
23
23
|
* title: string;
|
package/node/job/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sst",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"bin": {
|
|
5
5
|
"sst": "cli/sst.js"
|
|
6
6
|
},
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"react": "18.2.0",
|
|
81
81
|
"remeda": "^1.3.0",
|
|
82
82
|
"sst-aws-cdk": "2.62.2-3",
|
|
83
|
+
"tree-kill": "^1.2.2",
|
|
83
84
|
"undici": "^5.12.0",
|
|
84
85
|
"uuid": "^9.0.0",
|
|
85
86
|
"ws": "^8.11.0",
|
package/sst.mjs
CHANGED
|
@@ -1601,6 +1601,7 @@ function useAWSClient(client, force = false) {
|
|
|
1601
1601
|
retryDecider: (e) => {
|
|
1602
1602
|
if (e.code === "ENOTFOUND") {
|
|
1603
1603
|
printNoInternet();
|
|
1604
|
+
return true;
|
|
1604
1605
|
}
|
|
1605
1606
|
if ([
|
|
1606
1607
|
"ThrottlingException",
|
|
@@ -6697,18 +6698,18 @@ var init_config = __esm({
|
|
|
6697
6698
|
);
|
|
6698
6699
|
}
|
|
6699
6700
|
Config2.removeSecret = removeSecret;
|
|
6700
|
-
async function restart(
|
|
6701
|
+
async function restart(keys) {
|
|
6701
6702
|
const metadata3 = await stacks_exports.metadata();
|
|
6702
6703
|
const siteData = Object.values(metadata3).flat().filter(
|
|
6703
6704
|
(c) => c.type === "AstroSite" || c.type === "NextjsSite" || c.type === "RemixSite" || c.type === "SolidStartSite"
|
|
6704
|
-
).filter((c) => c.data.secrets.includes(key));
|
|
6705
|
+
).filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
6705
6706
|
const siteDataPlaceholder = siteData.filter(
|
|
6706
6707
|
(c) => c.data.mode === "placeholder"
|
|
6707
6708
|
);
|
|
6708
6709
|
const siteDataEdge = siteData.filter((c) => c.data.mode === "deployed").filter((c) => c.data.edge);
|
|
6709
6710
|
const siteDataRegional = siteData.filter((c) => c.data.mode === "deployed").filter((c) => !c.data.edge);
|
|
6710
6711
|
const regionalSiteArns = siteData.map((s) => s.data.server);
|
|
6711
|
-
const functionData = Object.values(metadata3).flat().filter((c) => c.type === "Function").filter((c) => !regionalSiteArns.includes(c.data.arn)).filter((c) => c.data.secrets.includes(key));
|
|
6712
|
+
const functionData = Object.values(metadata3).flat().filter((c) => c.type === "Function").filter((c) => !regionalSiteArns.includes(c.data.arn)).filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
6712
6713
|
const restartedSites = (await Promise.all(
|
|
6713
6714
|
siteDataRegional.map(async (s) => {
|
|
6714
6715
|
const restarted = await restartFunction(s.data.server);
|
|
@@ -7143,6 +7144,7 @@ var bind = (program2) => program2.command(
|
|
|
7143
7144
|
),
|
|
7144
7145
|
async (args) => {
|
|
7145
7146
|
const { spawn: spawn7 } = await import("child_process");
|
|
7147
|
+
const kill = await import("tree-kill");
|
|
7146
7148
|
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
7147
7149
|
const { useBus: useBus2 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
|
|
7148
7150
|
const { useIOT: useIOT2 } = await Promise.resolve().then(() => (init_iot(), iot_exports));
|
|
@@ -7270,7 +7272,7 @@ var bind = (program2) => program2.command(
|
|
|
7270
7272
|
);
|
|
7271
7273
|
bindSite("iam_expired");
|
|
7272
7274
|
}, expireAt - Date.now());
|
|
7273
|
-
runCommand({
|
|
7275
|
+
await runCommand({
|
|
7274
7276
|
...siteConfig.envs,
|
|
7275
7277
|
AWS_ACCESS_KEY_ID: credentials.AccessKeyId,
|
|
7276
7278
|
AWS_SECRET_ACCESS_KEY: credentials.SecretAccessKey,
|
|
@@ -7279,14 +7281,14 @@ var bind = (program2) => program2.command(
|
|
|
7279
7281
|
return;
|
|
7280
7282
|
}
|
|
7281
7283
|
}
|
|
7282
|
-
runCommand({
|
|
7284
|
+
await runCommand({
|
|
7283
7285
|
...siteConfig.envs,
|
|
7284
7286
|
...await localIamCredentials()
|
|
7285
7287
|
});
|
|
7286
7288
|
}
|
|
7287
7289
|
async function bindScript() {
|
|
7288
7290
|
const { Config: Config2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
7289
|
-
runCommand({
|
|
7291
|
+
await runCommand({
|
|
7290
7292
|
...await Config2.env(),
|
|
7291
7293
|
...await localIamCredentials()
|
|
7292
7294
|
});
|
|
@@ -7385,10 +7387,18 @@ var bind = (program2) => program2.command(
|
|
|
7385
7387
|
AWS_SESSION_TOKEN: credentials.sessionToken
|
|
7386
7388
|
};
|
|
7387
7389
|
}
|
|
7388
|
-
function runCommand(envs) {
|
|
7390
|
+
async function runCommand(envs) {
|
|
7389
7391
|
Colors2.gap();
|
|
7390
7392
|
if (p) {
|
|
7391
|
-
p.
|
|
7393
|
+
p.removeAllListeners("exit");
|
|
7394
|
+
await new Promise((resolve, reject) => {
|
|
7395
|
+
kill.default(p?.pid, (error2) => {
|
|
7396
|
+
if (error2) {
|
|
7397
|
+
return reject(error2);
|
|
7398
|
+
}
|
|
7399
|
+
resolve(true);
|
|
7400
|
+
});
|
|
7401
|
+
});
|
|
7392
7402
|
}
|
|
7393
7403
|
p = spawn7(command, {
|
|
7394
7404
|
env: {
|
|
@@ -7711,6 +7721,60 @@ var list = (program2) => program2.command(
|
|
|
7711
7721
|
}
|
|
7712
7722
|
);
|
|
7713
7723
|
|
|
7724
|
+
// src/cli/commands/secrets/load.ts
|
|
7725
|
+
var load2 = (program2) => program2.command(
|
|
7726
|
+
"load <filename>",
|
|
7727
|
+
"Loads secrets from an .env file",
|
|
7728
|
+
(yargs2) => yargs2.positional("filename", {
|
|
7729
|
+
type: "string",
|
|
7730
|
+
demandOption: true
|
|
7731
|
+
}),
|
|
7732
|
+
async (args) => {
|
|
7733
|
+
const { Config: Config2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
7734
|
+
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
7735
|
+
const { blue: blue4 } = await import("colorette");
|
|
7736
|
+
const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
|
|
7737
|
+
const { parse: parse2 } = await import("dotenv");
|
|
7738
|
+
const fs18 = await import("fs/promises");
|
|
7739
|
+
const fileContent = await fs18.readFile(args.filename, "utf-8");
|
|
7740
|
+
const envVars = parse2(fileContent);
|
|
7741
|
+
const setting = createSpinner2(
|
|
7742
|
+
` Setting secrets from "${args.filename}"`
|
|
7743
|
+
).start();
|
|
7744
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
7745
|
+
await Config2.setSecret({ key, value });
|
|
7746
|
+
}
|
|
7747
|
+
setting.succeed();
|
|
7748
|
+
const envNames = Object.keys(envVars);
|
|
7749
|
+
const restarting = createSpinner2(
|
|
7750
|
+
` Restarting all resources using ${blue4(envNames.join(", "))}...`
|
|
7751
|
+
).start();
|
|
7752
|
+
const { edgeSites, sites, placeholderSites, functions } = await Config2.restart(envNames);
|
|
7753
|
+
restarting.stop().clear();
|
|
7754
|
+
const siteCount = sites.length + placeholderSites.length;
|
|
7755
|
+
if (siteCount > 0) {
|
|
7756
|
+
Colors2.line(
|
|
7757
|
+
Colors2.success(`\u2714 `),
|
|
7758
|
+
siteCount === 1 ? `Reloaded ${siteCount} site` : `Reloaded ${siteCount} sites`
|
|
7759
|
+
);
|
|
7760
|
+
}
|
|
7761
|
+
const functionCount = functions.length;
|
|
7762
|
+
if (functionCount > 0) {
|
|
7763
|
+
Colors2.line(
|
|
7764
|
+
Colors2.success(`\u2714 `),
|
|
7765
|
+
functionCount === 1 ? `Reloaded ${functionCount} function` : `Reloaded ${functionCount} functions`
|
|
7766
|
+
);
|
|
7767
|
+
}
|
|
7768
|
+
edgeSites.forEach(({ id, type }) => {
|
|
7769
|
+
Colors2.line(
|
|
7770
|
+
Colors2.primary(`\u279C `),
|
|
7771
|
+
`Redeploy the "${id}" ${type} to use the new secret`
|
|
7772
|
+
);
|
|
7773
|
+
});
|
|
7774
|
+
process.exit(0);
|
|
7775
|
+
}
|
|
7776
|
+
);
|
|
7777
|
+
|
|
7714
7778
|
// src/cli/commands/secrets/remove.ts
|
|
7715
7779
|
var remove3 = (program2) => program2.command(
|
|
7716
7780
|
"remove <name>",
|
|
@@ -7769,7 +7833,7 @@ var set = (program2) => program2.command(
|
|
|
7769
7833
|
const restarting = createSpinner2(
|
|
7770
7834
|
` Reloading all resources using ${blue4(args.name)}...`
|
|
7771
7835
|
).start();
|
|
7772
|
-
const { edgeSites, sites, placeholderSites, functions } = await Config2.restart(args.name);
|
|
7836
|
+
const { edgeSites, sites, placeholderSites, functions } = await Config2.restart([args.name]);
|
|
7773
7837
|
restarting.stop().clear();
|
|
7774
7838
|
const siteCount = sites.length + placeholderSites.length;
|
|
7775
7839
|
if (siteCount > 0) {
|
|
@@ -7801,6 +7865,7 @@ function secrets(program2) {
|
|
|
7801
7865
|
yargs2.demandCommand(1);
|
|
7802
7866
|
set(yargs2);
|
|
7803
7867
|
get(yargs2);
|
|
7868
|
+
load2(yargs2);
|
|
7804
7869
|
list(yargs2);
|
|
7805
7870
|
remove3(yargs2);
|
|
7806
7871
|
return yargs2;
|