sst 2.22.10 → 2.23.0

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.
@@ -0,0 +1,398 @@
1
+ import { Construct } from "constructs";
2
+ import { DistributionDomainProps } from "./Distribution.js";
3
+ import { SSTConstruct } from "./Construct.js";
4
+ import { Permissions } from "./util/permission.js";
5
+ import { FunctionBindingProps } from "./util/functionBinding.js";
6
+ import { ISecurityGroup, IVpc, SubnetSelection } from "aws-cdk-lib/aws-ec2";
7
+ import { Cluster } from "aws-cdk-lib/aws-ecs";
8
+ declare const supportedCpus: {
9
+ "0.25 vCPU": number;
10
+ "0.5 vCPU": number;
11
+ "1 vCPU": number;
12
+ "2 vCPU": number;
13
+ "4 vCPU": number;
14
+ "8 vCPU": number;
15
+ "16 vCPU": number;
16
+ };
17
+ export interface ServiceDomainProps extends DistributionDomainProps {
18
+ }
19
+ export interface ServiceProps {
20
+ /**
21
+ * Path to the directory where the app is located.
22
+ * @default "."
23
+ */
24
+ path?: string;
25
+ /**
26
+ * The amount of cpu allocated.
27
+ * @default "0.25 vCPU"
28
+ * @example
29
+ * ```js
30
+ * {
31
+ * cpu: "1 vCPU",
32
+ * }
33
+ *```
34
+ */
35
+ cpu?: keyof typeof supportedCpus;
36
+ /**
37
+ * The amount of memory allocated.
38
+ * @default "0.5 GB"
39
+ * @example
40
+ * ```js
41
+ * {
42
+ * memory: "2 GB",
43
+ * }
44
+ *```
45
+ */
46
+ memory?: `${number} GB`;
47
+ /**
48
+ * The port number on the container.
49
+ * @default 3000
50
+ * @example
51
+ * ```js
52
+ * {
53
+ * port: 8000,
54
+ * }
55
+ *```
56
+ */
57
+ port?: number;
58
+ scaling?: {
59
+ /**
60
+ * The minimum capacity for the cluster.
61
+ * @default 1
62
+ * @example
63
+ * ```js
64
+ * {
65
+ * scaling: {
66
+ * minContainers: 4,
67
+ * maxContainers: 16,
68
+ * },
69
+ * }
70
+ *```
71
+ */
72
+ minContainers?: number;
73
+ /**
74
+ * The maximum capacity for the cluster.
75
+ * @default 1
76
+ * @example
77
+ * ```js
78
+ * {
79
+ * scaling: {
80
+ * minContainers: 4,
81
+ * maxContainers: 16,
82
+ * },
83
+ * }
84
+ *```
85
+ */
86
+ maxContainers?: number;
87
+ /**
88
+ * Scales in or out to achieve a target cpu utilization.
89
+ * @default 70
90
+ * @example
91
+ * ```js
92
+ * {
93
+ * scaling: {
94
+ * cpuUtilization: 50,
95
+ * memoryUtilization: 50,
96
+ * },
97
+ * }
98
+ *```
99
+ */
100
+ cpuUtilization?: number;
101
+ /**
102
+ * Scales in or out to achieve a target memory utilization.
103
+ * @default 70
104
+ * @example
105
+ * ```js
106
+ * {
107
+ * scaling: {
108
+ * cpuUtilization: 50,
109
+ * memoryUtilization: 50,
110
+ * },
111
+ * }
112
+ *```
113
+ */
114
+ memoryUtilization?: number;
115
+ /**
116
+ * Scales in or out to achieve a target request count per container.
117
+ * @default 500
118
+ * @example
119
+ * ```js
120
+ * {
121
+ * scaling: {
122
+ * requestsPerContainer: 1000,
123
+ * },
124
+ * }
125
+ *```
126
+ */
127
+ requestsPerContainer?: number;
128
+ };
129
+ /**
130
+ * Bind resources for the function
131
+ *
132
+ * @example
133
+ * ```js
134
+ * {
135
+ * bind: [STRIPE_KEY, bucket],
136
+ * }
137
+ * ```
138
+ */
139
+ bind?: SSTConstruct[];
140
+ /**
141
+ * The customDomain for this service. SST supports domains that are hosted
142
+ * either on [Route 53](https://aws.amazon.com/route53/) or externally.
143
+ *
144
+ * Note that you can also migrate externally hosted domains to Route 53 by
145
+ * [following this guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html).
146
+ *
147
+ * @example
148
+ * ```js
149
+ * {
150
+ * customDomain: "domain.com",
151
+ * }
152
+ * ```
153
+ *
154
+ * ```js
155
+ * {
156
+ * customDomain: {
157
+ * domainName: "domain.com",
158
+ * domainAlias: "www.domain.com",
159
+ * hostedZone: "domain.com"
160
+ * }
161
+ * }
162
+ * ```
163
+ */
164
+ customDomain?: string | ServiceDomainProps;
165
+ /**
166
+ * Attaches the given list of permissions to the SSR function. Configuring this property is equivalent to calling `attachPermissions()` after the site is created.
167
+ * @example
168
+ * ```js
169
+ * {
170
+ * permissions: ["ses"]
171
+ * }
172
+ * ```
173
+ */
174
+ permissions?: Permissions;
175
+ /**
176
+ * An object with the key being the environment variable name.
177
+ *
178
+ * @example
179
+ * ```js
180
+ * {
181
+ * environment: {
182
+ * API_URL: api.url,
183
+ * USER_POOL_CLIENT: auth.cognitoUserPoolClient.userPoolClientId,
184
+ * },
185
+ * }
186
+ * ```
187
+ */
188
+ environment?: Record<string, string>;
189
+ dev?: {
190
+ /**
191
+ * When running `sst dev, site is not deployed. This is to ensure `sst dev` can start up quickly.
192
+ * @default false
193
+ * @example
194
+ * ```js
195
+ * {
196
+ * dev: {
197
+ * deploy: true
198
+ * }
199
+ * }
200
+ * ```
201
+ */
202
+ deploy?: boolean;
203
+ /**
204
+ * The local site URL when running `sst dev`.
205
+ * @example
206
+ * ```js
207
+ * {
208
+ * dev: {
209
+ * url: "http://localhost:3000"
210
+ * }
211
+ * }
212
+ * ```
213
+ */
214
+ url?: string;
215
+ };
216
+ /**
217
+ * While deploying, SST waits for the CloudFront cache invalidation process to finish. This ensures that the new content will be served once the deploy command finishes. However, this process can sometimes take more than 5 mins. For non-prod environments it might make sense to pass in `false`. That'll skip waiting for the cache to invalidate and speed up the deploy process.
218
+ * @default false
219
+ * @example
220
+ * ```js
221
+ * {
222
+ * waitForInvalidation: true
223
+ * }
224
+ * ```
225
+ */
226
+ waitForInvalidation?: boolean;
227
+ cdk?: {
228
+ /**
229
+ * Runs codebuild job in the specified VPC. Note this will only work once deployed.
230
+ *
231
+ * @example
232
+ * ```js
233
+ * import { Vpc } from "aws-cdk-lib/aws-ec2";
234
+ *
235
+ * {
236
+ * cdk: {
237
+ * vpc: Vpc.fromLookup(stack, "VPC", {
238
+ * vpcId: "vpc-xxxxxxxxxx",
239
+ * }),
240
+ * }
241
+ * }
242
+ * ```
243
+ */
244
+ vpc?: IVpc;
245
+ /**
246
+ * Where to place the network interfaces within the VPC.
247
+ * @default All private subnets.
248
+ * @example
249
+ * ```js
250
+ * import { SubnetType } from "aws-cdk-lib/aws-ec2";
251
+ *
252
+ * {
253
+ * cdk: {
254
+ * vpc,
255
+ * vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS }
256
+ * }
257
+ * }
258
+ * ```
259
+ */
260
+ vpcSubnets?: SubnetSelection;
261
+ /**
262
+ * The list of security groups to associate with the Job's network interfaces.
263
+ * @default A new security group is created.
264
+ * @example
265
+ * ```js
266
+ * import { SecurityGroup } from "aws-cdk-lib/aws-ec2";
267
+ *
268
+ * {
269
+ * cdk: {
270
+ * vpc,
271
+ * securityGroups: [
272
+ * new SecurityGroup(stack, "MyJobSG", { vpc })
273
+ * ]
274
+ * }
275
+ * }
276
+ * ```
277
+ */
278
+ securityGroups?: ISecurityGroup[];
279
+ };
280
+ }
281
+ type ServiceNormalizedProps = ServiceProps & {
282
+ path: Exclude<ServiceProps["path"], undefined>;
283
+ cpu: Exclude<ServiceProps["cpu"], undefined>;
284
+ memory: Exclude<ServiceProps["memory"], undefined>;
285
+ port: Exclude<ServiceProps["port"], undefined>;
286
+ waitForInvalidation: Exclude<ServiceProps["waitForInvalidation"], undefined>;
287
+ };
288
+ /**
289
+ * The `Service` construct is a higher level CDK construct that makes it easy to create modern web apps with Server Side Rendering capabilities.
290
+ * @example
291
+ * Deploys a service in the `app` directory.
292
+ *
293
+ * ```js
294
+ * new Service(stack, "myApp", {
295
+ * path: "app",
296
+ * });
297
+ * ```
298
+ */
299
+ export declare class Service extends Construct implements SSTConstruct {
300
+ readonly id: string;
301
+ private props;
302
+ private doNotDeploy;
303
+ private devFunction?;
304
+ private vpc;
305
+ private cluster;
306
+ private container;
307
+ private taskDefinition;
308
+ private distribution;
309
+ constructor(scope: Construct, id: string, props?: ServiceProps);
310
+ /**
311
+ * The CloudFront URL of the website.
312
+ */
313
+ get url(): string | undefined;
314
+ /**
315
+ * If the custom domain is enabled, this is the URL of the website with the
316
+ * custom domain.
317
+ */
318
+ get customDomainUrl(): string | undefined;
319
+ /**
320
+ * The internally created CDK resources.
321
+ */
322
+ get cdk(): {
323
+ vpc: IVpc;
324
+ cluster: Cluster;
325
+ distribution: import("aws-cdk-lib/aws-cloudfront").IDistribution;
326
+ hostedZone: import("aws-cdk-lib/aws-route53").IHostedZone | undefined;
327
+ certificate: import("aws-cdk-lib/aws-certificatemanager").ICertificate | undefined;
328
+ } | undefined;
329
+ getConstructMetadata(): {
330
+ type: "Service";
331
+ data: {
332
+ mode: "placeholder" | "deployed";
333
+ path: string;
334
+ customDomainUrl: string | undefined;
335
+ url: string | undefined;
336
+ devFunction: string | undefined;
337
+ task: string;
338
+ container: string;
339
+ secrets: string[];
340
+ };
341
+ };
342
+ /** @internal */
343
+ getFunctionBinding(): FunctionBindingProps;
344
+ /**
345
+ * Binds additional resources to service.
346
+ *
347
+ * @example
348
+ * ```js
349
+ * service.bind([STRIPE_KEY, bucket]);
350
+ * ```
351
+ */
352
+ bind(constructs: SSTConstruct[]): void;
353
+ /**
354
+ * Attaches the given list of permissions to allow the service
355
+ * to access other AWS resources.
356
+ *
357
+ * @example
358
+ * ```js
359
+ * service.attachPermissions(["sns"]);
360
+ * ```
361
+ */
362
+ attachPermissions(permissions: Permissions): void;
363
+ /**
364
+ * Attaches additional environment variable to the service.
365
+ *
366
+ * @example
367
+ * ```js
368
+ * service.addEnvironment({
369
+ * DEBUG: "*"
370
+ * });
371
+ * ```
372
+ */
373
+ addEnvironment(name: string, value: string): void;
374
+ private validateServiceExists;
375
+ private validateMemoryAndCpu;
376
+ private createVpc;
377
+ private createService;
378
+ private createLoadBalancer;
379
+ private createAutoScaling;
380
+ private createDistribution;
381
+ private createDevFunction;
382
+ private bindForService;
383
+ private addEnvironmentForService;
384
+ private attachPermissionsForService;
385
+ private createNixpacksBuilder;
386
+ private runNixpacksBuild;
387
+ private runDockerBuild;
388
+ private updateContainerImage;
389
+ }
390
+ export declare const useServices: () => {
391
+ add(stack: string, name: string, props: ServiceNormalizedProps): void;
392
+ readonly all: {
393
+ stack: string;
394
+ name: string;
395
+ props: ServiceNormalizedProps;
396
+ }[];
397
+ };
398
+ export {};