@ts-cloud/core 0.16.158 → 0.16.159
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/index.js +80 -80
- package/dist/modules/compute.d.ts +15 -0
- package/dist/types.d.ts +220 -11
- package/package.json +2 -2
|
@@ -154,6 +154,21 @@ export interface ScalingPolicyOptions {
|
|
|
154
154
|
* x2gd, im4gn, is4gen, g5g.
|
|
155
155
|
*/
|
|
156
156
|
export declare function isArmInstanceType(instanceType: string): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* The EC2 instance type a compute config asks for, in this order:
|
|
159
|
+
*
|
|
160
|
+
* 1. an explicit `instanceType` (`compute.server.instanceType`);
|
|
161
|
+
* 2. `size`: a shorthand (`'large'`) maps to the burstable family of the
|
|
162
|
+
* preferred `architecture` (`t3` for x86_64, `t4g` for arm64), and
|
|
163
|
+
* anything else (`'m7g.xlarge'`) is a raw type and passes through;
|
|
164
|
+
* 3. `fallback`, in the preferred architecture's family.
|
|
165
|
+
*/
|
|
166
|
+
export declare function resolveAwsInstanceType(options: {
|
|
167
|
+
instanceType?: string;
|
|
168
|
+
size?: string;
|
|
169
|
+
architecture?: 'x86_64' | 'arm64';
|
|
170
|
+
fallback?: string;
|
|
171
|
+
}): string;
|
|
157
172
|
/**
|
|
158
173
|
* AWS's public SSM parameter for the current Amazon Linux 2023 AMI of the
|
|
159
174
|
* instance type's architecture. AWS keeps one in every region.
|
package/dist/types.d.ts
CHANGED
|
@@ -695,6 +695,20 @@ export interface InfrastructureConfig {
|
|
|
695
695
|
workers?: Record<string, WorkerConfig>;
|
|
696
696
|
security?: SecurityConfig;
|
|
697
697
|
monitoring?: MonitoringConfig;
|
|
698
|
+
/**
|
|
699
|
+
* An AWS Budget for the project: a provider-side alert on actual and
|
|
700
|
+
* forecast monthly spend, reconciled with the rest of the infrastructure
|
|
701
|
+
* (changing the amount updates it in place; removing this removes it).
|
|
702
|
+
*
|
|
703
|
+
* Scoped to resources tagged `Project=<slug>` when that cost-allocation tag
|
|
704
|
+
* is active in the account's Billing console; otherwise ts-cloud falls back
|
|
705
|
+
* to an account-wide budget and warns. It complements the spend engine
|
|
706
|
+
* (`docs/features/spend-management.md`) rather than replacing it: the
|
|
707
|
+
* engine meters and can enforce caps on ts-cloud's own usage, while this
|
|
708
|
+
* budget watches the AWS bill itself, including anything the engine does
|
|
709
|
+
* not meter.
|
|
710
|
+
*/
|
|
711
|
+
budget?: BudgetConfig;
|
|
698
712
|
api?: ApiConfig;
|
|
699
713
|
loadBalancer?: LoadBalancerConfig;
|
|
700
714
|
ssl?: SslConfig;
|
|
@@ -2494,10 +2508,21 @@ export interface WorkerConfig {
|
|
|
2494
2508
|
* Hostnames the Worker serves as Workers Custom Domains. Cloudflare creates
|
|
2495
2509
|
* the DNS record and certificate itself, so a hostname must not already have
|
|
2496
2510
|
* a DNS record or be attached to an R2 bucket or another Worker: the deploy
|
|
2497
|
-
* warns and leaves it alone rather than detaching anything.
|
|
2498
|
-
*
|
|
2511
|
+
* warns and leaves it alone rather than detaching anything. ts-cloud
|
|
2512
|
+
* records the hostnames it attached; one later removed from this list is
|
|
2513
|
+
* reported on every deploy and stays attached unless
|
|
2514
|
+
* {@link pruneCustomDomains} is set.
|
|
2499
2515
|
*/
|
|
2500
2516
|
customDomains?: string[];
|
|
2517
|
+
/**
|
|
2518
|
+
* Detach hostnames ts-cloud attached to this Worker that are no longer in
|
|
2519
|
+
* {@link customDomains}, so the list is the full description of what the
|
|
2520
|
+
* Worker serves. Cloudflare removes the DNS record a Worker custom domain
|
|
2521
|
+
* created when it is detached. A hostname attached outside ts-cloud is never
|
|
2522
|
+
* detached. A dry run lists the pending detaches.
|
|
2523
|
+
* @default false
|
|
2524
|
+
*/
|
|
2525
|
+
pruneCustomDomains?: boolean;
|
|
2501
2526
|
}
|
|
2502
2527
|
export interface StorageItemConfig {
|
|
2503
2528
|
/**
|
|
@@ -3222,7 +3247,20 @@ export interface ComputeConfig {
|
|
|
3222
3247
|
/** Enlarge the primary disk with the server. Cannot be undone. @default true */
|
|
3223
3248
|
upgradeDisk?: boolean;
|
|
3224
3249
|
};
|
|
3225
|
-
/**
|
|
3250
|
+
/**
|
|
3251
|
+
* Named persistent block volumes, kept apart from the root disk so they can
|
|
3252
|
+
* be grown and snapshotted on their own. Reconciled only by the server
|
|
3253
|
+
* owner; the host requires Bun.
|
|
3254
|
+
*
|
|
3255
|
+
* - Hetzner: a Hetzner Cloud volume per entry.
|
|
3256
|
+
* - AWS (lightweight EC2): an EBS volume per entry, created in the
|
|
3257
|
+
* instance's availability zone (see the EBS fields on
|
|
3258
|
+
* {@link ComputeVolumeConfig}).
|
|
3259
|
+
* - ssh: a disk already attached to the host, named by `device`.
|
|
3260
|
+
*
|
|
3261
|
+
* A volume is formatted only when it is blank, mounted by filesystem UUID
|
|
3262
|
+
* (persisted in fstab), grown online when its size goes up, and never shrunk.
|
|
3263
|
+
*/
|
|
3226
3264
|
volumes?: Record<string, ComputeVolumeConfig>;
|
|
3227
3265
|
/** Place releases and optional deployment backups on a named volume. */
|
|
3228
3266
|
deploymentStorage?: {
|
|
@@ -3264,10 +3302,24 @@ export interface ComputeConfig {
|
|
|
3264
3302
|
instances?: number;
|
|
3265
3303
|
/**
|
|
3266
3304
|
* Instance size (simple configuration)
|
|
3267
|
-
* Use this OR fleet, not both
|
|
3305
|
+
* Use this OR fleet, not both.
|
|
3306
|
+
*
|
|
3307
|
+
* On AWS the instance type resolves in this order: `server.instanceType`,
|
|
3308
|
+
* then `size` (a shorthand such as `'large'` maps to `t3.large`, or to
|
|
3309
|
+
* `t4g.large` with `architecture: 'arm64'`; anything else, such as
|
|
3310
|
+
* `'m7g.xlarge'`, is a raw instance type and is used as written), then
|
|
3311
|
+
* the provider default.
|
|
3268
3312
|
* @default 'micro'
|
|
3269
3313
|
*/
|
|
3270
3314
|
size?: InstanceSize;
|
|
3315
|
+
/**
|
|
3316
|
+
* CPU architecture that `size` shorthands map to on AWS: `'x86_64'` (t3) or
|
|
3317
|
+
* `'arm64'` (Graviton, t4g). A raw instance type carries its own
|
|
3318
|
+
* architecture and ignores this. The machine image always follows the
|
|
3319
|
+
* instance type.
|
|
3320
|
+
* @default 'x86_64'
|
|
3321
|
+
*/
|
|
3322
|
+
architecture?: 'x86_64' | 'arm64';
|
|
3271
3323
|
/**
|
|
3272
3324
|
* Number of application servers (Forge load-balanced fleet). When > 1, a load
|
|
3273
3325
|
* balancer is provisioned in front and a private network connects the fleet;
|
|
@@ -3343,9 +3395,20 @@ export interface ComputeConfig {
|
|
|
3343
3395
|
ami?: string;
|
|
3344
3396
|
keyPair?: string;
|
|
3345
3397
|
/**
|
|
3346
|
-
* IAM instance profile name attached at launch
|
|
3347
|
-
*
|
|
3348
|
-
*
|
|
3398
|
+
* IAM instance profile name attached at launch, used unchanged.
|
|
3399
|
+
*
|
|
3400
|
+
* Leave it unset on the lightweight EC2 boot path and ts-cloud creates a
|
|
3401
|
+
* least-privilege role and profile named `<slug>-<environment>-box`
|
|
3402
|
+
* (and removes it on teardown). A profile you name here must grant at
|
|
3403
|
+
* least:
|
|
3404
|
+
* - the AWS-managed `AmazonSSMManagedInstanceCore` policy, so deploys
|
|
3405
|
+
* (SSM Run Command) reach the box;
|
|
3406
|
+
* - `s3:GetObject` on `arn:aws:s3:::<slug>-<environment>-deploy/releases/*`
|
|
3407
|
+
* and `.../bootstrap/*`, so the box can pull the releases it is sent
|
|
3408
|
+
* and a first-boot script too large for user data;
|
|
3409
|
+
* - when `compute.backups` writes to AWS S3 without explicit credentials,
|
|
3410
|
+
* `s3:ListBucket` on the backup bucket (limited to its prefix) and
|
|
3411
|
+
* `s3:GetObject`/`s3:PutObject`/`s3:DeleteObject` on `<bucket>/<prefix>/*`.
|
|
3349
3412
|
*/
|
|
3350
3413
|
iamInstanceProfile?: string;
|
|
3351
3414
|
autoScaling?: {
|
|
@@ -3490,10 +3553,19 @@ export interface ComputeConfig {
|
|
|
3490
3553
|
* Root disk configuration
|
|
3491
3554
|
*/
|
|
3492
3555
|
disk?: {
|
|
3493
|
-
/** Size in GB @default 20 */
|
|
3556
|
+
/** Size in GB. Must be at least the image's own root snapshot. @default 20 */
|
|
3494
3557
|
size?: number;
|
|
3495
|
-
/**
|
|
3496
|
-
|
|
3558
|
+
/**
|
|
3559
|
+
* Disk type. The generic names map on AWS to `ssd` → gp3, `premium` →
|
|
3560
|
+
* io2, `standard` → magnetic; an EBS volume type (`gp3`, `gp2`, `io1`,
|
|
3561
|
+
* `io2`, `st1`, `sc1`) is used as written.
|
|
3562
|
+
* @default 'ssd'
|
|
3563
|
+
*/
|
|
3564
|
+
type?: 'standard' | 'ssd' | 'premium' | 'gp3' | 'gp2' | 'io1' | 'io2' | 'st1' | 'sc1';
|
|
3565
|
+
/** Provisioned IOPS (gp3, io1, io2). io1/io2 default to 3000. */
|
|
3566
|
+
iops?: number;
|
|
3567
|
+
/** Throughput in MiB/s (gp3 only). */
|
|
3568
|
+
throughput?: number;
|
|
3497
3569
|
/** Enable encryption @default true */
|
|
3498
3570
|
encrypted?: boolean;
|
|
3499
3571
|
};
|
|
@@ -3556,6 +3628,20 @@ export interface ComputeConfig {
|
|
|
3556
3628
|
* Set to `true` only if you need traditional SSH access.
|
|
3557
3629
|
*/
|
|
3558
3630
|
allowSsh?: boolean;
|
|
3631
|
+
/**
|
|
3632
|
+
* Source ranges for inbound ports on the AWS security group (lightweight
|
|
3633
|
+
* EC2 path). Each entry replaces the default sources of its port, or opens
|
|
3634
|
+
* a port that is otherwise closed. Removing an entry revokes its rules on
|
|
3635
|
+
* the next provision.
|
|
3636
|
+
*
|
|
3637
|
+
* By default 80 and 443 are open to the world, SSH (22) is closed (deploys
|
|
3638
|
+
* run over SSM; `allowSsh: true` opens it to the world), and site ports are
|
|
3639
|
+
* only published when no rpx gateway fronts them.
|
|
3640
|
+
*
|
|
3641
|
+
* @example
|
|
3642
|
+
* ingress: [{ port: 22, cidrs: ['198.51.100.7/32'] }]
|
|
3643
|
+
*/
|
|
3644
|
+
ingress?: ComputeIngressRule[];
|
|
3559
3645
|
/**
|
|
3560
3646
|
* Reverse-proxy gateway to provision on the box. When set to an engine,
|
|
3561
3647
|
* `buddy deploy` generates the gateway's route config from the `sites` model
|
|
@@ -3684,6 +3770,14 @@ export interface ComputeConfig {
|
|
|
3684
3770
|
*/
|
|
3685
3771
|
hostCleanup?: boolean | ComputeHostCleanupConfig;
|
|
3686
3772
|
}
|
|
3773
|
+
/** Inbound access to one port. See {@link ComputeConfig.ingress}. */
|
|
3774
|
+
export interface ComputeIngressRule {
|
|
3775
|
+
port: number;
|
|
3776
|
+
/** Source CIDRs, IPv4 (`203.0.113.0/24`) or IPv6 (`2001:db8::/32`). */
|
|
3777
|
+
cidrs: string[];
|
|
3778
|
+
/** @default 'tcp' */
|
|
3779
|
+
protocol?: 'tcp' | 'udp';
|
|
3780
|
+
}
|
|
3687
3781
|
/** Persistent Linux block storage managed by the compute owner. */
|
|
3688
3782
|
export interface ComputeVolumeConfig {
|
|
3689
3783
|
/** Provider resource name; defaults to <project>-<environment>-<key>. */
|
|
@@ -3692,8 +3786,27 @@ export interface ComputeVolumeConfig {
|
|
|
3692
3786
|
size: number;
|
|
3693
3787
|
/** Absolute Linux mount path, persisted by filesystem UUID. */
|
|
3694
3788
|
mountPath: string;
|
|
3695
|
-
/**
|
|
3789
|
+
/**
|
|
3790
|
+
* Refuse provider-side deletion. On AWS, a volume is deleted with its
|
|
3791
|
+
* instance's teardown only when this is `false`; otherwise it is kept.
|
|
3792
|
+
* @default true
|
|
3793
|
+
*/
|
|
3696
3794
|
deleteProtection?: boolean;
|
|
3795
|
+
/** EBS volume type (AWS). Same names as `compute.disk.type`. @default 'gp3' */
|
|
3796
|
+
type?: 'standard' | 'ssd' | 'premium' | 'gp3' | 'gp2' | 'io1' | 'io2' | 'st1' | 'sc1';
|
|
3797
|
+
/** Provisioned IOPS (AWS gp3, io1, io2). */
|
|
3798
|
+
iops?: number;
|
|
3799
|
+
/** Throughput in MiB/s (AWS gp3). */
|
|
3800
|
+
throughput?: number;
|
|
3801
|
+
/** Encrypt the EBS volume (AWS). @default true */
|
|
3802
|
+
encrypted?: boolean;
|
|
3803
|
+
/**
|
|
3804
|
+
* ssh provider: the already-attached disk, as an absolute path under
|
|
3805
|
+
* `/dev` (prefer a stable one: `/dev/disk/by-id/...`, or
|
|
3806
|
+
* `/dev/disk/by-label/<label>`). It is formatted only when it carries no
|
|
3807
|
+
* filesystem and no partition table.
|
|
3808
|
+
*/
|
|
3809
|
+
device?: string;
|
|
3697
3810
|
}
|
|
3698
3811
|
/**
|
|
3699
3812
|
* Retention windows for {@link ComputeConfig.hostCleanup}. Each field is an age
|
|
@@ -3846,6 +3959,74 @@ export interface ComputeMonitoringConfig {
|
|
|
3846
3959
|
* Each endpoint must return an {@link EgressReport}.
|
|
3847
3960
|
*/
|
|
3848
3961
|
egressEndpoints?: EgressEndpointConfig[];
|
|
3962
|
+
/**
|
|
3963
|
+
* Alarms raised from outside the box, by the provider (AWS CloudWatch on
|
|
3964
|
+
* the lightweight EC2 path). The on-box collector cannot report that the
|
|
3965
|
+
* instance itself is down or impaired; these can. Reconciled on every
|
|
3966
|
+
* provision: an alarm removed here is deleted, and alarms follow a
|
|
3967
|
+
* replacement instance.
|
|
3968
|
+
*/
|
|
3969
|
+
alarms?: ServerAlarmsConfig;
|
|
3970
|
+
}
|
|
3971
|
+
/** An alarm on a box metric. `false` turns it off. */
|
|
3972
|
+
export interface ServerAlarmThreshold {
|
|
3973
|
+
/** Seconds per evaluation period. @default 60 (status checks), 300 (CPU) */
|
|
3974
|
+
periodSeconds?: number;
|
|
3975
|
+
/** Consecutive breaching periods before the alarm fires. @default 2 (status checks), 3 (CPU) */
|
|
3976
|
+
evaluationPeriods?: number;
|
|
3977
|
+
}
|
|
3978
|
+
/** An AWS Budget declaration. See {@link InfrastructureConfig.budget}. */
|
|
3979
|
+
export interface BudgetConfig {
|
|
3980
|
+
/** Monthly limit, in `currency`. */
|
|
3981
|
+
monthly: number;
|
|
3982
|
+
/** ISO currency code AWS bills in. @default 'USD' */
|
|
3983
|
+
currency?: string;
|
|
3984
|
+
/**
|
|
3985
|
+
* Percentages of `monthly` that notify. A number is on actual spend; an
|
|
3986
|
+
* object can ask for the forecast instead, which catches a runaway before
|
|
3987
|
+
* the money is spent.
|
|
3988
|
+
* @default [80, 100, { percent: 100, forecast: true }]
|
|
3989
|
+
*/
|
|
3990
|
+
thresholds?: Array<number | {
|
|
3991
|
+
percent: number;
|
|
3992
|
+
forecast?: boolean;
|
|
3993
|
+
}>;
|
|
3994
|
+
/**
|
|
3995
|
+
* Who hears about it: email addresses, and/or an SNS topic (such as the
|
|
3996
|
+
* `<slug>-<environment>-alarms` topic of `compute.monitoring.alarms`). A
|
|
3997
|
+
* topic's access policy must allow `budgets.amazonaws.com` to publish.
|
|
3998
|
+
*/
|
|
3999
|
+
notify: {
|
|
4000
|
+
emails?: string[];
|
|
4001
|
+
topicArn?: string;
|
|
4002
|
+
};
|
|
4003
|
+
}
|
|
4004
|
+
/** Box-level alarms. See {@link ComputeMonitoringConfig.alarms}. */
|
|
4005
|
+
export interface ServerAlarmsConfig {
|
|
4006
|
+
/** `StatusCheckFailed_Instance`: the OS is unreachable. @default true */
|
|
4007
|
+
instanceStatusCheck?: boolean | ServerAlarmThreshold;
|
|
4008
|
+
/**
|
|
4009
|
+
* `StatusCheckFailed_System`: the host underneath is impaired. With
|
|
4010
|
+
* `recover` (the default) EC2 moves the instance to healthy hardware,
|
|
4011
|
+
* keeping its id, Elastic IP and EBS volumes.
|
|
4012
|
+
* @default true
|
|
4013
|
+
*/
|
|
4014
|
+
systemStatusCheck?: boolean | (ServerAlarmThreshold & {
|
|
4015
|
+
recover?: boolean;
|
|
4016
|
+
});
|
|
4017
|
+
/** Sustained CPU utilization. Off unless set. */
|
|
4018
|
+
cpu?: false | (ServerAlarmThreshold & {
|
|
4019
|
+
threshold?: number;
|
|
4020
|
+
});
|
|
4021
|
+
/**
|
|
4022
|
+
* Where alarms notify: an existing SNS topic, and/or email addresses (ts-cloud
|
|
4023
|
+
* creates `<slug>-<environment>-alarms` and subscribes them; each address
|
|
4024
|
+
* confirms once by email). Without either, alarms still fire and recover.
|
|
4025
|
+
*/
|
|
4026
|
+
notify?: {
|
|
4027
|
+
topicArn?: string;
|
|
4028
|
+
emails?: string[];
|
|
4029
|
+
};
|
|
3849
4030
|
}
|
|
3850
4031
|
/** An application endpoint reporting its own object-storage egress. */
|
|
3851
4032
|
export interface EgressEndpointConfig {
|
|
@@ -4178,6 +4359,34 @@ export interface TypesenseServiceConfig {
|
|
|
4178
4359
|
bindAddress?: string;
|
|
4179
4360
|
/** HTTP port; the adjacent lower port is reserved for peering. Defaults to 8108. */
|
|
4180
4361
|
port?: number;
|
|
4362
|
+
/**
|
|
4363
|
+
* Absolute directory Typesense keeps its data in. Defaults to
|
|
4364
|
+
* `/var/lib/ts-cloud-typesense`. Put it on a declared `compute.volumes`
|
|
4365
|
+
* mount to keep the index off the root disk; the service then refuses to
|
|
4366
|
+
* start while that volume is not mounted. Changing it on a box that already
|
|
4367
|
+
* has data stops the deploy with migration instructions instead of starting
|
|
4368
|
+
* on an empty index (see the Typesense guide).
|
|
4369
|
+
*/
|
|
4370
|
+
dataDir?: string;
|
|
4371
|
+
/** systemd `MemoryMax`, a hard ceiling (e.g. `'9G'`, `'60%'`). */
|
|
4372
|
+
memoryMax?: string;
|
|
4373
|
+
/** systemd `MemoryHigh`, where the kernel starts reclaiming (e.g. `'8G'`). */
|
|
4374
|
+
memoryHigh?: string;
|
|
4375
|
+
/** systemd `CPUQuota` (e.g. `'200%'` for two cores). */
|
|
4376
|
+
cpuQuota?: string;
|
|
4377
|
+
/** `--thread-pool-size`: request-handling threads. */
|
|
4378
|
+
threadPoolSize?: number;
|
|
4379
|
+
/** `--cache-num-entries`: search result cache entries. */
|
|
4380
|
+
cacheNumEntries?: number;
|
|
4381
|
+
/** `--enable-cors`. */
|
|
4382
|
+
enableCors?: boolean;
|
|
4383
|
+
/**
|
|
4384
|
+
* Other Typesense server flags, by name without the leading dashes
|
|
4385
|
+
* (e.g. `{ 'snapshot-interval-seconds': 3600 }`). Only known flags are
|
|
4386
|
+
* accepted, and the ones ts-cloud sets itself (key, addresses, ports,
|
|
4387
|
+
* data directory) cannot be overridden here.
|
|
4388
|
+
*/
|
|
4389
|
+
flags?: Record<string, string | number | boolean>;
|
|
4181
4390
|
}
|
|
4182
4391
|
export interface ComputeServicesConfig {
|
|
4183
4392
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-cloud/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.159",
|
|
5
5
|
"description": "Core CloudFormation generation library for ts-cloud",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ts-cloud/aws-types": "0.16.
|
|
34
|
+
"@ts-cloud/aws-types": "0.16.159"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^7.0.2"
|