-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathconfig.ts
More file actions
1297 lines (1278 loc) · 35.2 KB
/
config.ts
File metadata and controls
1297 lines (1278 loc) · 35.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* The `sst.config.ts` file is used to configure your SST app and its resources.
*
* ```ts
* $config(input: Config): Config
* ```
*
* You specify it using the `$config` function. This takes an object of type [`Config`](#config).
*
* ```ts title="sst.config.ts"
* /// <reference path="./.sst/platform/config.d.ts" />
*
* export default $config({
* // Your app's config
* app(input) {
* return {
* name: "my-sst-app",
* home: "aws"
* };
* },
* // Your app's resources
* async run() {
* const bucket = new sst.aws.Bucket("MyBucket");
*
* // Your app's outputs
* return {
* bucket: bucket.name
* };
* },
* // Optionally, your app's Console config
* console: {
* autodeploy: {
* runner: { compute: "large" }
* }
* }
* });
* ```
*
* The `Config` object takes:
* 1. [`app`](#app-2) — Your config
* 2. [`run`](#run) — Your resources
* 3. [`console`](#console) — Optionally, your app's Console config
*
* The `app` function is evaluated right when your app loads. It's used to define the app config and its providers.
*
* :::note
* You need TypeScript 5 to see the types in your config.
* :::
*
* You can add Pulumi code in the `run` function not the `app` function. While the `run`
* function is where you define your resources using SST or Pulumi's components.
*
* The run function also has access to a list of [Global](/docs/reference/global/) `$` variables and functions. These serve as the context for your app config.
*
* :::caution
* Do not `import` the provider packages in your `sst.config.ts`.
* :::
*
* Since SST manages importing your provider packages, it's recommended not to add any imports
* in your `sst.config.ts`.
*
* ---
*
* #### .env
*
* Your `.env` and `.env.<stage>` files are loaded as environment variables in your config.
* They need to be in the same directory as your `sst.config.ts`.
*
* ```bash title=".env"
* MY_ENV_VAR=hello
* ```
*
* And are available as `process.env` in both your `app` and `run` functions.
*
* ```ts title="sst.config.ts"
* process.env.MY_ENV_VAR
* ```
*
* The `.env` file takes precedence over `.env.<stage>`. So if you have a `.env` and a
* `.env.dev` file, the values in the `.env` file will be used.
*
* :::note
* You need to restart `sst dev` for changes in your `.env` files to take effect.
* :::
*
* Make sure the stage name in your `.env.<stage>` matches the stage your app is running on.
*
* @packageDocumentation
*/
import type { Shell } from "bun";
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
export interface App {
/**
* The version of SST supported by the app. The CLI will fail any commands if the version does
* not match.
*
* :::tip
* Useful in CI where you don't want it to automatically deploy with a new version of SST.
* :::
*
* @default The latest version of SST.
*
* @example
*
* Takes a specific version.
*
* ```ts
* version: "3.2.49"
* ```
*
* Also supports semver ranges.
* ```ts
* version: ">= 3.2.49"
* ```
*/
version?: string;
/**
* The name of the app. This is used to prefix the names of the resources in your app.
*
* :::caution
* If you change the name of your app, it'll redeploy your app with new resources. The old resources will be orphaned.
* :::
*
* This means that you don't want to change the name of your app without removing the old resources first.
*
* @example
*
* ```ts
* {
* name: "my-sst-app"
* }
* ```
*/
name: string;
/**
* Configure how your resources are handled when they have to be removed.
*
* - `remove`: Removes the underlying resource.
* - `retain`: Retains resources like S3 buckets and DynamoDB tables. Removes everything else.
* - `retain-all`: Retains all resources.
*
* :::tip
* If you change your removal policy, you'll need to deploy your app once for it to take
* effect.
* :::
*
* For example, retain resources if it's the _production_ stage, otherwise remove all
* resources.
*
* ```ts
* {
* removal: input.stage === "production" ? "retain" : "remove"
* }
* ```
*
* This applies to not just the `sst remove` command but also cases where you remove a
* resource from the `sst.config.ts` and run `sst dev` or `sst deploy`.
*
* <VideoAside title="Watch a video on how to protect your prod resources" href="https://youtu.be/fb6UBGwgDuA" />
*
* To control how a stage is handled on `sst remove`, check out the `protect` prop.
*
* @default `"retain"`
*/
removal?: "remove" | "retain" | "retain-all";
/**
* The providers that are being used in this app. This allows you to use the resources from
* these providers in your app.
*
* ```ts
* {
* providers: {
* aws: "6.27.0",
* cloudflare: "5.37.1"
* }
* }
* ```
*
* Check out the full list in the [Directory](/docs/all-providers#directory).
*
* :::tip
* You'll need to run `sst install` after you update the `providers` in your config.
* :::
*
* If you don't set a `provider` it uses your `home` provider with the default config. So if you set `home` to `aws`, it's the same as doing:
*
* ```ts
* {
* home: "aws",
* providers: {
* aws: "6.27.0"
* }
* }
* ```
*
* You can also configure the provider props. Here's the config for some common providers:
* - [AWS](https://www.pulumi.com/registry/packages/aws/api-docs/provider/#inputs)
* - [Cloudflare](https://www.pulumi.com/registry/packages/cloudflare/api-docs/provider/#inputs)
*
* @example
*
* For example, to change the region for AWS.
*
* ```ts
* {
* providers: {
* aws: {
* region: "us-west-2"
* }
* }
* }
* ```
*
* @default The `home` provider.
*/
providers?: Record<string, any>;
/**
* The provider SST will use to store the state for your app. The state keeps track of all your resources and secrets. The state is generated locally and backed up in your cloud provider.
*
*
* Currently supports AWS, Cloudflare and local.
*
* :::tip
* SST uses the `home` provider to store the state for your app. If you use the local provider it will be saved on your machine. You can see where by running `sst version`.
* :::
*
* If you want to configure the aws or cloudflare home provider, you can:
*
* ```ts
* {
* home: "aws",
* providers: {
* aws: {
* region: "us-west-2"
* }
* }
* }
* ```
*
*/
home: "aws" | "cloudflare" | "local";
/**
* If set to `true`, the `sst remove` CLI will not run and will error out.
*
* This is useful for preventing cases where you run `sst remove --stage <stage>` for the
* wrong stage.
*
* :::tip
* Protect your production stages from being accidentally removed.
* :::
*
* For example, prevent the _production_ stage from being removed.
*
* ```ts
* {
* protect: input.stage === "production"
* }
* ```
*
* However, this only applies to `sst remove` for stages.
*
* <VideoAside title="Watch a video on how to protect your prod resources" href="https://youtu.be/fb6UBGwgDuA" />
*
* If you accidentally remove a resource from the `sst.config.ts` and run `sst deploy` or
* `sst dev`, it'll still get removed. To avoid this, check out the `removal` prop.
*/
protect?: boolean;
/**
* Configure which directories should be watched for changes when running `sst dev`.
* By default, all directories are watched (except node_modules and hidden directories).
*
* @example
* ```ts
* {
* watch: ["packages/www", "packages/api"]
* }
* ```
*
* This will only watch the `packages/www` and `packages/api` directories.
* The paths are relative to the project root.
*/
watch?: string[];
/**
* Configure which directories should be ignored when generating `sst-env.d.ts`
* and `sst.pyi` files.
* By default, type files are generated for all JavaScript and Python projects
* (except node_modules and hidden directories).
*
* @example
* ```ts
* {
* typeIgnore: ["packages/docs", "services/legacy-python"]
* }
* ```
*
* This will skip generating type files inside the `packages/docs` and
* `services/legacy-python` directories.
* The paths are relative to the project root.
*/
typeIgnore?: string[];
}
export interface AppInput {
/**
* The stage this app is running on. This is a string that can be passed in through the CLI.
*
* :::caution
* Changing the stage will redeploy your app to a new stage with new resources. The old resources will still be around in the old stage.
* :::
*
* If not passed in, it'll use the username of your local machine, or prompt you for it.
*/
stage: string;
}
export interface RunnerInput {
/**
* The stage the deployment will be run in.
*/
stage: string;
}
export interface Runner {
/**
* The service used to run the build. Currently, only AWS CodeBuild is supported.
*/
engine: "codebuild";
/**
* The timeout for the build. It can be from `5 minutes` to `36 hours`.
* @default `1 hour`
*/
timeout?: `${number} ${"minute" | "minutes" | "hour" | "hours"}`;
/**
* The architecture of the build machine.
*
* The `x86_64` machine uses the [`al/standard/5.0`](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/x86_64/standard/5.0) build image.
* While `arm64` uses the [`al/aarch64/standard/3.0`](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/aarch64/standard/3.0) image instead.
*
* You can also configure what's used in the image:
*
* - **Node**
*
* To specify the version of Node you want to use in your build, you can use the
* `.node-version`, `.nvmrc`, or use the `engine` field in your `package.json`.
*
* <Tabs>
* <TabItem label="package.json">
* ```js title="package.json"
* {
* engine: {
* node: "20.15.1"
* }
* }
* ```
* </TabItem>
* <TabItem label="node-version">
* ```bash title=".node-version"
* 20.15.1
* ```
* </TabItem>
* <TabItem label="nvmrc">
* ```bash title=".nvmrc"
* 20.15.1
* ```
* </TabItem>
* </Tabs>
*
* - **Package manager**
*
* To specify the package manager you want to use you can configure it through your
* `package.json`.
*
* <Tabs>
* <TabItem label="pnpm">
* ```js title="package.json"
* {
* packageManager: "pnpm@8.6.3"
* }
* ```
* </TabItem>
* <TabItem label="bun">
* ```js title="package.json"
* {
* packageManager: "bun@1.2.0"
* }
* ```
* </TabItem>
* </Tabs>
*
* Feel free to get in touch if you want to use your own build image or
* configure what's used in the build image.
*
* @default `x86_64`
*/
architecture?: "x86_64" | "arm64";
/**
* The compute size of the build environment.
*
* For `x86_64`, the following compute sizes are supported:
* - `small`: 3 GB, 2 vCPUs
* - `medium`: 7 GB, 4 vCPUs
* - `large`: 15 GB, 8 vCPUs
* - `xlarge`: 70 GB, 36 vCPUs
* - `2xlarge`: 145 GB, 72 vCPUs
*
* For `arm64` architecture, the following compute sizes are supported:
* - `small`: 4 GB, 2 vCPUs
* - `medium`: 8 GB, 4 vCPUs
* - `large`: 16 GB, 8 vCPUs
* - `xlarge`: 64 GB, 32 vCPUs
* - `2xlarge`: 96 GB, 48 vCPUs
*
* To increase the memory used by your Node.js process in the build environment, you'll want
* to set the `NODE_OPTIONS` environment variable to `--max-old-space-size=xyz`. Where `xyz`
* is the memory size in MB. By default, this is set to 1.5 GB.
*
* Read more about the [CodeBuild build environments](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html).
*
* @default `medium`
*/
compute?: "small" | "medium" | "large" | "xlarge" | "2xlarge";
/**
* The VPC to run the build in. If provided, the build environment will have access to
* resources in the VPC.
*
* This is useful for building Next.js apps that might make queries to your database
* as a part of the build process.
*
* You can get these from the outputs of the `Vpc` component your are using or from the
* [Console](/docs/console/#resources).
*
* @example
*
* ```ts
* {
* vpc: {
* id: "vpc-0be8fa4de860618bb",
* subnets: ["subnet-0be8fa4de860618bb"],
* securityGroups: ["sg-0be8fa4de860618bb"]
* }
* }
* ```
*/
vpc?: {
/**
* The ID of the VPC.
*/
id: string;
/**
* The subnets to run the build in.
*/
subnets: string[];
/**
* The security groups to run the build in.
*/
securityGroups: string[];
};
/**
* Paths to cache as a part of the build. By default the `.git` directory is cached.
*
* The given list of files and directories will be saved to the cache at the end of the build.
* And they will be restored at the start of the build process.
*
* ```ts
* {
* cache: {
* paths: ["node_modules", "/path/to/cache"]
* }
* }
* ```
*
* The relative paths are for caching files inside your repo. While the absolute path is for
* any global caches.
*
* To clear the cache, you can trigger a new deploy using the **Force** deploy option in the
* Console.
*/
cache?: {
/**
* The paths to cache. These are relative to the root of the repository.
*
* By default, the `.git` directory is always cached.
*/
paths: string[];
};
}
interface GitSender {
/**
* The ID of the user.
*/
id: number;
/**
* The username of the user.
*/
username: string;
}
interface GitCommit {
/**
* The ID of the commit.
*/
id: string;
/**
* The commit message.
*/
message: string;
}
interface GitRepo {
/**
* The ID of the repo. This is usually a number.
*/
id: number;
/**
* The name of the owner or org the repo to belongs to.
*/
owner: string;
/**
* The name of the repo.
*/
repo: string;
}
/**
* A git event for when a branch is updated or deleted. For example:
* ```js
* {
* type: "branch",
* action: "pushed",
* repo: {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* },
* branch: "main",
* commit: {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* },
* sender: {
* id: 1,
* username: "octocat"
* }
* }
* ```
*/
export interface BranchEvent {
/**
* The git event type, for the `BranchEvent` it's `branch`.
*/
type: "branch";
/**
* The type of the git action.
*
* - `pushed` is when you git push to a branch
* - `removed` is when a branch is removed
*/
action: "pushed" | "removed";
/**
* The Git repository the event is coming from. This might look like:
*
* ```js
* {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* }
* ```
*/
repo: Prettify<GitRepo>;
/**
* The name of the branch the event is coming from.
*/
branch: string;
/**
* Info about the commit in the event. This might look like:
*
* ```js
* {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* }
* ```
*/
commit: Prettify<GitCommit>;
/**
* The user that generated the event. For example:
*
* ```js
* {
* id: 1,
* username: "octocat"
* }
* ```
*/
sender: Prettify<GitSender>;
}
/**
* A git event for when a tag is created or deleted. For example:
* ```js
* {
* type: "tag",
* action: "pushed",
* repo: {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* },
* tag: "v1.5.2",
* commit: {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* },
* sender: {
* id: 1,
* username: "octocat"
* }
* }
* ```
*/
export interface TagEvent {
/**
* The git event type, for the `TagEvent` it's `tag`.
*/
type: "tag";
/**
* The type of the git action.
*
* - `pushed` is when you create a tag
* - `removed` is when a tag is removed
*/
action: "pushed" | "removed";
/**
* The Git repository the event is coming from. This might look like:
*
* ```js
* {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* }
* ```
*/
repo: Prettify<GitRepo>;
/**
* The name of the tag. For example, `v1.5.2`.
*/
tag: string;
/**
* Info about the commit in the event. This might look like:
*
* ```js
* {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* }
* ```
*/
commit: Prettify<GitCommit>;
/**
* The user that generated the event. For example:
*
* ```js
* {
* id: 1,
* username: "octocat"
* }
* ```
*/
sender: Prettify<GitSender>;
}
/**
* A git event for when a pull request is updated or deleted. For example:
*
* ```js
* {
* type: "pull_request",
* action: "pushed",
* repo: {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* },
* number: 1347,
* base: "main",
* head: "feature",
* commit: {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* },
* sender: {
* id: 1,
* username: "octocat"
* }
* }
* ```
*/
export interface PullRequestEvent {
/**
* The git event type, for the `PullRequestEvent` it's `pull_request`.
*/
type: "pull_request";
/**
* The type of the git action.
*
* - `pushed` is when you git push to the base branch of the PR
* - `removed` is when the PR is closed or merged
*/
action: "pushed" | "removed";
/**
* The Git repository the event is coming from. This might look like:
*
* ```js
* {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* }
* ```
*/
repo: Prettify<GitRepo>;
/**
* The pull request number.
*/
number: number;
/**
* The title of the pull request.
*/
title: string;
/**
* The base branch of the PR. This is the branch the code is being merged into.
*/
base: string;
/**
* The head branch of the PR. This is the branch the code is coming from.
*/
head: string;
/**
* Info about the commit in the event. This might look like:
*
* ```js
* {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* }
* ```
*/
commit: Prettify<GitCommit>;
/**
* The user that generated the event. For example:
*
* ```js
* {
* id: 1,
* username: "octocat"
* }
* ```
*/
sender: Prettify<GitSender>;
}
/**
* A user event for when the user manually triggers a deploy. For example:
* ```js
* {
* type: "user",
* action: "deploy",
* repo: {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* },
* ref: "main",
* commit: {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* }
* }
* ```
*/
export interface UserEvent {
/**
* The user event type.
*/
type: "user";
/**
* The type of the user action.
*
* - `deploy` is when you manually trigger a deploy
* - `remove` is when you manually remove a stage
*/
action: "deploy" | "remove";
/**
* The Git repository the event is coming from. This might look like:
*
* ```js
* {
* id: 1296269,
* owner: "octocat",
* repo: "Hello-World"
* }
* ```
*/
repo: Prettify<GitRepo>;
/**
* The reference to the Git commit. This can be the branch, tag, or commit hash.
*/
ref: string;
/**
* Info about the commit in the event. This might look like:
*
* ```js
* {
* id: "b7e7c4c559e0e5b4bc6f8d98e0e5e5e5e5e5e5e5",
* message: "Update the README with new information"
* }
* ```
*/
commit: Prettify<GitCommit>;
}
export interface Target {
/**
* The stage or a list of stages the app will be deployed to.
*/
stage: string | string[];
}
export interface WorkflowInput {
/**
* The [Bun shell](https://bun.sh/docs/runtime/shell). It's a cross-platform
* _bash-like_ shell for scripting with JavaScript and TypeScript.
*/
$: Shell;
/**
* The event that triggered the workflow.
*
* This includes git branch, pull request, or tag events. And it also
* includes a user event for manual deploys that are triggered through the
* Console.
*/
event: BranchEvent | PullRequestEvent | TagEvent | UserEvent;
}
export interface Config {
/**
* The config for your app. It needs to return an object of type [`App`](#app-1). The `app`
* function is evaluated when your app loads.
*
* :::caution
* You cannot define any components or resources in the `app` function.
* :::
*
* Here's an example of a simple `app` function.
*
* @example
*
* ```ts title="sst.config.ts"
* app(input) {
* return {
* name: "my-sst-app",
* home: "aws",
* providers: {
* aws: true,
* cloudflare: {
* accountId: "6fef9ed9089bb15de3e4198618385de2"
* }
* },
* removal: input.stage === "production" ? "retain" : "remove"
* };
* },
* ```
*/
app(input: AppInput): App | Promise<App>;
/**
* Configure how your app works with the SST Console.
*/
console?: {
/**
* Auto-deploys your app when you _git push_ to your repo. Uses
* [AWS CodeBuild](https://aws.amazon.com/codebuild/) in your account to run the build.
*
* To get started, first [make sure to set up Autodeploy](/docs/console#setup).
* Specifically, you need to configure an environment with the stage and AWS account
* you want to auto-deploy to.
*
* Now when you _git push_ to a branch, pull request, or tag, the following happens:
*
* 1. The stage name is generated based on the `autodeploy.target` callback.
* 1. If there is no callback, the stage name is a sanitized version of the branch or tag.
* 2. If there is a callback but no stage is returned, the deploy is skipped.
* 2. The runner config is generated based on the `autodeploy.runner`. Or the defaults are
* used.
* 3. The stage is matched against the environments in the Console to get the AWS account
* and any environment variables for the deploy.
* 4. The deploy is run based on the above config.
*
* This only applies only to git events. If you trigger a deploy through the Console, you
* are asked to sepcify the stage you want to deploy to. So in this case, it skips step 1
* from above and does not call `autodeploy.target`.
*
* You can further configure Autodeploy through the `autodeploy` prop.
*
* ```ts title="sst.config.ts"
* console: {
* autodeploy: {
* target(event) {}, // Customize the target stage
* runner(stage) {}, // Customize the runner
* async workflow({ $, input }) {} // Customize the workflow
* }
* }
* ```
*
* Here, `target`, `runner`, and `workflow` are all optional and come with defaults, so
* you don't need to configure anything. But you can customize them.
*
* ```ts
* {
* autodeploy: {
* target(event) {
* if (
* event.type === "branch" &&
* event.branch === "main" &&
* event.action === "pushed"
* ) {
* return { stage: "production" };
* }
* },
* runner(stage) {
* if (stage === "production") return { timeout: "3 hours" };
* }
* }
* }
* ```
*
* For example, here we are only auto-deploying to the `production` stage when you git push
* to the `main` branch. We are also setting the timeout to 3 hours for the `production`
* stage. You can read more about the `target` and `runner` props below.
*
* Finally, if you want to configure exactly what happens in the build, you can pass in
* a `workflow` function.
*
* ```ts
* {
* autodeploy: {
* async workflow({ $, event }) {
* await $`npm i -g pnpm`;
* await $`pnpm i`;
* event.action === "removed"
* ? await $`pnpm sst remove`
* : await $`pnpm sst deploy`;
* }
* }
* }
* ```
*
* You can read more the `workflow` prop below.
*
* @default Auto-deploys branches and PRs.
*/
autodeploy: {
/**
* Defines the stage or a list of stages the app will be auto-deployed to.
*
* When a git event is received, Autodeploy will run the `target` function with the
* git event. This function should return the stage or a list of stages the app will
* be deployed to. Or `undefined` if the deploy should be skipped.
*
* :::tip
* Return `undefined` to skip the deploy.
* :::
*
* The stage that is returned is then compared to the environments set in the
* [app settings in the Console](/docs/console/#setup). If the stage matches an
* environment, the stage will be deployed to that environment. If no matching environment
* is found, the deploy will be skipped.
*
* :::note
* You need to configure an environment in the Console to be able to deploy to it.
* :::
*
* Currently, only git events for **branches**, **pull requests**, and **tags** are
* supported.
*
* :::tip
* This is not called when you manually trigger a deploy through the Console.
* :::
*
* This config only applies to git events. If you trigger a deploy through the Console,
* you are asked to sepcify the stage you want to deploy to. In this case, and