From 44ba0c4e555cbd44aaa1985afc1fefba594c4350 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 8 Mar 2021 00:59:01 +1300 Subject: [PATCH] fix(serverless): update config properties (#51130) --- .../plugins/aws/provider/awsProvider.d.ts | 50 +++++++++++++++---- types/serverless/serverless-tests.ts | 37 ++++++++++++-- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/types/serverless/plugins/aws/provider/awsProvider.d.ts b/types/serverless/plugins/aws/provider/awsProvider.d.ts index 3e9fe56e3ed79c..638a8fdf10c934 100644 --- a/types/serverless/plugins/aws/provider/awsProvider.d.ts +++ b/types/serverless/plugins/aws/provider/awsProvider.d.ts @@ -6,8 +6,12 @@ declare namespace Aws { */ interface Serverless { service: Service | string; - frameworkVersion: string; - configValidationMode?: string; + useDotenv?: boolean; + frameworkVersion?: string; + enableLocalInstallationFallback?: boolean; + unresolvedVariablesNotificationMode?: 'warn' | 'error'; + disabledDeprecations?: string[]; + configValidationMode?: 'warn' | 'error' | 'off'; provider: Provider; package?: Package; functions?: Functions; @@ -22,6 +26,7 @@ declare namespace Aws { interface Service { name: string; + /** @deprecated in favor of `kmsKeyArn` at the provider level */ awsKmsKeyArn?: string; } @@ -32,6 +37,7 @@ declare namespace Aws { region?: string; stackName?: string; apiName?: string; + lambdaHashingVersion?: number; websocketsApiName?: string; websocketsApiRouteSelectionExpression?: string; profile?: string; @@ -41,9 +47,17 @@ declare namespace Aws { logRetentionInDays?: number | string; deploymentBucket?: DeploymentBucket; deploymentPrefix?: string; + /** @deprecated in favor of `iam.role` */ role?: string; + /** @deprecated in favor of `iam.permissionsBoundary` */ rolePermissionsBoundary?: string; + /** @deprecated in favor of `iam.statements` */ + iamRoleStatements?: IamRoleStatement[]; + /** @deprecated in favor of `iam.managedPolicies` */ + iamManagedPolicies?: string[]; + /** @deprecated in favor of `iam.deploymentRole` */ cfnRole?: string; + iam?: IamSettings; versionFunctions?: boolean; environment?: Environment | string; endpointType?: 'regional' | 'edge' | 'private'; @@ -53,8 +67,6 @@ declare namespace Aws { httpApi?: HttpApi; usagePlan?: UsagePlan; stackTags?: Tags; - iamManagedPolicies?: string[]; - iamRoleStatements?: IamRoleStatement[]; stackPolicy?: ResourcePolicy[]; vpc?: string | Vpc; notificationArns?: string[]; @@ -64,6 +76,15 @@ declare namespace Aws { tags?: Tags; tracing?: Tracing; logs?: Logs; + kmsKeyArn?: string; + } + + interface IamSettings { + role?: string; + permissionBoundary?: string; + statements?: IamRoleStatement[]; + managedPolicies?: string[]; + deploymentRole?: string; } interface Tags { @@ -93,7 +114,7 @@ declare namespace Aws { [key: string]: string; }; websocketApiId?: any; - apiKeySourceType?: string; + apiKeySourceType?: 'HEADER' | 'AUTHORIZER' | 'header' | 'authorizer'; minimumCompressionSize?: number | string; description?: string; binaryMediaTypes?: string[]; @@ -218,21 +239,21 @@ declare namespace Aws { interface Tracing { apiGateway: boolean; - lambda?: boolean; + lambda?: 'Active' | 'PassThrough' | boolean; } interface RestApiLogs { accessLogging?: boolean; format?: string; executionLogging?: boolean; - level?: string; + level?: 'INFO' | 'ERROR'; fullExecutionData?: boolean; role?: string; roleManagedExternally?: boolean; } interface WebsocketLogs { - level?: string; + level?: 'INFO' | 'ERROR'; } interface HttpApiLogs { @@ -293,7 +314,7 @@ declare namespace Aws { cors?: boolean | HttpCors; private?: boolean; async?: boolean; - authorizer?: HttpAuthorizer; + authorizer?: HttpAuthorizer | string; request?: HttpRequestValidation; integration?: 'lambda' | 'mock'; } @@ -512,6 +533,11 @@ declare namespace Aws { cloudFront?: CloudFront; } + interface FileSystemConfig { + arn: string; + localMountPath: string; + } + interface AwsFunction { name?: string; description?: string; @@ -522,17 +548,21 @@ declare namespace Aws { timeout?: number | string; role?: string; onError?: string; + /** @deprecated in favor of `kmsKeyArn` */ awsKmsKeyArn?: string; + kmsKeyArn?: string; environment?: Environment; tags?: Tags; vpc?: string | Vpc; package?: Package; layers?: Array>; - tracing?: string; + tracing?: 'Active' | 'PassThrough' | boolean; condition?: string; dependsOn?: string[]; + fileSystemConfig?: FileSystemConfig; destinations?: Destinations; events?: Event[]; + disableLogs?: boolean; } interface AwsFunctionHandler extends AwsFunction { diff --git a/types/serverless/serverless-tests.ts b/types/serverless/serverless-tests.ts index c1ca16ea8082a4..adfc673c87e708 100644 --- a/types/serverless/serverless-tests.ts +++ b/types/serverless/serverless-tests.ts @@ -166,7 +166,7 @@ const awsServerless: Aws.Serverless = { testrestapiresource: 'testrestapiresource' }, websocketApiId: 'testwebsocketApiId', - apiKeySourceType: 'testapiKeySourceType', + apiKeySourceType: 'HEADER', minimumCompressionSize: 1, description: 'testdescription', binaryMediaTypes: ['testbinaryMediaTypes'] @@ -308,13 +308,13 @@ const awsServerless: Aws.Serverless = { accessLogging: false, format: 'testformat', executionLogging: false, - level: 'testlevel', + level: 'ERROR', fullExecutionData: false, role: 'testrole', roleManagedExternally: false, }, websocket: { - level: 'testlevel' + level: 'INFO' }, httpApi: { format: 'testformat' @@ -363,7 +363,7 @@ const awsServerless: Aws.Serverless = { individually: true }, layers: ['testlayers'], - tracing: 'testtracing', + tracing: 'PassThrough', condition: 'testcondition', dependsOn: ['testdependson'], destinations: { @@ -644,6 +644,35 @@ const awsServerless: Aws.Serverless = { awsServerless.provider.vpc = 'serverless reference'; awsServerless.functions![0].vpc = 'serverless reference'; +const bunchOfConfigs: Aws.Serverless[] = [ + { + service: 'users', + provider: { name: 'aws' }, + functions: {} + }, + { + service: 'users', + useDotenv: true, + provider: { name: 'aws' }, + functions: {} + }, + { + service: 'users', + configValidationMode: 'off', + unresolvedVariablesNotificationMode: 'error', + provider: { name: 'aws' }, + functions: {} + }, + { + service: 'users', + disabledDeprecations: [ + '*' + ], + provider: { name: 'aws' }, + functions: {} + } +]; + // Test Aws Class const aws = new Aws(serverless, options);