diff --git a/lib/plugins/aws/package/compile/events/stream/index.js b/lib/plugins/aws/package/compile/events/stream/index.js index a51a1628afec..91850f153b7b 100644 --- a/lib/plugins/aws/package/compile/events/stream/index.js +++ b/lib/plugins/aws/package/compile/events/stream/index.js @@ -17,7 +17,7 @@ class AwsCompileStreamEvents { { type: 'object', properties: { - arn: { $ref: '#/definitions/awsArn' }, + arn: { $ref: '#/definitions/awsArnString' }, type: { enum: ['dynamodb', 'kinesis'] }, batchSize: { type: 'integer', minimum: 1, maximum: 10000 }, parallelizationFactor: { type: 'integer', minimum: 1, maximum: 10 }, @@ -67,6 +67,59 @@ class AwsCompileStreamEvents { additionalProperties: false, required: ['arn'], }, + { + type: 'object', + properties: { + arn: { $ref: '#/definitions/awsCfFunction' }, + type: { enum: ['dynamodb', 'kinesis'] }, + batchSize: { type: 'integer', minimum: 1, maximum: 10000 }, + parallelizationFactor: { type: 'integer', minimum: 1, maximum: 10 }, + startingPosition: { enum: ['LATEST', 'TRIM_HORIZON'] }, + enabled: { type: 'boolean' }, + consumer: { oneOf: [{ const: true }, { $ref: '#/definitions/awsArn' }] }, + batchWindow: { type: 'integer', minimum: 0, maximum: 300 }, + maximumRetryAttempts: { type: 'integer', minimum: -1, maximum: 10000 }, + bisectBatchOnFunctionError: { type: 'boolean' }, + maximumRecordAgeInSeconds: { + oneOf: [ + { type: 'integer', minimum: -1, maximum: -1 }, + { type: 'integer', minimum: 60, maximum: 604800 }, + ], + }, + destinations: { + type: 'object', + properties: { + onFailure: { + anyOf: [ + { $ref: '#/definitions/awsArnString' }, + { + type: 'object', + properties: { + arn: { $ref: '#/definitions/awsArnString' }, + type: { enum: ['sns', 'sqs'] }, + }, + additionalProperties: false, + required: ['arn'], + }, + { + type: 'object', + properties: { + arn: { $ref: '#/definitions/awsCfFunction' }, + type: { enum: ['sns', 'sqs'] }, + }, + additionalProperties: false, + required: ['arn', 'type'], + }, + ], + }, + }, + additionalProperties: false, + required: ['onFailure'], + }, + }, + additionalProperties: false, + required: ['arn', 'type'], + }, ], }); } @@ -131,18 +184,6 @@ class AwsCompileStreamEvents { let Enabled = true; if (typeof event.stream === 'object') { - if (typeof event.stream.arn !== 'string') { - // for dynamic arns (GetAtt/ImportValue) - if (!event.stream.type) { - const errorMessage = [ - `Missing "type" property for stream event in function "${functionName}"`, - ' If the "arn" property on a stream is a complex type (such as Fn::GetAtt)', - ' then a "type" must be provided for the stream, either "kinesis" or,', - ' "dynamodb". Please check the docs for more info.', - ].join(''); - throw new this.serverless.classes.Error(errorMessage); - } - } EventSourceArn = event.stream.arn; BatchSize = event.stream.batchSize || BatchSize; if (event.stream.parallelizationFactor) {