Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable intrinsic function for configs #640

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-appsync-plugin",
"version": "0.0.0-development",
"version": "0.0.1",
"description": "AWS AppSync support for the Serverless Framework",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/validation/__snapshots__/auth.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`Valdiation Invalid should validate a Lambda with empty config 1`] = `"/
exports[`Valdiation Invalid should validate a Lambda with invalid config functionnArn 1`] = `
"/authentication/config/functionArn: must be a string or a CloudFormation intrinsic function
/authentication/config: must specify functionName, functionArn or function (all exclusives)
/authentication/config/functionArn: must be string
/authentication/config/functionArn: must be a string or a CloudFormation intrinsic function
/authentication/config/identityValidationExpression: must be string
/authentication/config/authorizerResultTtlInSeconds: must be number"
`;
Expand All @@ -35,7 +35,7 @@ exports[`Valdiation Invalid should validate a Lambda with missing config 1`] = `
exports[`Valdiation Invalid should validate a OIDC with empty config 1`] = `"/authentication/config: must have required property 'issuer'"`;

exports[`Valdiation Invalid should validate a OIDC with invalid config 1`] = `
"/authentication/config/issuer: must be string
"/authentication/config/issuer: must be a string or a CloudFormation intrinsic function
/authentication/config/clientId: must be string
/authentication/config/iatTTL: must be number
/authentication/config/authTTL: must be number"
Expand Down
7 changes: 2 additions & 5 deletions src/__tests__/validation/__snapshots__/base.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ exports[`Valdiation Domain Invalid should validate a useCloudFormation: true, ce

exports[`Valdiation Log Invalid should validate a Invalid 1`] = `
"/logging/level: must be one of 'ALL', 'ERROR' or 'NONE'
/logging/retentionInDays: must be integer
/logging/excludeVerboseContent: must be boolean"
/logging/retentionInDays: must be integer"
`;

exports[`Valdiation Waf Invalid should validate a Invalid 1`] = `
"/waf/name: must be string
/waf/defaultAction: must be 'Allow' or 'Block'
/waf/rules/0: must be a valid WAF rule
/waf/rules/1: must be a valid WAF rule
/waf/rules/2: must be a valid WAF rule
/waf/enabled: must be boolean"
/waf/rules/2: must be a valid WAF rule"
`;

exports[`Valdiation Waf Invalid should validate a Invalid arn 1`] = `"/waf/arn: must be a string or a CloudFormation intrinsic function"`;
Expand All @@ -55,7 +53,6 @@ exports[`Valdiation should validate 1`] = `
": must have required property 'name'
: must have required property 'authentication'
/unknownPorp: invalid (unknown) property
/xrayEnabled: must be boolean
/visibility: must be \\"GLOBAL\\" or \\"PRIVATE\\"
/introspection: must be boolean
/queryDepthLimit: must be integer
Expand Down
29 changes: 24 additions & 5 deletions src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const appSyncSchema = {
// Note: functionName and functionArn are already defined in #/definitions/lambdaFunctionConfig
// But if not also defined here, TypeScript shows an error.
functionName: { type: 'string' },
functionArn: { type: 'string' },
functionArn: { $ref: '#/definitions/stringOrIntrinsicFunction' },
identityValidationExpression: { type: 'string' },
authorizerResultTtlInSeconds: { type: 'number' },
},
Expand All @@ -128,7 +128,7 @@ export const appSyncSchema = {
oidcAuth: {
type: 'object',
properties: {
issuer: { type: 'string' },
issuer: { $ref: '#/definitions/stringOrIntrinsicFunction' },
clientId: { type: 'string' },
iatTTL: { type: 'number' },
authTTL: { type: 'number' },
Expand Down Expand Up @@ -630,6 +630,9 @@ export const appSyncSchema = {
},
required: ['eventBusArn'],
},
xrayEnabledConfig: {
$ref: '#/definitions/lambdaFunctionConfig',
},
},
properties: {
name: { type: 'string' },
Expand Down Expand Up @@ -685,7 +688,13 @@ export const appSyncSchema = {
'when using CloudFormation, you must provide either certificateArn or hostedZoneId.',
},
},
xrayEnabled: { type: 'boolean' },
xrayEnabled: {
oneOf: [
{ type: 'boolean' },
{ $ref: '#/definitions/stringOrIntrinsicFunction' },
],
errorMessage: 'must be a boolean or a CloudFormation intrinsic function',
},
visibility: {
type: 'string',
enum: ['GLOBAL', 'PRIVATE'],
Expand All @@ -699,7 +708,12 @@ export const appSyncSchema = {
waf: {
type: 'object',
properties: {
enabled: { type: 'boolean' },
enabled: {
oneOf: [
{ type: 'boolean' },
{ $ref: '#/definitions/stringOrIntrinsicFunction' },
],
},
},
if: {
required: ['arn'],
Expand Down Expand Up @@ -805,7 +819,12 @@ export const appSyncSchema = {
errorMessage: "must be one of 'ALL', 'ERROR' or 'NONE'",
},
retentionInDays: { type: 'integer' },
excludeVerboseContent: { type: 'boolean' },
excludeVerboseContent: {
oneOf: [
{ type: 'boolean' },
{ $ref: '#/definitions/stringOrIntrinsicFunction' },
],
},
enabled: { type: 'boolean' },
},
required: ['level'],
Expand Down