diff --git a/lib/plugins/aws/package/compile/events/stream/index.js b/lib/plugins/aws/package/compile/events/stream/index.js index 66290cc5455a..a51a1628afec 100644 --- a/lib/plugins/aws/package/compile/events/stream/index.js +++ b/lib/plugins/aws/package/compile/events/stream/index.js @@ -37,17 +37,26 @@ class AwsCompileStreamEvents { type: 'object', properties: { onFailure: { - oneOf: [ + anyOf: [ { $ref: '#/definitions/awsArnString' }, { type: 'object', properties: { - arn: { $ref: '#/definitions/awsArn' }, + 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'], + }, ], }, }, @@ -220,18 +229,6 @@ class AwsCompileStreamEvents { let OnFailureDestinationArn; if (typeof event.stream.destinations.onFailure === 'object') { - if ( - typeof event.stream.destinations.onFailure.arn !== 'string' && - !event.stream.destinations.onFailure.type - ) { - const errorMessage = [ - `Missing "type" property for on failure destination in function "${functionName}"`, - ' If the "arn" property on a destination is a complex type (such as Fn::GetAtt)', - ' then a "type" must be provided for the destination, either "sns" or,', - ' "sqs". Please check the docs for more info.', - ].join(''); - throw new this.serverless.classes.Error(errorMessage); - } OnFailureDestinationArn = event.stream.destinations.onFailure.arn; } else { OnFailureDestinationArn = event.stream.destinations.onFailure;