├── .eslintrc.json ├── .github └── workflows │ ├── test.yml │ └── update-and-release.yml ├── .gitignore ├── .npmignore ├── .npmrc ├── README.md ├── index.d.ts ├── package.json ├── serverless.yml ├── src └── plugin.ts └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:prettier/recommended" 5 | ], 6 | "rules": { 7 | "curly": [ 8 | "error", 9 | "all" 10 | ], 11 | "eqeqeq": [ 12 | "error", 13 | "smart" 14 | ], 15 | "import/no-extraneous-dependencies": [ 16 | "error", 17 | { 18 | "devDependencies": true, 19 | "optionalDependencies": false, 20 | "peerDependencies": false 21 | } 22 | ], 23 | "no-shadow": [ 24 | "error", 25 | { 26 | "hoist": "all" 27 | } 28 | ], 29 | "prefer-const": "error", 30 | "import/order": [ 31 | "error", 32 | { 33 | "groups": [ 34 | [ 35 | "external", 36 | "builtin" 37 | ], 38 | "internal", 39 | [ 40 | "parent", 41 | "sibling", 42 | "index" 43 | ] 44 | ] 45 | } 46 | ], 47 | "sort-imports": [ 48 | "error", 49 | { 50 | "ignoreCase": true, 51 | "ignoreDeclarationSort": true, 52 | "ignoreMemberSort": false, 53 | "memberSyntaxSortOrder": [ 54 | "none", 55 | "all", 56 | "multiple", 57 | "single" 58 | ] 59 | } 60 | ], 61 | "padding-line-between-statements": [ 62 | "error", 63 | { 64 | "blankLine": "always", 65 | "prev": "*", 66 | "next": "return" 67 | } 68 | ] 69 | }, 70 | "root": true, 71 | "plugins": [ 72 | "import" 73 | ], 74 | "env": { 75 | "es6": true, 76 | "node": true 77 | }, 78 | "overrides": [ 79 | { 80 | "files": [ 81 | "src/**/*.ts" 82 | ], 83 | "extends": [ 84 | "plugin:@typescript-eslint/recommended", 85 | "plugin:@typescript-eslint/recommended-requiring-type-checking", 86 | "prettier/@typescript-eslint" 87 | ], 88 | "parser": "@typescript-eslint/parser", 89 | "parserOptions": { 90 | "project": "tsconfig.json" 91 | }, 92 | "rules": { 93 | "@typescript-eslint/prefer-optional-chain": "error", 94 | "no-shadow": "off", 95 | "@typescript-eslint/no-shadow": "error", 96 | "@typescript-eslint/prefer-nullish-coalescing": "error", 97 | "@typescript-eslint/strict-boolean-expressions": "error", 98 | "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", 99 | "@typescript-eslint/no-unnecessary-condition": "error", 100 | "@typescript-eslint/no-unnecessary-type-arguments": "error", 101 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 102 | "@typescript-eslint/switch-exhaustiveness-check": "error" 103 | } 104 | } 105 | ] 106 | } 107 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: push 3 | 4 | jobs: 5 | tests: 6 | name: Run serverless/typescript tests 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout repository 10 | uses: actions/checkout@v2 11 | 12 | - name: Install Node.js and npm 13 | uses: actions/setup-node@v1 14 | with: 15 | node-version: 20.x 16 | registry-url: https://registry.npmjs.org 17 | 18 | - name: Install dependencies 19 | run: npm i 20 | 21 | - name: Run lint tests 22 | run: npm run test:lint 23 | 24 | - name: Run type tests 25 | run: npm run test:type 26 | -------------------------------------------------------------------------------- /.github/workflows/update-and-release.yml: -------------------------------------------------------------------------------- 1 | name: Update and Release Serverless Definitions 2 | on: 3 | workflow_dispatch: 4 | repository_dispatch: 5 | types: [serverless-released] 6 | 7 | jobs: 8 | generateTSDefinitions: 9 | name: Generate serverless/serverless typescript definitions 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v2 14 | 15 | - name: Install Node.js and npm 16 | uses: actions/setup-node@v1 17 | with: 18 | node-version: 20.x 19 | registry-url: https://registry.npmjs.org 20 | 21 | - name: Install dependencies 22 | run: npm i 23 | 24 | - name: Build plugin 25 | run: npm run build 26 | 27 | - name: Set Serverless latest version 28 | id: serverless-version 29 | run: | 30 | version=$(npm list serverless | grep serverless@ | sed 's/.*serverless@/v/g' | tr -d '[[:space:]]') 31 | echo "version=$version" >> $GITHUB_ENV 32 | 33 | - name: Generate TypeScript Definitions 34 | run: npx sls schema 35 | env: 36 | SERVERLESS_ACCESS_KEY: ${{secrets.SERVERLESS_ACCESS_KEY}} 37 | 38 | - name: Update package.json version 39 | run: npm version ${{ env.version }} --git-tag-version=false 40 | 41 | - name: Commit changes 42 | uses: EndBug/add-and-commit@v5 43 | with: 44 | author_name: Eslam λ Hefnawy 45 | author_email: eslam@serverless.com 46 | branch: master 47 | message: Add Serverless definitions for ${{ env.version }} 48 | add: index.d.ts package.json 49 | tag: ${{ env.version }} --force 50 | env: 51 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 52 | 53 | - name: Publish 54 | uses: JS-DevTools/npm-publish@v1 55 | with: 56 | token: ${{ secrets.NPM_TOKEN }} 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .github 2 | .gitignore 3 | dist 4 | node_modules 5 | src 6 | serverless.yml 7 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # serverless/typescript 2 | 3 | Typescript definitions for Serverless `serverless.ts` service file. 4 | 5 | Since [v1.72.0](https://github.com/serverless/serverless/releases/tag/v1.72.0), the Serverless framework accepts `serverless.ts` as a valid service file in addition to the usual `serverless.yml`, `serverless.json` and `serverless.js` file formats. 6 | 7 | This repository serves as a replacement of the community-maintained [DefinitelyTyped @types/serverless package](https://www.npmjs.com/package/@types/serverless). It aims to automate service file TypeScript definitions based on JSON-schema used by [serverless/serverless](https://github.com/serverless/serverless) for validation at the beginning of any Serverless CLI command. This automated pipeline is triggered every time a new release of Serverless framework is available. The pipeline ends with the publishing of the newly generated definitions to NPM, ensuring they are always up to date and consistent with the framework internal validation logic. 8 | 9 | ![TypeScript definition generation pipeline](https://miro.medium.com/max/1400/1*7TeqkHLkfPEXJ6f2NzbV3A.png) 10 | 11 | ## Installation 12 | 13 | ``` 14 | npm i @serverless/typescript --save-dev 15 | ``` 16 | 17 | or 18 | 19 | ``` 20 | yarn add @serverless/typescript --dev 21 | ``` 22 | 23 | ## Usage 24 | 25 | `serverless.ts` file 26 | 27 | ```ts 28 | import type { AWS } from '@serverless/typescript'; 29 | 30 | const serverlessConfiguration: AWS = { 31 | service: 'aws-nodejs-typescript', 32 | frameworkVersion: '*', 33 | provider: { 34 | name: 'aws', 35 | runtime: 'nodejs12.x', 36 | }, 37 | functions: { 38 | hello: { 39 | handler: 'handler.hello', 40 | events: [ 41 | { 42 | http: { 43 | method: 'get', 44 | path: 'hello', 45 | } 46 | } 47 | ] 48 | } 49 | } 50 | } 51 | 52 | module.exports = serverlessConfiguration; 53 | ``` 54 | 55 | ## Contributing 56 | 57 | > **No PR including modifications on `index.d.ts` will be accepted.** The service file Typescript definitions enclosed within this file are automatically generated at each new Serverless framework release. If any manual modification was added to this file, those would be overwritten during the next Serverless version release and TypeScript definitions generation process. 58 | 59 | We love our contributors! 60 | 61 | Check out our [help wanted](https://github.com/serverless/typescript/labels/help%20wanted) or [good first issue](https://github.com/serverless/typescript/labels/good%20first%20issue) labels to find issues we want to move forward on with your help. 62 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated by json-schema-to-typescript. 4 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, 5 | * and run json-schema-to-typescript to regenerate this file. 6 | */ 7 | 8 | export type ErrorCode = string; 9 | export type AwsCfFunction = 10 | | AwsCfImport 11 | | AwsCfJoin 12 | | AwsCfGetAtt 13 | | AwsCfRef 14 | | AwsCfSub 15 | | AwsCfBase64 16 | | AwsCfToJsonString; 17 | export type AwsCfInstruction = string | AwsCfFunction; 18 | export type AwsArn = AwsArnString | AwsCfFunction; 19 | export type AwsArnString = string; 20 | export type FunctionName = string; 21 | export type AwsSecretsManagerArnString = string; 22 | export type FilterPatterns = { 23 | [k: string]: unknown; 24 | }[]; 25 | export type AwsAlbListenerArn = string; 26 | export type AwsAlexaEventToken = string; 27 | export type AwsLogGroupName = string; 28 | export type AwsKmsArn = AwsCfFunction | string; 29 | export type AwsLambdaArchitecture = "arm64" | "x86_64"; 30 | export type AwsResourceCondition = string; 31 | export type AwsResourceDependsOn = string[]; 32 | export type EcrImageUri = string; 33 | export type AwsLambdaLayers = AwsArn[]; 34 | export type AwsLogRetentionInDays = 35 | | 1 36 | | 3 37 | | 5 38 | | 7 39 | | 14 40 | | 30 41 | | 60 42 | | 90 43 | | 120 44 | | 150 45 | | 180 46 | | 365 47 | | 400 48 | | 545 49 | | 731 50 | | 1827 51 | | 2192 52 | | 2557 53 | | 2922 54 | | 3288 55 | | 3653; 56 | export type AwsLambdaMemorySize = number; 57 | export type AwsLambdaRole = string | AwsCfSub | AwsCfImport | AwsCfGetAtt; 58 | export type AwsLambdaRuntime = 59 | | "dotnet6" 60 | | "dotnet8" 61 | | "go1.x" 62 | | "java21" 63 | | "java17" 64 | | "java11" 65 | | "java8" 66 | | "java8.al2" 67 | | "nodejs14.x" 68 | | "nodejs16.x" 69 | | "nodejs18.x" 70 | | "nodejs20.x" 71 | | "nodejs22.x" 72 | | "provided" 73 | | "provided.al2" 74 | | "provided.al2023" 75 | | "python3.7" 76 | | "python3.8" 77 | | "python3.9" 78 | | "python3.10" 79 | | "python3.11" 80 | | "python3.12" 81 | | "python3.13" 82 | | "ruby2.7" 83 | | "ruby3.2" 84 | | "ruby3.3"; 85 | export type AwsLambdaRuntimeManagement = 86 | | ("auto" | "onFunctionUpdate") 87 | | { 88 | mode?: "auto" | "onFunctionUpdate" | "manual"; 89 | arn?: AwsArn; 90 | }; 91 | export type AwsLambdaTimeout = number; 92 | export type AwsLambdaTracing = ("Active" | "PassThrough") | boolean; 93 | export type AwsLambdaVersioning = boolean; 94 | export type AwsHttpApiPayload = "1.0" | "2.0"; 95 | export type AwsApiGatewayApiKeys = ( 96 | | string 97 | | AwsApiGatewayApiKeysProperties 98 | | { 99 | [k: string]: (string | AwsApiGatewayApiKeysProperties)[]; 100 | } 101 | )[]; 102 | export type AwsResourcePolicyStatements = ({ 103 | [k: string]: unknown; 104 | } & ( 105 | | { 106 | [k: string]: unknown; 107 | } 108 | | { 109 | [k: string]: unknown; 110 | } 111 | ) & 112 | ( 113 | | { 114 | [k: string]: unknown; 115 | } 116 | | { 117 | [k: string]: unknown; 118 | } 119 | ))[]; 120 | export type AwsS3BucketName = string; 121 | export type AwsIamPolicyStatements = ({ 122 | [k: string]: unknown; 123 | } & ( 124 | | { 125 | [k: string]: unknown; 126 | } 127 | | { 128 | [k: string]: unknown; 129 | } 130 | ) & 131 | ( 132 | | { 133 | [k: string]: unknown; 134 | } 135 | | { 136 | [k: string]: unknown; 137 | } 138 | ))[]; 139 | export type Stage = string; 140 | export type AwsCfArrayInstruction = AwsCfInstruction[] | AwsCfSplit; 141 | export type ServiceName = string; 142 | 143 | export interface AWS { 144 | org?: string; 145 | app?: string; 146 | outputs?: { 147 | [k: string]: 148 | | string 149 | | number 150 | | boolean 151 | | unknown[] 152 | | { 153 | [k: string]: unknown; 154 | }; 155 | }; 156 | configValidationMode?: "error" | "warn" | "off"; 157 | console?: 158 | | boolean 159 | | { 160 | [k: string]: unknown; 161 | }; 162 | custom?: { 163 | [k: string]: unknown; 164 | }; 165 | dashboard?: { 166 | disableMonitoring?: boolean; 167 | }; 168 | deprecationNotificationMode?: "error" | "warn" | "warn:summary"; 169 | disabledDeprecations?: "*" | ErrorCode[]; 170 | build?: 171 | | string 172 | | { 173 | esbuild?: 174 | | { 175 | external?: string[]; 176 | exclude?: string[]; 177 | packages?: "external"; 178 | buildConcurrency?: number; 179 | bundle?: boolean; 180 | minify?: boolean; 181 | sourcemap?: 182 | | boolean 183 | | { 184 | type?: "inline" | "linked" | "external"; 185 | setNodeOptions?: boolean; 186 | [k: string]: unknown; 187 | }; 188 | [k: string]: unknown; 189 | } 190 | | boolean; 191 | [k: string]: unknown; 192 | }; 193 | frameworkVersion?: string; 194 | functions?: { 195 | /** 196 | * This interface was referenced by `undefined`'s JSON-Schema definition 197 | * via the `patternProperty` "^[a-zA-Z0-9-_]+$". 198 | */ 199 | [k: string]: { 200 | name?: string; 201 | events?: ( 202 | | { 203 | __schemaWorkaround__: null; 204 | } 205 | | { 206 | schedule: 207 | | string 208 | | { 209 | rate: (AwsCfFunction | string)[]; 210 | enabled?: boolean; 211 | name?: string; 212 | description?: string; 213 | input?: 214 | | string 215 | | ( 216 | | { 217 | body: string; 218 | } 219 | | { 220 | [k: string]: unknown; 221 | } 222 | ); 223 | inputPath?: string; 224 | inputTransformer?: { 225 | inputTemplate: string; 226 | inputPathsMap?: { 227 | [k: string]: unknown; 228 | }; 229 | }; 230 | method?: "eventBus" | "scheduler"; 231 | timezone?: string; 232 | }; 233 | } 234 | | { 235 | s3: 236 | | string 237 | | { 238 | bucket: string | AwsCfFunction | AwsCfIf; 239 | event?: string; 240 | existing?: boolean; 241 | forceDeploy?: boolean; 242 | rules?: { 243 | prefix?: string | AwsCfFunction; 244 | suffix?: string | AwsCfFunction; 245 | }[]; 246 | }; 247 | } 248 | | { 249 | http: 250 | | string 251 | | { 252 | async?: boolean; 253 | authorizer?: 254 | | string 255 | | { 256 | arn?: AwsArn; 257 | authorizerId?: AwsCfInstruction; 258 | claims?: string[]; 259 | identitySource?: string; 260 | identityValidationExpression?: string; 261 | managedExternally?: boolean; 262 | name?: string; 263 | resultTtlInSeconds?: number; 264 | scopes?: (string | AwsCfInstruction)[]; 265 | type?: string | string | string | string | string; 266 | }; 267 | connectionId?: AwsCfInstruction; 268 | connectionType?: string | string; 269 | cors?: 270 | | boolean 271 | | { 272 | allowCredentials?: boolean; 273 | cacheControl?: string; 274 | headers?: string[]; 275 | maxAge?: number; 276 | methods?: ("GET" | "POST" | "PUT" | "PATCH" | "OPTIONS" | "HEAD" | "DELETE" | "ANY")[]; 277 | origin?: string; 278 | origins?: string[]; 279 | }; 280 | integration?: string | string | string | string | string | string | string | string | string | string; 281 | method: string; 282 | operationId?: string; 283 | path: string; 284 | private?: boolean; 285 | request?: { 286 | contentHandling?: "CONVERT_TO_BINARY" | "CONVERT_TO_TEXT"; 287 | method?: string; 288 | parameters?: { 289 | querystrings?: { 290 | [k: string]: 291 | | boolean 292 | | { 293 | required?: boolean; 294 | mappedValue?: AwsCfInstruction; 295 | }; 296 | }; 297 | headers?: { 298 | [k: string]: 299 | | boolean 300 | | { 301 | required?: boolean; 302 | mappedValue?: AwsCfInstruction; 303 | }; 304 | }; 305 | paths?: { 306 | [k: string]: 307 | | boolean 308 | | { 309 | required?: boolean; 310 | mappedValue?: AwsCfInstruction; 311 | }; 312 | }; 313 | }; 314 | passThrough?: "NEVER" | "WHEN_NO_MATCH" | "WHEN_NO_TEMPLATES"; 315 | schemas?: { 316 | [k: string]: 317 | | { 318 | [k: string]: unknown; 319 | } 320 | | string; 321 | }; 322 | template?: { 323 | [k: string]: string; 324 | }; 325 | uri?: AwsCfInstruction; 326 | }; 327 | response?: { 328 | contentHandling?: "CONVERT_TO_BINARY" | "CONVERT_TO_TEXT"; 329 | headers?: { 330 | [k: string]: string; 331 | }; 332 | template?: string; 333 | statusCodes?: { 334 | [k: string]: { 335 | headers?: { 336 | [k: string]: string; 337 | }; 338 | pattern?: string; 339 | template?: 340 | | string 341 | | { 342 | [k: string]: string; 343 | }; 344 | }; 345 | }; 346 | }; 347 | timeoutInMillis?: number; 348 | }; 349 | } 350 | | { 351 | websocket: 352 | | string 353 | | { 354 | route: string; 355 | routeResponseSelectionExpression?: "$default"; 356 | authorizer?: 357 | | AwsArnString 358 | | FunctionName 359 | | ( 360 | | { 361 | [k: string]: unknown; 362 | } 363 | | { 364 | [k: string]: unknown; 365 | } 366 | ); 367 | }; 368 | } 369 | | { 370 | sns: 371 | | string 372 | | AwsArnString 373 | | ( 374 | | { 375 | [k: string]: unknown; 376 | } 377 | | { 378 | [k: string]: unknown; 379 | } 380 | ); 381 | } 382 | | { 383 | stream: 384 | | AwsArnString 385 | | ( 386 | | { 387 | arn: AwsCfFunction; 388 | [k: string]: unknown; 389 | } 390 | | { 391 | arn: AwsArnString; 392 | [k: string]: unknown; 393 | } 394 | ); 395 | } 396 | | { 397 | kafka: { 398 | accessConfigurations: { 399 | vpcSubnet?: string[]; 400 | vpcSecurityGroup?: string[]; 401 | saslPlainAuth?: AwsSecretsManagerArnString[]; 402 | saslScram256Auth?: AwsSecretsManagerArnString[]; 403 | saslScram512Auth?: AwsSecretsManagerArnString[]; 404 | clientCertificateTlsAuth?: AwsSecretsManagerArnString[]; 405 | serverRootCaCertificate?: AwsSecretsManagerArnString[]; 406 | }; 407 | batchSize?: number; 408 | maximumBatchingWindow?: number; 409 | enabled?: boolean; 410 | bootstrapServers: string[]; 411 | startingPosition?: "LATEST" | "TRIM_HORIZON" | "AT_TIMESTAMP"; 412 | startingPositionTimestamp?: number; 413 | topic: string; 414 | consumerGroupId?: string; 415 | filterPatterns?: FilterPatterns; 416 | }; 417 | } 418 | | { 419 | activemq: { 420 | arn: string | AwsCfImport | AwsCfRef; 421 | basicAuthArn: AwsSecretsManagerArnString | AwsCfImport | AwsCfRef; 422 | batchSize?: number; 423 | maximumBatchingWindow?: number; 424 | enabled?: boolean; 425 | queue: string; 426 | filterPatterns?: FilterPatterns; 427 | }; 428 | } 429 | | { 430 | rabbitmq: { 431 | arn: string | AwsCfImport | AwsCfRef; 432 | basicAuthArn: AwsSecretsManagerArnString | AwsCfImport | AwsCfRef; 433 | batchSize?: number; 434 | maximumBatchingWindow?: number; 435 | enabled?: boolean; 436 | queue: string; 437 | virtualHost?: string; 438 | filterPatterns?: FilterPatterns; 439 | }; 440 | } 441 | | { 442 | msk: { 443 | arn: AwsArnString | AwsCfImport | AwsCfRef; 444 | batchSize?: number; 445 | maximumBatchingWindow?: number; 446 | enabled?: boolean; 447 | startingPosition?: "LATEST" | "TRIM_HORIZON" | "AT_TIMESTAMP"; 448 | startingPositionTimestamp?: number; 449 | topic: string; 450 | saslScram512?: AwsArnString; 451 | consumerGroupId?: string; 452 | filterPatterns?: FilterPatterns; 453 | }; 454 | } 455 | | { 456 | alb: { 457 | authorizer?: string[]; 458 | conditions: { 459 | header?: 460 | | { 461 | name: string; 462 | values: string[]; 463 | }[] 464 | | { 465 | name: string; 466 | values: string[]; 467 | }; 468 | host?: string[]; 469 | ip?: string[]; 470 | method?: string[]; 471 | path?: string[]; 472 | query?: { 473 | [k: string]: string; 474 | }; 475 | }; 476 | healthCheck?: 477 | | boolean 478 | | { 479 | healthyThresholdCount?: number; 480 | intervalSeconds?: number; 481 | matcher?: { 482 | httpCode?: string; 483 | }; 484 | path?: string; 485 | timeoutSeconds?: number; 486 | unhealthyThresholdCount?: number; 487 | }; 488 | listenerArn: AwsAlbListenerArn | AwsCfRef; 489 | multiValueHeaders?: boolean; 490 | priority: number; 491 | targetGroupName?: string; 492 | }; 493 | } 494 | | { 495 | alexaSkill: 496 | | AwsAlexaEventToken 497 | | { 498 | appId: AwsAlexaEventToken; 499 | enabled?: boolean; 500 | }; 501 | } 502 | | { 503 | alexaSmartHome: 504 | | AwsAlexaEventToken 505 | | { 506 | appId: AwsAlexaEventToken; 507 | enabled?: boolean; 508 | }; 509 | } 510 | | { 511 | iot: { 512 | sql: string; 513 | sqlVersion?: "2015-10-08" | "2016-03-23" | "beta"; 514 | name?: string; 515 | enabled?: boolean; 516 | description?: string; 517 | }; 518 | } 519 | | { 520 | iotFleetProvisioning: { 521 | enabled?: boolean; 522 | provisioningRoleArn: AwsArn; 523 | templateBody: { 524 | [k: string]: unknown; 525 | }; 526 | templateName?: string; 527 | }; 528 | } 529 | | { 530 | cloudwatchEvent: { 531 | event?: { 532 | [k: string]: unknown; 533 | }; 534 | input?: 535 | | string 536 | | { 537 | [k: string]: unknown; 538 | }; 539 | inputPath?: string; 540 | inputTransformer?: { 541 | inputPathsMap?: { 542 | [k: string]: string; 543 | }; 544 | inputTemplate: string; 545 | }; 546 | description?: string; 547 | name?: string; 548 | enabled?: boolean; 549 | }; 550 | } 551 | | { 552 | cloudwatchLog: 553 | | AwsLogGroupName 554 | | { 555 | logGroup: AwsLogGroupName; 556 | filter?: string; 557 | }; 558 | } 559 | | { 560 | cognitoUserPool: { 561 | pool: string; 562 | trigger: 563 | | "PreSignUp" 564 | | "PostConfirmation" 565 | | "PreAuthentication" 566 | | "PostAuthentication" 567 | | "PreTokenGeneration" 568 | | "CustomMessage" 569 | | "DefineAuthChallenge" 570 | | "CreateAuthChallenge" 571 | | "VerifyAuthChallengeResponse" 572 | | "UserMigration" 573 | | "CustomSMSSender" 574 | | "CustomEmailSender"; 575 | existing?: boolean; 576 | forceDeploy?: boolean; 577 | kmsKeyId?: AwsKmsArn; 578 | }; 579 | } 580 | | { 581 | eventBridge: 582 | | { 583 | [k: string]: unknown; 584 | } 585 | | { 586 | [k: string]: unknown; 587 | }; 588 | } 589 | | { 590 | sqs: 591 | | AwsArnString 592 | | { 593 | arn: AwsArn; 594 | batchSize?: number; 595 | enabled?: boolean; 596 | maximumBatchingWindow?: number; 597 | functionResponseType?: "ReportBatchItemFailures"; 598 | filterPatterns?: FilterPatterns; 599 | maximumConcurrency?: number; 600 | }; 601 | } 602 | | { 603 | cloudFront: { 604 | behavior?: { 605 | AllowedMethods?: 606 | | ("GET" | "HEAD")[] 607 | | ("GET" | "HEAD" | "OPTIONS")[] 608 | | ("GET" | "HEAD" | "OPTIONS" | "PUT" | "PATCH" | "POST" | "DELETE")[]; 609 | CachedMethods?: ("GET" | "HEAD")[] | ("GET" | "HEAD" | "OPTIONS")[]; 610 | CachePolicyId?: string; 611 | Compress?: boolean; 612 | FieldLevelEncryptionId?: string; 613 | OriginRequestPolicyId?: string | AwsCfFunction; 614 | ResponseHeadersPolicyId?: string | AwsCfFunction; 615 | SmoothStreaming?: boolean; 616 | TrustedSigners?: string[]; 617 | ViewerProtocolPolicy?: "allow-all" | "redirect-to-https" | "https-only"; 618 | TrustedKeyGroups?: (string | AwsCfRef)[]; 619 | MaxTTL?: number; 620 | MinTTL?: number; 621 | DefaultTTL?: number; 622 | ForwardedValues?: { 623 | Cookies?: 624 | | { 625 | Forward: "all" | "none"; 626 | } 627 | | { 628 | Forward: "whitelist"; 629 | WhitelistedNames: string[]; 630 | }; 631 | Headers?: string[]; 632 | QueryString: boolean; 633 | QueryStringCacheKeys?: string[]; 634 | }; 635 | }; 636 | cachePolicy?: 637 | | { 638 | [k: string]: unknown; 639 | } 640 | | { 641 | [k: string]: unknown; 642 | }; 643 | eventType?: "viewer-request" | "origin-request" | "origin-response" | "viewer-response"; 644 | isDefaultOrigin?: boolean; 645 | includeBody?: boolean; 646 | origin?: 647 | | string 648 | | ( 649 | | { 650 | [k: string]: unknown; 651 | } 652 | | { 653 | [k: string]: unknown; 654 | } 655 | ); 656 | pathPattern?: string; 657 | }; 658 | } 659 | | { 660 | httpApi: 661 | | string 662 | | { 663 | authorizer?: 664 | | string 665 | | ( 666 | | { 667 | [k: string]: unknown; 668 | } 669 | | { 670 | [k: string]: unknown; 671 | } 672 | | { 673 | [k: string]: unknown; 674 | } 675 | ); 676 | method?: string; 677 | path: string; 678 | }; 679 | } 680 | )[]; 681 | architecture?: AwsLambdaArchitecture; 682 | awsKmsKeyArn?: AwsKmsArn; 683 | condition?: AwsResourceCondition; 684 | dependsOn?: AwsResourceDependsOn; 685 | description?: string; 686 | destinations?: { 687 | onSuccess?: 688 | | string 689 | | { 690 | arn: AwsCfFunction; 691 | type: "function" | "sns" | "sqs" | "eventBus"; 692 | }; 693 | onFailure?: 694 | | string 695 | | { 696 | arn: AwsCfFunction; 697 | type: "function" | "sns" | "sqs" | "eventBus"; 698 | }; 699 | }; 700 | disableLogs?: boolean; 701 | environment?: AwsLambdaEnvironment; 702 | ephemeralStorageSize?: number; 703 | fileSystemConfig?: { 704 | arn: string | AwsCfGetAtt | AwsCfJoin | AwsCfImport; 705 | localMountPath: string; 706 | }; 707 | handler?: string; 708 | image?: 709 | | EcrImageUri 710 | | { 711 | name?: string; 712 | uri?: EcrImageUri; 713 | workingDirectory?: string; 714 | command?: string[]; 715 | entryPoint?: string[]; 716 | }; 717 | kmsKeyArn?: AwsKmsArn; 718 | snapStart?: boolean; 719 | layers?: AwsLambdaLayers; 720 | logRetentionInDays?: AwsLogRetentionInDays; 721 | logDataProtectionPolicy?: AwsLogDataProtectionPolicy; 722 | logs?: AwsLambdaLoggingConfiguration; 723 | maximumEventAge?: number; 724 | maximumRetryAttempts?: number; 725 | memorySize?: AwsLambdaMemorySize; 726 | onError?: string | AwsCfFunction; 727 | package?: { 728 | artifact?: string; 729 | exclude?: string[]; 730 | include?: string[]; 731 | individually?: boolean; 732 | patterns?: string[]; 733 | }; 734 | provisionedConcurrency?: 735 | | ( 736 | | number 737 | | { 738 | executions: number; 739 | alias?: string; 740 | } 741 | ) 742 | | AwsCfFunction 743 | | AwsCfIf; 744 | reservedConcurrency?: number | AwsCfFunction | AwsCfIf; 745 | role?: AwsLambdaRole; 746 | runtime?: AwsLambdaRuntime; 747 | build?: string; 748 | runtimeManagement?: AwsLambdaRuntimeManagement; 749 | tags?: AwsResourceTags; 750 | timeout?: AwsLambdaTimeout; 751 | tracing?: AwsLambdaTracing; 752 | url?: 753 | | boolean 754 | | { 755 | authorizer?: "aws_iam"; 756 | cors?: 757 | | boolean 758 | | { 759 | allowCredentials?: boolean; 760 | allowedHeaders?: string[]; 761 | allowedMethods?: string[]; 762 | allowedOrigins?: string[]; 763 | exposedResponseHeaders?: string[]; 764 | maxAge?: number; 765 | }; 766 | invokeMode?: "BUFFERED" | "RESPONSE_STREAM"; 767 | }; 768 | versionFunction?: AwsLambdaVersioning; 769 | vpc?: AwsLambdaVpcConfig; 770 | httpApi?: { 771 | payload?: AwsHttpApiPayload; 772 | }; 773 | alarms?: unknown[]; 774 | }; 775 | }; 776 | licenseKey?: string; 777 | package?: { 778 | artifact?: string; 779 | exclude?: string[]; 780 | excludeDevDependencies?: boolean; 781 | include?: string[]; 782 | individually?: boolean; 783 | path?: string; 784 | patterns?: string[]; 785 | }; 786 | params?: { 787 | /** 788 | * This interface was referenced by `undefined`'s JSON-Schema definition 789 | * via the `patternProperty` "^[a-zA-Z0-9-]+$". 790 | */ 791 | [k: string]: { 792 | [k: string]: unknown; 793 | }; 794 | }; 795 | stages?: { 796 | /** 797 | * This interface was referenced by `undefined`'s JSON-Schema definition 798 | * via the `patternProperty` "^[a-zA-Z0-9-]+$". 799 | */ 800 | [k: string]: { 801 | observability?: 802 | | boolean 803 | | ("axiom" | "dashboard") 804 | | { 805 | provider: "axiom" | "dashboard"; 806 | dataset?: string; 807 | }; 808 | resolvers?: { 809 | [k: string]: unknown; 810 | }; 811 | [k: string]: unknown; 812 | }; 813 | }; 814 | plugins?: 815 | | { 816 | localPath?: string; 817 | modules: string[]; 818 | } 819 | | string[]; 820 | projectDir?: string; 821 | provider: { 822 | name: "aws"; 823 | alb?: { 824 | targetGroupPrefix?: string; 825 | authorizers?: { 826 | [k: string]: 827 | | { 828 | type: "oidc"; 829 | authorizationEndpoint: string; 830 | clientId: string; 831 | clientSecret?: string; 832 | issuer: string; 833 | tokenEndpoint: string; 834 | userInfoEndpoint: string; 835 | onUnauthenticatedRequest?: "allow" | "authenticate" | "deny"; 836 | requestExtraParams?: { 837 | [k: string]: string; 838 | }; 839 | scope?: string; 840 | sessionCookieName?: string; 841 | sessionTimeout?: number; 842 | } 843 | | { 844 | type: "cognito"; 845 | userPoolArn: AwsArn; 846 | userPoolClientId: string; 847 | userPoolDomain: string; 848 | onUnauthenticatedRequest?: "allow" | "authenticate" | "deny"; 849 | requestExtraParams?: { 850 | [k: string]: string; 851 | }; 852 | scope?: string; 853 | sessionCookieName?: string; 854 | sessionTimeout?: number; 855 | }; 856 | }; 857 | }; 858 | apiGateway?: { 859 | apiKeys?: AwsApiGatewayApiKeys; 860 | apiKeySourceType?: string; 861 | binaryMediaTypes?: string[]; 862 | description?: string; 863 | disableDefaultEndpoint?: boolean; 864 | metrics?: boolean; 865 | minimumCompressionSize?: number; 866 | resourcePolicy?: AwsResourcePolicyStatements; 867 | restApiId?: AwsCfInstruction; 868 | restApiResources?: 869 | | { 870 | path?: string; 871 | resourceId?: string; 872 | }[] 873 | | { 874 | [k: string]: unknown; 875 | }; 876 | restApiRootResourceId?: AwsCfInstruction; 877 | request?: { 878 | schemas?: { 879 | [k: string]: { 880 | schema: { 881 | [k: string]: unknown; 882 | }; 883 | name?: string; 884 | description?: string; 885 | }; 886 | }; 887 | }; 888 | shouldStartNameWithService?: boolean; 889 | stage?: string; 890 | timeoutInMillis?: number; 891 | usagePlan?: 892 | | { 893 | quota?: { 894 | limit?: number; 895 | offset?: number; 896 | period?: "DAY" | "WEEK" | "MONTH"; 897 | }; 898 | throttle?: { 899 | burstLimit?: number; 900 | rateLimit?: number; 901 | }; 902 | } 903 | | { 904 | [k: string]: { 905 | quota?: { 906 | limit?: number; 907 | offset?: number; 908 | period?: "DAY" | "WEEK" | "MONTH"; 909 | }; 910 | throttle?: { 911 | burstLimit?: number; 912 | rateLimit?: number; 913 | }; 914 | }; 915 | }[]; 916 | websocketApiId?: AwsCfInstruction; 917 | }; 918 | apiName?: string; 919 | architecture?: AwsLambdaArchitecture; 920 | cfnRole?: AwsArn; 921 | cloudFront?: { 922 | cachePolicies?: { 923 | [k: string]: { 924 | Comment?: string; 925 | DefaultTTL: number; 926 | MaxTTL: number; 927 | MinTTL: number; 928 | ParametersInCacheKeyAndForwardedToOrigin: { 929 | CookiesConfig: { 930 | CookieBehavior: "none" | "whitelist" | "allExcept" | "all"; 931 | Cookies?: string[]; 932 | }; 933 | EnableAcceptEncodingBrotli?: boolean; 934 | EnableAcceptEncodingGzip: boolean; 935 | HeadersConfig: { 936 | HeaderBehavior: "none" | "whitelist"; 937 | Headers?: string[]; 938 | }; 939 | QueryStringsConfig: { 940 | QueryStringBehavior: "none" | "whitelist" | "allExcept" | "all"; 941 | QueryStrings?: string[]; 942 | }; 943 | }; 944 | }; 945 | }; 946 | }; 947 | deploymentBucket?: 948 | | AwsS3BucketName 949 | | { 950 | blockPublicAccess?: boolean; 951 | skipPolicySetup?: boolean; 952 | maxPreviousDeploymentArtifacts?: number; 953 | name?: AwsS3BucketName; 954 | versioning?: boolean; 955 | serverSideEncryption?: "AES256" | "aws:kms"; 956 | sseCustomerAlgorithim?: string; 957 | sseCustomerKey?: string; 958 | sseCustomerKeyMD5?: string; 959 | sseKMSKeyId?: string; 960 | tags?: AwsResourceTags; 961 | }; 962 | deploymentPrefix?: string; 963 | disableRollback?: boolean; 964 | endpointType?: string; 965 | environment?: AwsLambdaEnvironment; 966 | eventBridge?: { 967 | useCloudFormation?: boolean; 968 | }; 969 | httpApi?: { 970 | authorizers?: { 971 | [k: string]: 972 | | { 973 | type?: "jwt"; 974 | name?: string; 975 | identitySource: AwsCfInstruction; 976 | issuerUrl: AwsCfInstruction; 977 | audience: AwsCfInstruction | AwsCfInstruction[]; 978 | } 979 | | { 980 | type: "request"; 981 | name?: string; 982 | functionName?: string; 983 | functionArn?: AwsCfInstruction; 984 | managedExternally?: boolean; 985 | resultTtlInSeconds?: number; 986 | enableSimpleResponses?: boolean; 987 | payloadVersion?: AwsHttpApiPayload; 988 | identitySource?: AwsCfInstruction | AwsCfInstruction[]; 989 | [k: string]: unknown; 990 | }; 991 | }; 992 | cors?: 993 | | boolean 994 | | { 995 | allowCredentials?: boolean; 996 | allowedHeaders?: string[]; 997 | allowedMethods?: string[]; 998 | allowedOrigins?: string[]; 999 | exposedResponseHeaders?: string[]; 1000 | maxAge?: number; 1001 | }; 1002 | id?: string | AwsCfImportLocallyResolvable; 1003 | name?: string; 1004 | payload?: string; 1005 | metrics?: boolean; 1006 | useProviderTags?: true; 1007 | disableDefaultEndpoint?: boolean; 1008 | shouldStartNameWithService?: boolean; 1009 | }; 1010 | iam?: { 1011 | role?: 1012 | | AwsLambdaRole 1013 | | { 1014 | name?: string; 1015 | path?: string; 1016 | managedPolicies?: AwsArn[]; 1017 | statements?: AwsIamPolicyStatements; 1018 | permissionBoundary?: AwsArn; 1019 | permissionsBoundary?: AwsArn; 1020 | tags?: AwsResourceTags; 1021 | }; 1022 | deploymentRole?: AwsArn; 1023 | }; 1024 | iamManagedPolicies?: AwsArn[]; 1025 | iamRoleStatements?: AwsIamPolicyStatements; 1026 | ecr?: { 1027 | scanOnPush?: boolean; 1028 | images: { 1029 | /** 1030 | * This interface was referenced by `undefined`'s JSON-Schema definition 1031 | * via the `patternProperty` "^[a-z][a-z0-9-_]{1,31}$". 1032 | */ 1033 | [k: string]: 1034 | | { 1035 | uri?: EcrImageUri; 1036 | path?: string; 1037 | file?: string; 1038 | buildArgs?: { 1039 | [k: string]: string; 1040 | }; 1041 | buildOptions?: string[]; 1042 | cacheFrom?: string[]; 1043 | platform?: string; 1044 | provenance?: string; 1045 | } 1046 | | string; 1047 | }; 1048 | }; 1049 | kmsKeyArn?: AwsKmsArn; 1050 | lambdaHashingVersion?: "20200924" | "20201221"; 1051 | layers?: AwsLambdaLayers; 1052 | logRetentionInDays?: AwsLogRetentionInDays; 1053 | logDataProtectionPolicy?: AwsLogDataProtectionPolicy; 1054 | logs?: { 1055 | frameworkLambda?: boolean; 1056 | lambda?: AwsLambdaLoggingConfiguration; 1057 | httpApi?: 1058 | | boolean 1059 | | { 1060 | format?: string; 1061 | }; 1062 | restApi?: 1063 | | boolean 1064 | | { 1065 | accessLogging?: boolean; 1066 | executionLogging?: boolean; 1067 | format?: string; 1068 | fullExecutionData?: boolean; 1069 | level?: "INFO" | "ERROR"; 1070 | role?: AwsArn; 1071 | roleManagedExternally?: boolean; 1072 | }; 1073 | websocket?: 1074 | | boolean 1075 | | { 1076 | accessLogging?: boolean; 1077 | executionLogging?: boolean; 1078 | format?: string; 1079 | fullExecutionData?: boolean; 1080 | level?: "INFO" | "ERROR"; 1081 | }; 1082 | [k: string]: unknown; 1083 | }; 1084 | memorySize?: AwsLambdaMemorySize; 1085 | notificationArns?: AwsArnString[]; 1086 | profile?: string; 1087 | region?: 1088 | | "us-east-1" 1089 | | "us-east-2" 1090 | | "us-gov-east-1" 1091 | | "us-gov-west-1" 1092 | | "us-iso-east-1" 1093 | | "us-iso-west-1" 1094 | | "us-isob-east-1" 1095 | | "us-west-1" 1096 | | "us-west-2" 1097 | | "af-south-1" 1098 | | "ap-east-1" 1099 | | "ap-northeast-1" 1100 | | "ap-northeast-2" 1101 | | "ap-northeast-3" 1102 | | "ap-south-1" 1103 | | "ap-south-2" 1104 | | "ap-southeast-1" 1105 | | "ap-southeast-2" 1106 | | "ap-southeast-3" 1107 | | "ap-southeast-4" 1108 | | "ap-southeast-5" 1109 | | "ap-southeast-7" 1110 | | "ca-central-1" 1111 | | "ca-west-1" 1112 | | "cn-north-1" 1113 | | "cn-northwest-1" 1114 | | "eu-central-1" 1115 | | "eu-central-2" 1116 | | "eu-north-1" 1117 | | "eu-south-1" 1118 | | "eu-south-2" 1119 | | "eu-west-1" 1120 | | "eu-west-2" 1121 | | "eu-west-3" 1122 | | "il-central-1" 1123 | | "me-central-1" 1124 | | "me-south-1" 1125 | | "sa-east-1" 1126 | | "mx-central-1"; 1127 | resolver?: string; 1128 | role?: AwsLambdaRole; 1129 | rolePermissionsBoundary?: AwsArnString; 1130 | rollbackConfiguration?: { 1131 | RollbackTriggers?: { 1132 | Arn: AwsArnString; 1133 | Type: "AWS::CloudWatch::Alarm"; 1134 | }[]; 1135 | MonitoringTimeInMinutes?: number; 1136 | }; 1137 | runtime?: AwsLambdaRuntime; 1138 | runtimeManagement?: AwsLambdaRuntimeManagement; 1139 | build?: string; 1140 | deploymentMethod?: "changesets" | "direct"; 1141 | enableLegacyDeploymentBucket?: boolean; 1142 | s3?: { 1143 | [k: string]: { 1144 | accelerateConfiguration?: { 1145 | AccelerationStatus: "Enabled" | "Suspended"; 1146 | }; 1147 | accessControl?: string; 1148 | analyticsConfigurations?: { 1149 | Id: string; 1150 | Prefix?: string; 1151 | StorageClassAnalysis: { 1152 | DataExport?: { 1153 | Destination: { 1154 | BucketAccountId?: string; 1155 | BucketArn: AwsArn; 1156 | Format: "CSV" | "ORC" | "Parquet"; 1157 | Prefix?: string; 1158 | }; 1159 | OutputSchemaVersion: "V_1"; 1160 | }; 1161 | }; 1162 | TagFilters?: { 1163 | Key: string; 1164 | Value: string; 1165 | }[]; 1166 | }[]; 1167 | bucketEncryption?: { 1168 | ServerSideEncryptionConfiguration: { 1169 | ServerSideEncryptionByDefault?: { 1170 | KMSMasterKeyID?: AwsArn | string; 1171 | SSEAlgorithm: "AES256" | "aws:kms"; 1172 | }; 1173 | BucketKeyEnabled?: boolean; 1174 | }[]; 1175 | }; 1176 | bucketName?: AwsS3BucketName; 1177 | corsConfiguration?: { 1178 | CorsRules: { 1179 | AllowedHeaders?: string[]; 1180 | AllowedMethods: ("GET" | "PUT" | "HEAD" | "POST" | "DELETE")[]; 1181 | AllowedOrigins: string[]; 1182 | ExposedHeaders?: string[]; 1183 | Id?: string; 1184 | MaxAge?: number; 1185 | }[]; 1186 | }; 1187 | inventoryConfigurations?: { 1188 | Destination: { 1189 | BucketAccountId?: string; 1190 | BucketArn: AwsArn; 1191 | Format: "CSV" | "ORC" | "Parquet"; 1192 | Prefix?: string; 1193 | }; 1194 | Enabled: boolean; 1195 | Id: string; 1196 | IncludedObjectVersions: "All" | "Current"; 1197 | OptionalFields?: string[]; 1198 | Prefix?: string; 1199 | ScheduleFrequency: "Daily" | "Weekly"; 1200 | }[]; 1201 | lifecycleConfiguration?: { 1202 | Rules: ( 1203 | | { 1204 | [k: string]: unknown; 1205 | } 1206 | | { 1207 | [k: string]: unknown; 1208 | } 1209 | | { 1210 | [k: string]: unknown; 1211 | } 1212 | | { 1213 | [k: string]: unknown; 1214 | } 1215 | | { 1216 | [k: string]: unknown; 1217 | } 1218 | | { 1219 | [k: string]: unknown; 1220 | } 1221 | | { 1222 | [k: string]: unknown; 1223 | } 1224 | | { 1225 | [k: string]: unknown; 1226 | } 1227 | )[]; 1228 | }; 1229 | loggingConfiguration?: { 1230 | DestinationBucketName?: AwsS3BucketName | AwsCfFunction; 1231 | LogFilePrefix?: string; 1232 | }; 1233 | metricsConfigurations?: { 1234 | Id: string; 1235 | Prefix?: string; 1236 | TagFilters?: { 1237 | Key: string; 1238 | Value: string; 1239 | }[]; 1240 | }[]; 1241 | name?: AwsS3BucketName; 1242 | notificationConfiguration?: { 1243 | LambdaConfigurations?: { 1244 | Event: string; 1245 | Filter?: { 1246 | S3Key: { 1247 | Rules: { 1248 | Name: "prefix" | "suffix"; 1249 | Value: string; 1250 | }[]; 1251 | }; 1252 | }; 1253 | Function: AwsArn; 1254 | }[]; 1255 | QueueConfigurations?: { 1256 | Event: string; 1257 | Filter?: { 1258 | S3Key: { 1259 | Rules: { 1260 | Name: "prefix" | "suffix"; 1261 | Value: string; 1262 | }[]; 1263 | }; 1264 | }; 1265 | Queue: AwsArn; 1266 | }[]; 1267 | TopicConfigurations?: { 1268 | Event: string; 1269 | Filter?: { 1270 | S3Key: { 1271 | Rules: { 1272 | Name: "prefix" | "suffix"; 1273 | Value: string; 1274 | }[]; 1275 | }; 1276 | }; 1277 | Topic: AwsArn; 1278 | }[]; 1279 | }; 1280 | objectLockConfiguration?: { 1281 | ObjectLockEnabled?: "Enabled"; 1282 | Rule?: { 1283 | DefaultRetention?: { 1284 | Days?: number; 1285 | Mode?: "COMPLIANCE" | "GOVERNANCE"; 1286 | Years?: number; 1287 | }; 1288 | }; 1289 | }; 1290 | objectLockEnabled?: boolean; 1291 | publicAccessBlockConfiguration?: { 1292 | BlockPublicAcls?: boolean; 1293 | BlockPublicPolicy?: boolean; 1294 | IgnorePublicAcls?: boolean; 1295 | RestrictPublicBuckets?: boolean; 1296 | }; 1297 | replicationConfiguration?: { 1298 | Role: AwsArn; 1299 | Rules: { 1300 | DeleteMarkerReplication?: { 1301 | Status?: "Disabled" | "Enabled"; 1302 | }; 1303 | Destination: { 1304 | AccessControlTranslation?: { 1305 | Owner: "Destination"; 1306 | }; 1307 | Account?: string; 1308 | Bucket: AwsArn; 1309 | EncryptionConfiguration?: { 1310 | ReplicaKmsKeyID: string; 1311 | }; 1312 | Metrics?: { 1313 | EventThreshold: { 1314 | Minutes: number; 1315 | }; 1316 | Status: "Disabled" | "Enabled"; 1317 | }; 1318 | ReplicationTime?: { 1319 | Status: "Disabled" | "Enabled"; 1320 | Time: { 1321 | Minutes: number; 1322 | }; 1323 | }; 1324 | StorageClass?: 1325 | | "DEEP_ARCHIVE" 1326 | | "GLACIER" 1327 | | "INTELLIGENT_TIERING" 1328 | | "ONEZONE_IA" 1329 | | "OUTPOSTS" 1330 | | "REDUCED_REDUNDANCY" 1331 | | "STANDARD" 1332 | | "STANDARD_IA"; 1333 | }; 1334 | Filter?: { 1335 | And?: { 1336 | Prefix?: string; 1337 | TagFilters?: { 1338 | Key: string; 1339 | Value: string; 1340 | }[]; 1341 | }; 1342 | Prefix?: string; 1343 | TagFilter?: { 1344 | Key: string; 1345 | Value: string; 1346 | }; 1347 | }; 1348 | Id?: string; 1349 | Prefix?: string; 1350 | Priority?: number; 1351 | SourceSelectionCriteria?: { 1352 | SseKmsEncryptedObjects: { 1353 | Status: "Disabled" | "Enabled"; 1354 | }; 1355 | }; 1356 | Status: "Disabled" | "Enabled"; 1357 | }[]; 1358 | }; 1359 | tags?: { 1360 | Key: string; 1361 | Value: string; 1362 | }[]; 1363 | versioningConfiguration?: { 1364 | Status: "Enabled" | "Suspended"; 1365 | }; 1366 | websiteConfiguration?: { 1367 | ErrorDocument?: string; 1368 | IndexDocument?: string; 1369 | RedirectAllRequestsTo?: { 1370 | HostName: string; 1371 | Protocol?: "http" | "https"; 1372 | }; 1373 | RoutingRules?: { 1374 | RedirectRule: { 1375 | HostName?: string; 1376 | HttpRedirectCode?: string; 1377 | Protocol?: "http" | "https"; 1378 | ReplaceKeyPrefixWith?: string; 1379 | ReplaceKeyWith?: string; 1380 | }; 1381 | RoutingRuleCondition?: { 1382 | HttpErrorCodeReturnedEquals?: string; 1383 | KeyPrefixEquals?: string; 1384 | }; 1385 | }[]; 1386 | }; 1387 | }; 1388 | }; 1389 | stage?: Stage; 1390 | stackName?: string; 1391 | stackParameters?: { 1392 | ParameterKey?: string; 1393 | ParameterValue?: string; 1394 | UsePreviousValue?: boolean; 1395 | ResolvedValue?: string; 1396 | }[]; 1397 | stackPolicy?: AwsIamPolicyStatements; 1398 | stackTags?: AwsResourceTags; 1399 | tags?: AwsResourceTags; 1400 | timeout?: AwsLambdaTimeout; 1401 | tracing?: { 1402 | apiGateway?: boolean; 1403 | lambda?: AwsLambdaTracing; 1404 | }; 1405 | vpc?: AwsLambdaVpcConfig; 1406 | vpcEndpointIds?: AwsCfArrayInstruction; 1407 | versionFunctions?: AwsLambdaVersioning; 1408 | websocket?: { 1409 | useProviderTags?: boolean; 1410 | }; 1411 | websocketsApiName?: string; 1412 | kinesis?: { 1413 | consumerNamingMode?: "serviceSpecific"; 1414 | }; 1415 | websocketsApiRouteSelectionExpression?: string; 1416 | websocketsDescription?: string; 1417 | }; 1418 | service: ServiceName; 1419 | state?: 1420 | | { 1421 | resolver: string; 1422 | } 1423 | | string; 1424 | useDotenv?: true; 1425 | variablesResolutionMode?: "20210219" | "20210326"; 1426 | resources?: { 1427 | AWSTemplateFormatVersion?: string; 1428 | Conditions?: { 1429 | [k: string]: unknown; 1430 | }; 1431 | Description?: string; 1432 | Mappings?: { 1433 | [k: string]: unknown; 1434 | }; 1435 | Metadata?: { 1436 | [k: string]: unknown; 1437 | }; 1438 | Outputs?: { 1439 | [k: string]: unknown; 1440 | }; 1441 | Parameters?: { 1442 | [k: string]: unknown; 1443 | }; 1444 | Resources?: { 1445 | "Fn::Transform"?: { 1446 | Name: string; 1447 | Parameters?: { 1448 | [k: string]: unknown; 1449 | }; 1450 | }; 1451 | /** 1452 | * This interface was referenced by `undefined`'s JSON-Schema definition 1453 | * via the `patternProperty` "^[a-zA-Z0-9]{1,255}$". 1454 | */ 1455 | [k: string]: { 1456 | Type: string; 1457 | Properties?: { 1458 | [k: string]: unknown; 1459 | }; 1460 | CreationPolicy?: { 1461 | [k: string]: unknown; 1462 | }; 1463 | DeletionPolicy?: string; 1464 | DependsOn?: AwsResourceDependsOn; 1465 | Metadata?: { 1466 | [k: string]: unknown; 1467 | }; 1468 | UpdatePolicy?: { 1469 | [k: string]: unknown; 1470 | }; 1471 | UpdateReplacePolicy?: string; 1472 | Condition?: AwsResourceCondition; 1473 | }; 1474 | }; 1475 | Transform?: string[]; 1476 | extensions?: { 1477 | /** 1478 | * This interface was referenced by `undefined`'s JSON-Schema definition 1479 | * via the `patternProperty` "^[a-zA-Z0-9]{1,255}$". 1480 | */ 1481 | [k: string]: { 1482 | Properties?: { 1483 | [k: string]: unknown; 1484 | }; 1485 | CreationPolicy?: { 1486 | [k: string]: unknown; 1487 | }; 1488 | DeletionPolicy?: string; 1489 | DependsOn?: AwsResourceDependsOn; 1490 | Metadata?: { 1491 | [k: string]: unknown; 1492 | }; 1493 | UpdatePolicy?: { 1494 | [k: string]: unknown; 1495 | }; 1496 | UpdateReplacePolicy?: string; 1497 | Condition?: AwsResourceCondition; 1498 | }; 1499 | }; 1500 | }; 1501 | layers?: { 1502 | [k: string]: { 1503 | allowedAccounts?: string[]; 1504 | compatibleArchitectures?: AwsLambdaArchitecture[]; 1505 | compatibleRuntimes?: AwsLambdaRuntime[]; 1506 | description?: string; 1507 | licenseInfo?: string; 1508 | name?: string; 1509 | package?: { 1510 | artifact?: string; 1511 | exclude?: string[]; 1512 | include?: string[]; 1513 | patterns?: string[]; 1514 | }; 1515 | path?: string; 1516 | retain?: boolean; 1517 | }; 1518 | }; 1519 | } 1520 | export interface AwsCfImport { 1521 | "Fn::ImportValue": unknown; 1522 | } 1523 | export interface AwsCfJoin { 1524 | "Fn::Join": [string, unknown[]]; 1525 | } 1526 | export interface AwsCfGetAtt { 1527 | "Fn::GetAtt": string[]; 1528 | } 1529 | export interface AwsCfRef { 1530 | Ref: string; 1531 | } 1532 | export interface AwsCfSub { 1533 | "Fn::Sub": unknown; 1534 | } 1535 | export interface AwsCfBase64 { 1536 | "Fn::Base64"?: unknown; 1537 | [k: string]: unknown; 1538 | } 1539 | export interface AwsCfToJsonString { 1540 | "Fn::ToJsonString": 1541 | | { 1542 | [k: string]: unknown; 1543 | } 1544 | | unknown[]; 1545 | } 1546 | export interface AwsCfIf { 1547 | "Fn::If": AwsCfInstruction[]; 1548 | } 1549 | export interface AwsLambdaEnvironment { 1550 | /** 1551 | * This interface was referenced by `AwsLambdaEnvironment`'s JSON-Schema definition 1552 | * via the `patternProperty` "^[A-Za-z_][a-zA-Z0-9_]*$". 1553 | */ 1554 | [k: string]: "" | AwsCfInstruction | AwsCfIf | AwsCfSelect; 1555 | } 1556 | export interface AwsCfSelect { 1557 | "Fn::Select": ( 1558 | | number 1559 | | string 1560 | | unknown[] 1561 | | AwsCfFindInMap 1562 | | AwsCfGetAtt 1563 | | AwsCfGetAZs 1564 | | AwsCfIf 1565 | | AwsCfSplit 1566 | | AwsCfRef 1567 | )[]; 1568 | } 1569 | export interface AwsCfFindInMap { 1570 | "Fn::FindInMap": (string | AwsCfFunction)[]; 1571 | } 1572 | export interface AwsCfGetAZs { 1573 | "Fn::GetAZs": string | AwsCfRef; 1574 | } 1575 | export interface AwsCfSplit { 1576 | "Fn::Split": (string | AwsCfFunction)[]; 1577 | } 1578 | export interface AwsLogDataProtectionPolicy { 1579 | Name: string; 1580 | Description?: string; 1581 | Version: string; 1582 | Statement: unknown[]; 1583 | } 1584 | export interface AwsLambdaLoggingConfiguration { 1585 | applicationLogLevel?: "DEBUG" | "ERROR" | "FATAL" | "INFO" | "TRACE" | "WARN"; 1586 | logFormat?: "JSON" | "Text"; 1587 | logGroup?: string; 1588 | systemLogLevel?: "DEBUG" | "INFO" | "WARN"; 1589 | } 1590 | export interface AwsResourceTags { 1591 | /** 1592 | * This interface was referenced by `AwsResourceTags`'s JSON-Schema definition 1593 | * via the `patternProperty` "^(?!aws:)[\w./=+:\-_\x20]{1,128}$". 1594 | */ 1595 | [k: string]: string; 1596 | } 1597 | export interface AwsLambdaVpcConfig { 1598 | securityGroupIds: (AwsCfInstruction | AwsCfIf)[] | AwsCfSplit | AwsCfFindInMap; 1599 | subnetIds: (AwsCfInstruction | AwsCfIf)[] | AwsCfSplit | AwsCfFindInMap; 1600 | } 1601 | export interface AwsApiGatewayApiKeysProperties { 1602 | name?: string; 1603 | value?: string; 1604 | description?: string; 1605 | customerId?: string; 1606 | enabled?: boolean; 1607 | } 1608 | export interface AwsCfImportLocallyResolvable { 1609 | "Fn::ImportValue": string; 1610 | } 1611 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@serverless/typescript", 3 | "version": "4.15.1", 4 | "description": "Serverless typescript definitions", 5 | "main": "index.d.ts", 6 | "scripts": { 7 | "build": "tsc", 8 | "lint:fix": "eslint src --fix", 9 | "watch": "tsc -w", 10 | "test:lint": "eslint src", 11 | "test:type": "tsc --noEmit" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/serverless/typescript.git" 16 | }, 17 | "keywords": [ 18 | "serverless", 19 | "sls", 20 | "typescript" 21 | ], 22 | "author": "Frédéric Barthelet", 23 | "license": "ISC", 24 | "bugs": { 25 | "url": "https://github.com/serverless/typescript/issues" 26 | }, 27 | "homepage": "https://github.com/serverless/typescript#readme", 28 | "devDependencies": { 29 | "@types/json-schema": "^7.0.6", 30 | "@typescript-eslint/eslint-plugin": "^4.10.0", 31 | "@typescript-eslint/parser": "^4.10.0", 32 | "ajv": "^7.0.3", 33 | "eslint": "^7.16.0", 34 | "eslint-config-prettier": "^7.1.0", 35 | "eslint-plugin-import": "^2.22.1", 36 | "eslint-plugin-prettier": "^3.3.0", 37 | "json-schema-to-typescript": "^10.1.3", 38 | "lodash": "^4.17.21", 39 | "prettier": "^2.2.1", 40 | "serverless": "*", 41 | "typescript": "^4.0.5" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /serverless.yml: -------------------------------------------------------------------------------- 1 | service: ConfigSchemaHandlerTypescriptDefinitions 2 | 3 | provider: 4 | name: aws 5 | 6 | plugins: 7 | - ./dist/plugin 8 | -------------------------------------------------------------------------------- /src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { compile } from "json-schema-to-typescript"; 2 | import fs from "fs"; 3 | import type { JSONSchema4 } from "json-schema"; 4 | import * as _ from "lodash"; 5 | 6 | interface Serverless { 7 | configSchemaHandler: { 8 | schema: JSONSchema4; 9 | }; 10 | } 11 | 12 | class ConfigSchemaHandlerTypescriptDefinitionsPlugin { 13 | private serverless: Serverless; 14 | 15 | constructor(serverless: Serverless) { 16 | this.serverless = serverless; 17 | } 18 | 19 | commands = { 20 | schema: { 21 | usage: "Get JSON schema definition and generate TS definitions", 22 | lifecycleEvents: ["generate"], 23 | }, 24 | }; 25 | 26 | hooks = { 27 | "schema:generate": this.generateSchema.bind(this), 28 | }; 29 | 30 | async generateSchema() { 31 | const schema = _.cloneDeep(this.serverless.configSchemaHandler.schema); 32 | /** 33 | * ignoreMinAndMaxItems: true -> maxItems: 100 in provider.s3.corsConfiguration definition is generating 100 tuples 34 | */ 35 | const compiledDefinitions = await compile(schema, "AWS", { 36 | ignoreMinAndMaxItems: true, 37 | }); 38 | fs.writeFileSync("index.d.ts", compiledDefinitions); 39 | } 40 | } 41 | 42 | module.exports = ConfigSchemaHandlerTypescriptDefinitionsPlugin; 43 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": false, 4 | "esModuleInterop": true, 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "noFallthroughCasesInSwitch": true, 8 | "noUnusedLocals": true, 9 | "noUnusedParameters": true, 10 | "outDir": "dist", 11 | "preserveConstEnums": true, 12 | "strict": true, 13 | "skipLibCheck": true, 14 | "target": "ESNext" 15 | }, 16 | "include": ["src"], 17 | } 18 | --------------------------------------------------------------------------------