@awsless/awsless 0.0.268 → 0.0.270
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +227 -274
- package/dist/build-json-schema.js +3 -1
- package/dist/stack.json +1 -1
- package/package.json +6 -6
package/dist/bin.js
CHANGED
|
@@ -493,6 +493,7 @@ var TypeSchema = z12.enum([
|
|
|
493
493
|
var CommandSchema = z12.string().describe(`The script you want to execute when the instance starts up.`);
|
|
494
494
|
var CodeSchema = LocalDirectorySchema.describe(`The code directory that will be deployed to your instance.`);
|
|
495
495
|
var ConnectSchema = z12.boolean().describe("Allows you to connect to all instances with an Instance Connect Endpoint.");
|
|
496
|
+
var EnvironmentSchema2 = z12.record(z12.string(), z12.string()).optional().describe("Environment variable key-value pairs.");
|
|
496
497
|
var InstanceDefaultSchema = z12.object({
|
|
497
498
|
connect: ConnectSchema.default(false)
|
|
498
499
|
}).default({}).describe("Define the default settings for all instances in your stacks.");
|
|
@@ -502,7 +503,8 @@ var InstancesSchema = z12.record(
|
|
|
502
503
|
image: ImageSchema,
|
|
503
504
|
type: TypeSchema,
|
|
504
505
|
code: CodeSchema,
|
|
505
|
-
command: CommandSchema.optional()
|
|
506
|
+
command: CommandSchema.optional(),
|
|
507
|
+
environment: EnvironmentSchema2.optional()
|
|
506
508
|
})
|
|
507
509
|
).optional().describe("Define the instances in your stack.");
|
|
508
510
|
|
|
@@ -1718,8 +1720,8 @@ var bootstrapAwsless = async (props) => {
|
|
|
1718
1720
|
};
|
|
1719
1721
|
|
|
1720
1722
|
// src/util/aws.ts
|
|
1723
|
+
import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
|
|
1721
1724
|
import { fromIni } from "@aws-sdk/credential-providers";
|
|
1722
|
-
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
|
|
1723
1725
|
var getCredentials = (profile) => {
|
|
1724
1726
|
return fromIni({ profile });
|
|
1725
1727
|
};
|
|
@@ -3453,7 +3455,6 @@ var instanceFeature = defineFeature({
|
|
|
3453
3455
|
const group = new Node9(ctx.base, "instance", "asset");
|
|
3454
3456
|
const bucket = new aws9.s3.Bucket(group, "bucket", {
|
|
3455
3457
|
name: formatGlobalResourceName(ctx.appConfig.name, "instance", "assets"),
|
|
3456
|
-
versioning: true,
|
|
3457
3458
|
forceDelete: true
|
|
3458
3459
|
});
|
|
3459
3460
|
ctx.shared.set("instance-bucket-name", bucket.name);
|
|
@@ -3482,7 +3483,7 @@ var instanceFeature = defineFeature({
|
|
|
3482
3483
|
const bucketName = ctx.shared.get("instance-bucket-name");
|
|
3483
3484
|
const userData = new Output2([], (resolve) => {
|
|
3484
3485
|
ctx.onReady(() => {
|
|
3485
|
-
combine([bucketName, ...Object.values(env)]).apply(
|
|
3486
|
+
combine([bucketName, ...Object.values(env)]).apply(([bucketName2]) => {
|
|
3486
3487
|
const u = "ec2-user";
|
|
3487
3488
|
const code2 = [
|
|
3488
3489
|
`#!/bin/bash`,
|
|
@@ -3492,8 +3493,13 @@ var instanceFeature = defineFeature({
|
|
|
3492
3493
|
`sudo -u ${u} unzip -o ${name} -d ./code`,
|
|
3493
3494
|
`sudo -u ${u} rm ./${name}`,
|
|
3494
3495
|
`cd ./code`,
|
|
3496
|
+
// system environment vars
|
|
3495
3497
|
...Object.entries(env).map(([key, value]) => {
|
|
3496
|
-
return `export ${key}="${unwrap(value)}"`;
|
|
3498
|
+
return `echo export ${key}="${unwrap(value)}" >> /etc/profile`;
|
|
3499
|
+
}),
|
|
3500
|
+
// user environment vars
|
|
3501
|
+
...Object.entries(props.environment ?? {}).map(([key, value]) => {
|
|
3502
|
+
return `echo export ${key}="${value}" >> /etc/profile`;
|
|
3497
3503
|
}),
|
|
3498
3504
|
props.command ? `sudo -u ${u} ${props.command}` : ""
|
|
3499
3505
|
].join("\n");
|
|
@@ -3525,8 +3531,6 @@ var instanceFeature = defineFeature({
|
|
|
3525
3531
|
securityGroupIds: [ctx.shared.get("vpc-security-group-id")],
|
|
3526
3532
|
monitoring: true,
|
|
3527
3533
|
userData
|
|
3528
|
-
// userData: userData.value.apply(Asset.fromString),
|
|
3529
|
-
// userData: Asset.fromString('echo 1'),
|
|
3530
3534
|
});
|
|
3531
3535
|
const role = new aws9.iam.Role(group, "role", {
|
|
3532
3536
|
name,
|
|
@@ -3537,16 +3541,8 @@ var instanceFeature = defineFeature({
|
|
|
3537
3541
|
role: role.name
|
|
3538
3542
|
});
|
|
3539
3543
|
policy.addStatement({
|
|
3540
|
-
actions: [
|
|
3541
|
-
|
|
3542
|
-
//
|
|
3543
|
-
// 's3:*',
|
|
3544
|
-
],
|
|
3545
|
-
resources: [
|
|
3546
|
-
bucketName.apply((bucket) => `arn:aws:s3:::${bucket}/${name}`)
|
|
3547
|
-
//
|
|
3548
|
-
// '*',
|
|
3549
|
-
]
|
|
3544
|
+
actions: ["s3:GetObject"],
|
|
3545
|
+
resources: [bucketName.apply((bucket) => `arn:aws:s3:::${bucket}/${name}`)]
|
|
3550
3546
|
});
|
|
3551
3547
|
ctx.registerPolicy(policy);
|
|
3552
3548
|
const profile = new aws9.iam.InstanceProfile(group, "profile", {
|
|
@@ -3558,7 +3554,6 @@ var instanceFeature = defineFeature({
|
|
|
3558
3554
|
iamInstanceProfile: profile.arn,
|
|
3559
3555
|
launchTemplate: template,
|
|
3560
3556
|
subnetId: ctx.shared.get(`vpc-public-subnet-id-1`)
|
|
3561
|
-
// keyName: props.ssh ? ctx.shared.get('instance-key-name') : undefined,
|
|
3562
3557
|
});
|
|
3563
3558
|
instance.dependsOn(code);
|
|
3564
3559
|
const logGroup = new aws9.cloudWatch.LogGroup(group, "log", {
|
|
@@ -5318,71 +5313,142 @@ var deploy = (program2) => {
|
|
|
5318
5313
|
});
|
|
5319
5314
|
};
|
|
5320
5315
|
|
|
5321
|
-
// src/cli/command/
|
|
5322
|
-
import {
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5316
|
+
// src/cli/command/auth/user/create.ts
|
|
5317
|
+
import {
|
|
5318
|
+
AdminCreateUserCommand,
|
|
5319
|
+
AdminSetUserPasswordCommand,
|
|
5320
|
+
CognitoIdentityProviderClient
|
|
5321
|
+
} from "@aws-sdk/client-cognito-identity-provider";
|
|
5322
|
+
import { unwrap as unwrap2 } from "@awsless/formation";
|
|
5323
|
+
import { password, select, text as text2 } from "@clack/prompts";
|
|
5324
|
+
var create = (program2) => {
|
|
5325
|
+
program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
|
|
5326
|
+
await layout("auth user create", async ({ appConfig, stackConfigs }) => {
|
|
5327
5327
|
const region = appConfig.region;
|
|
5328
5328
|
const credentials = getCredentials(appConfig.profile);
|
|
5329
5329
|
const accountId = await getAccountId(credentials, region);
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5330
|
+
if (!name) {
|
|
5331
|
+
name = await select({
|
|
5332
|
+
message: "Select the auth userpool:",
|
|
5333
|
+
options: Object.keys(appConfig.defaults.auth).map((name2) => ({
|
|
5334
|
+
label: name2,
|
|
5335
|
+
value: name2
|
|
5336
|
+
}))
|
|
5337
|
+
});
|
|
5338
|
+
}
|
|
5339
|
+
if (!(name in appConfig.defaults.auth)) {
|
|
5340
|
+
throw new Error(`Provided auth name doesn't exist inside your app config.`);
|
|
5341
|
+
}
|
|
5342
|
+
const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
|
|
5343
|
+
const { workspace } = createWorkSpace({
|
|
5344
|
+
credentials,
|
|
5345
|
+
accountId,
|
|
5346
|
+
region
|
|
5343
5347
|
});
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
}
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
...diff2.creates.map((v) => [
|
|
5359
|
-
chalk7.magenta(stack.name),
|
|
5360
|
-
color.success`create`,
|
|
5361
|
-
formatResource(stack, v)
|
|
5362
|
-
]),
|
|
5363
|
-
...diff2.updates.map((v) => [
|
|
5364
|
-
chalk7.magenta(stack.name),
|
|
5365
|
-
color.warning`update`,
|
|
5366
|
-
formatResource(stack, v)
|
|
5367
|
-
]),
|
|
5368
|
-
...diff2.deletes.map((v) => [
|
|
5369
|
-
chalk7.magenta(stack.name),
|
|
5370
|
-
color.error`delete`,
|
|
5371
|
-
formatResource(stack, v)
|
|
5372
|
-
])
|
|
5373
|
-
);
|
|
5348
|
+
await workspace.hydrate(app);
|
|
5349
|
+
let userPoolId;
|
|
5350
|
+
try {
|
|
5351
|
+
userPoolId = unwrap2(shared.get(`auth-${name}-user-pool-id`));
|
|
5352
|
+
} catch (_) {
|
|
5353
|
+
throw new Error(`The auth userpool hasn't been deployed yet.`);
|
|
5354
|
+
}
|
|
5355
|
+
const user2 = await text2({
|
|
5356
|
+
message: "Username:",
|
|
5357
|
+
validate(value) {
|
|
5358
|
+
if (!value) {
|
|
5359
|
+
return "Required";
|
|
5360
|
+
}
|
|
5361
|
+
return;
|
|
5374
5362
|
}
|
|
5375
|
-
return "Done finding app differences.";
|
|
5376
5363
|
});
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5364
|
+
const pass = await password({
|
|
5365
|
+
message: "Password:",
|
|
5366
|
+
mask: "*",
|
|
5367
|
+
validate(value) {
|
|
5368
|
+
if (!value) {
|
|
5369
|
+
return "Required";
|
|
5370
|
+
}
|
|
5371
|
+
return;
|
|
5372
|
+
}
|
|
5373
|
+
});
|
|
5374
|
+
const client = new CognitoIdentityProviderClient({
|
|
5375
|
+
region,
|
|
5376
|
+
credentials
|
|
5377
|
+
});
|
|
5378
|
+
await client.send(
|
|
5379
|
+
new AdminCreateUserCommand({
|
|
5380
|
+
UserPoolId: userPoolId,
|
|
5381
|
+
Username: user2.toString(),
|
|
5382
|
+
TemporaryPassword: pass.toString()
|
|
5383
|
+
})
|
|
5384
|
+
);
|
|
5385
|
+
await client.send(
|
|
5386
|
+
new AdminSetUserPasswordCommand({
|
|
5387
|
+
UserPoolId: userPoolId,
|
|
5388
|
+
Username: user2.toString(),
|
|
5389
|
+
Password: pass.toString(),
|
|
5390
|
+
Permanent: true
|
|
5391
|
+
})
|
|
5392
|
+
);
|
|
5393
|
+
return "User created.";
|
|
5394
|
+
});
|
|
5395
|
+
});
|
|
5396
|
+
};
|
|
5397
|
+
|
|
5398
|
+
// src/cli/command/auth/user/index.ts
|
|
5399
|
+
var commands2 = [create];
|
|
5400
|
+
var user = (program2) => {
|
|
5401
|
+
const command = program2.command("user").description(`Manage auth users`);
|
|
5402
|
+
commands2.forEach((cb) => cb(command));
|
|
5403
|
+
};
|
|
5404
|
+
|
|
5405
|
+
// src/cli/command/auth/index.ts
|
|
5406
|
+
var commands3 = [user];
|
|
5407
|
+
var auth = (program2) => {
|
|
5408
|
+
const command = program2.command("auth").description(`Manage auth`);
|
|
5409
|
+
commands3.forEach((cb) => cb(command));
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5412
|
+
// src/cli/command/bind.ts
|
|
5413
|
+
import { unwrap as unwrap3 } from "@awsless/formation";
|
|
5414
|
+
import { note as note3 } from "@clack/prompts";
|
|
5415
|
+
import { spawn } from "child_process";
|
|
5416
|
+
var bind = (program2) => {
|
|
5417
|
+
program2.command("bind").argument("<command...>", "The command to execute").description(`Bind your site environment variables to a command`).action(async (commands7) => {
|
|
5418
|
+
await layout("bind", async ({ appConfig, stackConfigs }) => {
|
|
5419
|
+
const region = appConfig.region;
|
|
5420
|
+
const credentials = getCredentials(appConfig.profile);
|
|
5421
|
+
const accountId = await getAccountId(credentials, region);
|
|
5422
|
+
const { app, binds } = createApp({ appConfig, stackConfigs, accountId });
|
|
5423
|
+
const { workspace } = createWorkSpace({
|
|
5424
|
+
credentials,
|
|
5425
|
+
accountId,
|
|
5426
|
+
region
|
|
5427
|
+
});
|
|
5428
|
+
await workspace.hydrate(app);
|
|
5429
|
+
const env = {};
|
|
5430
|
+
for (const { name, value } of binds) {
|
|
5431
|
+
env[name] = unwrap3(value);
|
|
5384
5432
|
}
|
|
5385
|
-
|
|
5433
|
+
note3(wrap(list(env)), "Bind Env");
|
|
5434
|
+
const command = commands7.join(" ");
|
|
5435
|
+
spawn(command, {
|
|
5436
|
+
env: {
|
|
5437
|
+
// Pass the process env vars
|
|
5438
|
+
...process.env,
|
|
5439
|
+
// Pass the site bind env vars
|
|
5440
|
+
...env,
|
|
5441
|
+
// Basic info
|
|
5442
|
+
AWS_REGION: appConfig.region,
|
|
5443
|
+
AWS_ACCOUNT_ID: accountId
|
|
5444
|
+
// Give AWS access
|
|
5445
|
+
// AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
5446
|
+
// AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
5447
|
+
// AWS_SESSION_TOKEN: credentials.sessionToken,
|
|
5448
|
+
},
|
|
5449
|
+
stdio: "inherit",
|
|
5450
|
+
shell: true
|
|
5451
|
+
});
|
|
5386
5452
|
});
|
|
5387
5453
|
});
|
|
5388
5454
|
};
|
|
@@ -5425,75 +5491,6 @@ var buildTypes = async (props) => {
|
|
|
5425
5491
|
log9.step("Done generating type definition files.");
|
|
5426
5492
|
};
|
|
5427
5493
|
|
|
5428
|
-
// src/cli/command/types.ts
|
|
5429
|
-
var types = (program2) => {
|
|
5430
|
-
program2.command("types").description("Generate type definition files").action(async () => {
|
|
5431
|
-
await layout("types", async (props) => {
|
|
5432
|
-
await buildTypes(props);
|
|
5433
|
-
return `Ready to use the ${color.info("@awsless/awsless")} libary!`;
|
|
5434
|
-
});
|
|
5435
|
-
});
|
|
5436
|
-
};
|
|
5437
|
-
|
|
5438
|
-
// src/cli/command/test.ts
|
|
5439
|
-
var test = (program2) => {
|
|
5440
|
-
program2.command("test").argument("[stacks...]", "Optionally filter stacks to test").option("-f --filters <string...>", "Optionally filter test files").description("Test your app").action(async (stacks, options) => {
|
|
5441
|
-
await layout("test", async (props) => {
|
|
5442
|
-
const region = props.appConfig.region;
|
|
5443
|
-
const credentials = getCredentials(props.appConfig.profile);
|
|
5444
|
-
const accountId = await getAccountId(credentials, region);
|
|
5445
|
-
const { tests } = createApp({ ...props, accountId }, stacks);
|
|
5446
|
-
if (tests.length === 0) {
|
|
5447
|
-
return "No tests found.";
|
|
5448
|
-
}
|
|
5449
|
-
await runTests(tests, options?.filters);
|
|
5450
|
-
return "All tests finished.";
|
|
5451
|
-
});
|
|
5452
|
-
});
|
|
5453
|
-
};
|
|
5454
|
-
|
|
5455
|
-
// src/cli/command/resource/list.ts
|
|
5456
|
-
import chalk8 from "chalk";
|
|
5457
|
-
var list3 = (program2) => {
|
|
5458
|
-
program2.command("list").description(`List all defined resources`).action(async () => {
|
|
5459
|
-
await layout("resource list", async ({ appConfig, stackConfigs }) => {
|
|
5460
|
-
const region = appConfig.region;
|
|
5461
|
-
const credentials = getCredentials(appConfig.profile);
|
|
5462
|
-
const accountId = await getAccountId(credentials, region);
|
|
5463
|
-
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
5464
|
-
const resources = [];
|
|
5465
|
-
const formatResource = (stack, urn) => {
|
|
5466
|
-
return urn.replace(stack.urn + ":", "").replace(/\{([a-z0-9\-\s\/\._]+)\}/gi, (_, v) => {
|
|
5467
|
-
return `${color.dim("{")}${color.warning(v)}${color.dim("}")}`;
|
|
5468
|
-
}).replaceAll(":", color.dim(":"));
|
|
5469
|
-
};
|
|
5470
|
-
for (const stack of app.stacks) {
|
|
5471
|
-
for (const resource2 of stack.resources) {
|
|
5472
|
-
resources.push([
|
|
5473
|
-
chalk8.magenta(stack.name),
|
|
5474
|
-
// resource.type,
|
|
5475
|
-
formatResource(stack, resource2.urn)
|
|
5476
|
-
]);
|
|
5477
|
-
}
|
|
5478
|
-
}
|
|
5479
|
-
console.log(
|
|
5480
|
-
table({
|
|
5481
|
-
// colWidths,
|
|
5482
|
-
head: ["stack", "urn"],
|
|
5483
|
-
body: resources
|
|
5484
|
-
})
|
|
5485
|
-
);
|
|
5486
|
-
});
|
|
5487
|
-
});
|
|
5488
|
-
};
|
|
5489
|
-
|
|
5490
|
-
// src/cli/command/resource/index.ts
|
|
5491
|
-
var commands2 = [list3];
|
|
5492
|
-
var resource = (program2) => {
|
|
5493
|
-
const command = program2.command("resource").description(`Manage app resources`);
|
|
5494
|
-
commands2.forEach((cb) => cb(command));
|
|
5495
|
-
};
|
|
5496
|
-
|
|
5497
5494
|
// src/config/load/watch.ts
|
|
5498
5495
|
import { watch } from "chokidar";
|
|
5499
5496
|
var watchConfig = async (options, resolve, reject) => {
|
|
@@ -5541,6 +5538,48 @@ var dev = (program2) => {
|
|
|
5541
5538
|
});
|
|
5542
5539
|
};
|
|
5543
5540
|
|
|
5541
|
+
// src/cli/command/resource/list.ts
|
|
5542
|
+
import chalk7 from "chalk";
|
|
5543
|
+
var list3 = (program2) => {
|
|
5544
|
+
program2.command("list").description(`List all defined resources`).action(async () => {
|
|
5545
|
+
await layout("resource list", async ({ appConfig, stackConfigs }) => {
|
|
5546
|
+
const region = appConfig.region;
|
|
5547
|
+
const credentials = getCredentials(appConfig.profile);
|
|
5548
|
+
const accountId = await getAccountId(credentials, region);
|
|
5549
|
+
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
5550
|
+
const resources = [];
|
|
5551
|
+
const formatResource = (stack, urn) => {
|
|
5552
|
+
return urn.replace(stack.urn + ":", "").replace(/\{([a-z0-9\-\s\/\._]+)\}/gi, (_, v) => {
|
|
5553
|
+
return `${color.dim("{")}${color.warning(v)}${color.dim("}")}`;
|
|
5554
|
+
}).replaceAll(":", color.dim(":"));
|
|
5555
|
+
};
|
|
5556
|
+
for (const stack of app.stacks) {
|
|
5557
|
+
for (const resource2 of stack.resources) {
|
|
5558
|
+
resources.push([
|
|
5559
|
+
chalk7.magenta(stack.name),
|
|
5560
|
+
// resource.type,
|
|
5561
|
+
formatResource(stack, resource2.urn)
|
|
5562
|
+
]);
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5565
|
+
console.log(
|
|
5566
|
+
table({
|
|
5567
|
+
// colWidths,
|
|
5568
|
+
head: ["stack", "urn"],
|
|
5569
|
+
body: resources
|
|
5570
|
+
})
|
|
5571
|
+
);
|
|
5572
|
+
});
|
|
5573
|
+
});
|
|
5574
|
+
};
|
|
5575
|
+
|
|
5576
|
+
// src/cli/command/resource/index.ts
|
|
5577
|
+
var commands4 = [list3];
|
|
5578
|
+
var resource = (program2) => {
|
|
5579
|
+
const command = program2.command("resource").description(`Manage app resources`);
|
|
5580
|
+
commands4.forEach((cb) => cb(command));
|
|
5581
|
+
};
|
|
5582
|
+
|
|
5544
5583
|
// src/cli/command/state/pull.ts
|
|
5545
5584
|
var pull = (program2) => {
|
|
5546
5585
|
program2.command("pull").description("Pull the remote state and store it locally").action(async () => {
|
|
@@ -5579,149 +5618,63 @@ var push = (program2) => {
|
|
|
5579
5618
|
});
|
|
5580
5619
|
};
|
|
5581
5620
|
|
|
5582
|
-
// src/cli/command/state/
|
|
5583
|
-
|
|
5584
|
-
var
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
};
|
|
5588
|
-
|
|
5589
|
-
// src/cli/command/auth/user/create.ts
|
|
5590
|
-
import {
|
|
5591
|
-
AdminCreateUserCommand,
|
|
5592
|
-
AdminSetUserPasswordCommand,
|
|
5593
|
-
CognitoIdentityProviderClient
|
|
5594
|
-
} from "@aws-sdk/client-cognito-identity-provider";
|
|
5595
|
-
import { unwrap as unwrap2 } from "@awsless/formation";
|
|
5596
|
-
import { password, select, text as text2 } from "@clack/prompts";
|
|
5597
|
-
var create = (program2) => {
|
|
5598
|
-
program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
|
|
5599
|
-
await layout("auth user create", async ({ appConfig, stackConfigs }) => {
|
|
5621
|
+
// src/cli/command/state/unlock.ts
|
|
5622
|
+
import { confirm as confirm6 } from "@clack/prompts";
|
|
5623
|
+
var unlock = (program2) => {
|
|
5624
|
+
program2.command("unlock").description("Release the lock that ensures sequential deployments").action(async () => {
|
|
5625
|
+
await layout("state unlock", async ({ appConfig, stackConfigs }) => {
|
|
5600
5626
|
const region = appConfig.region;
|
|
5601
5627
|
const credentials = getCredentials(appConfig.profile);
|
|
5602
5628
|
const accountId = await getAccountId(credentials, region);
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
value: name2
|
|
5609
|
-
}))
|
|
5610
|
-
});
|
|
5611
|
-
}
|
|
5612
|
-
if (!(name in appConfig.defaults.auth)) {
|
|
5613
|
-
throw new Error(`Provided auth name doesn't exist inside your app config.`);
|
|
5629
|
+
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
5630
|
+
const { lockProvider } = createWorkSpace({ credentials, region, accountId });
|
|
5631
|
+
const isLocked = await lockProvider.locked(app.urn);
|
|
5632
|
+
if (!isLocked) {
|
|
5633
|
+
return "No lock is exists.";
|
|
5614
5634
|
}
|
|
5615
|
-
const
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
accountId,
|
|
5619
|
-
region
|
|
5635
|
+
const ok = await confirm6({
|
|
5636
|
+
message: "Releasing the lock that ensures sequential deployments might result in corrupt state if a deployment is still running. Are you sure?",
|
|
5637
|
+
initialValue: false
|
|
5620
5638
|
});
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
try {
|
|
5624
|
-
userPoolId = unwrap2(shared.get(`auth-${name}-user-pool-id`));
|
|
5625
|
-
} catch (_) {
|
|
5626
|
-
throw new Error(`The auth userpool hasn't been deployed yet.`);
|
|
5639
|
+
if (!ok) {
|
|
5640
|
+
throw new Cancelled();
|
|
5627
5641
|
}
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
validate(value) {
|
|
5631
|
-
if (!value) {
|
|
5632
|
-
return "Required";
|
|
5633
|
-
}
|
|
5634
|
-
return;
|
|
5635
|
-
}
|
|
5636
|
-
});
|
|
5637
|
-
const pass = await password({
|
|
5638
|
-
message: "Password:",
|
|
5639
|
-
mask: "*",
|
|
5640
|
-
validate(value) {
|
|
5641
|
-
if (!value) {
|
|
5642
|
-
return "Required";
|
|
5643
|
-
}
|
|
5644
|
-
return;
|
|
5645
|
-
}
|
|
5646
|
-
});
|
|
5647
|
-
const client = new CognitoIdentityProviderClient({
|
|
5648
|
-
region,
|
|
5649
|
-
credentials
|
|
5650
|
-
});
|
|
5651
|
-
await client.send(
|
|
5652
|
-
new AdminCreateUserCommand({
|
|
5653
|
-
UserPoolId: userPoolId,
|
|
5654
|
-
Username: user2.toString(),
|
|
5655
|
-
TemporaryPassword: pass.toString()
|
|
5656
|
-
})
|
|
5657
|
-
);
|
|
5658
|
-
await client.send(
|
|
5659
|
-
new AdminSetUserPasswordCommand({
|
|
5660
|
-
UserPoolId: userPoolId,
|
|
5661
|
-
Username: user2.toString(),
|
|
5662
|
-
Password: pass.toString(),
|
|
5663
|
-
Permanent: true
|
|
5664
|
-
})
|
|
5665
|
-
);
|
|
5666
|
-
return "User created.";
|
|
5642
|
+
await lockProvider.insecureReleaseLock(app.urn);
|
|
5643
|
+
return "The state lock was been successfully released.";
|
|
5667
5644
|
});
|
|
5668
5645
|
});
|
|
5669
5646
|
};
|
|
5670
5647
|
|
|
5671
|
-
// src/cli/command/
|
|
5672
|
-
var
|
|
5673
|
-
var
|
|
5674
|
-
const command = program2.command("
|
|
5675
|
-
commands4.forEach((cb) => cb(command));
|
|
5676
|
-
};
|
|
5677
|
-
|
|
5678
|
-
// src/cli/command/auth/index.ts
|
|
5679
|
-
var commands5 = [user];
|
|
5680
|
-
var auth = (program2) => {
|
|
5681
|
-
const command = program2.command("auth").description(`Manage auth`);
|
|
5648
|
+
// src/cli/command/state/index.ts
|
|
5649
|
+
var commands5 = [pull, push, unlock];
|
|
5650
|
+
var state = (program2) => {
|
|
5651
|
+
const command = program2.command("state").description(`Manage app state`);
|
|
5682
5652
|
commands5.forEach((cb) => cb(command));
|
|
5683
5653
|
};
|
|
5684
5654
|
|
|
5685
|
-
// src/cli/command/
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
await layout("bind", async ({ appConfig, stackConfigs }) => {
|
|
5692
|
-
const region = appConfig.region;
|
|
5693
|
-
const credentials = getCredentials(appConfig.profile);
|
|
5655
|
+
// src/cli/command/test.ts
|
|
5656
|
+
var test = (program2) => {
|
|
5657
|
+
program2.command("test").argument("[stacks...]", "Optionally filter stacks to test").option("-f --filters <string...>", "Optionally filter test files").description("Test your app").action(async (stacks, options) => {
|
|
5658
|
+
await layout("test", async (props) => {
|
|
5659
|
+
const region = props.appConfig.region;
|
|
5660
|
+
const credentials = getCredentials(props.appConfig.profile);
|
|
5694
5661
|
const accountId = await getAccountId(credentials, region);
|
|
5695
|
-
const {
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
accountId,
|
|
5699
|
-
region
|
|
5700
|
-
});
|
|
5701
|
-
await workspace.hydrate(app);
|
|
5702
|
-
const env = {};
|
|
5703
|
-
for (const { name, value } of binds) {
|
|
5704
|
-
env[name] = unwrap3(value);
|
|
5662
|
+
const { tests } = createApp({ ...props, accountId }, stacks);
|
|
5663
|
+
if (tests.length === 0) {
|
|
5664
|
+
return "No tests found.";
|
|
5705
5665
|
}
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
// AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
5719
|
-
// AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
5720
|
-
// AWS_SESSION_TOKEN: credentials.sessionToken,
|
|
5721
|
-
},
|
|
5722
|
-
stdio: "inherit",
|
|
5723
|
-
shell: true
|
|
5724
|
-
});
|
|
5666
|
+
await runTests(tests, options?.filters);
|
|
5667
|
+
return "All tests finished.";
|
|
5668
|
+
});
|
|
5669
|
+
});
|
|
5670
|
+
};
|
|
5671
|
+
|
|
5672
|
+
// src/cli/command/types.ts
|
|
5673
|
+
var types = (program2) => {
|
|
5674
|
+
program2.command("types").description("Generate type definition files").action(async () => {
|
|
5675
|
+
await layout("types", async (props) => {
|
|
5676
|
+
await buildTypes(props);
|
|
5677
|
+
return `Ready to use the ${color.info("@awsless/awsless")} libary!`;
|
|
5725
5678
|
});
|
|
5726
5679
|
});
|
|
5727
5680
|
};
|
|
@@ -5732,7 +5685,7 @@ var commands6 = [
|
|
|
5732
5685
|
types,
|
|
5733
5686
|
build2,
|
|
5734
5687
|
deploy,
|
|
5735
|
-
diff,
|
|
5688
|
+
// diff,
|
|
5736
5689
|
del2,
|
|
5737
5690
|
dev,
|
|
5738
5691
|
bind,
|
|
@@ -473,6 +473,7 @@ var TypeSchema2 = z15.enum([
|
|
|
473
473
|
var CommandSchema = z15.string().describe(`The script you want to execute when the instance starts up.`);
|
|
474
474
|
var CodeSchema = LocalDirectorySchema.describe(`The code directory that will be deployed to your instance.`);
|
|
475
475
|
var ConnectSchema = z15.boolean().describe("Allows you to connect to all instances with an Instance Connect Endpoint.");
|
|
476
|
+
var EnvironmentSchema2 = z15.record(z15.string(), z15.string()).optional().describe("Environment variable key-value pairs.");
|
|
476
477
|
var InstanceDefaultSchema = z15.object({
|
|
477
478
|
connect: ConnectSchema.default(false)
|
|
478
479
|
}).default({}).describe("Define the default settings for all instances in your stacks.");
|
|
@@ -482,7 +483,8 @@ var InstancesSchema = z15.record(
|
|
|
482
483
|
image: ImageSchema,
|
|
483
484
|
type: TypeSchema2,
|
|
484
485
|
code: CodeSchema,
|
|
485
|
-
command: CommandSchema.optional()
|
|
486
|
+
command: CommandSchema.optional(),
|
|
487
|
+
environment: EnvironmentSchema2.optional()
|
|
486
488
|
})
|
|
487
489
|
).optional().describe("Define the instances in your stack.");
|
|
488
490
|
|