Skip to content

Commit

Permalink
fix(serverless): update config properties (#51130)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Mar 7, 2021
1 parent d340df8 commit 44ba0c4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 14 deletions.
50 changes: 40 additions & 10 deletions types/serverless/plugins/aws/provider/awsProvider.d.ts
Expand Up @@ -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;
Expand All @@ -22,6 +26,7 @@ declare namespace Aws {

interface Service {
name: string;
/** @deprecated in favor of `kmsKeyArn` at the provider level */
awsKmsKeyArn?: string;
}

Expand All @@ -32,6 +37,7 @@ declare namespace Aws {
region?: string;
stackName?: string;
apiName?: string;
lambdaHashingVersion?: number;
websocketsApiName?: string;
websocketsApiRouteSelectionExpression?: string;
profile?: string;
Expand All @@ -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';
Expand All @@ -53,8 +67,6 @@ declare namespace Aws {
httpApi?: HttpApi;
usagePlan?: UsagePlan;
stackTags?: Tags;
iamManagedPolicies?: string[];
iamRoleStatements?: IamRoleStatement[];
stackPolicy?: ResourcePolicy[];
vpc?: string | Vpc;
notificationArns?: string[];
Expand All @@ -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 {
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -293,7 +314,7 @@ declare namespace Aws {
cors?: boolean | HttpCors;
private?: boolean;
async?: boolean;
authorizer?: HttpAuthorizer;
authorizer?: HttpAuthorizer | string;
request?: HttpRequestValidation;
integration?: 'lambda' | 'mock';
}
Expand Down Expand Up @@ -512,6 +533,11 @@ declare namespace Aws {
cloudFront?: CloudFront;
}

interface FileSystemConfig {
arn: string;
localMountPath: string;
}

interface AwsFunction {
name?: string;
description?: string;
Expand All @@ -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<string | Record<string, string>>;
tracing?: string;
tracing?: 'Active' | 'PassThrough' | boolean;
condition?: string;
dependsOn?: string[];
fileSystemConfig?: FileSystemConfig;
destinations?: Destinations;
events?: Event[];
disableLogs?: boolean;
}

interface AwsFunctionHandler extends AwsFunction {
Expand Down
37 changes: 33 additions & 4 deletions types/serverless/serverless-tests.ts
Expand Up @@ -166,7 +166,7 @@ const awsServerless: Aws.Serverless = {
testrestapiresource: 'testrestapiresource'
},
websocketApiId: 'testwebsocketApiId',
apiKeySourceType: 'testapiKeySourceType',
apiKeySourceType: 'HEADER',
minimumCompressionSize: 1,
description: 'testdescription',
binaryMediaTypes: ['testbinaryMediaTypes']
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -363,7 +363,7 @@ const awsServerless: Aws.Serverless = {
individually: true
},
layers: ['testlayers'],
tracing: 'testtracing',
tracing: 'PassThrough',
condition: 'testcondition',
dependsOn: ['testdependson'],
destinations: {
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 44ba0c4

Please sign in to comment.