/
schema.js
64 lines (58 loc) · 1.24 KB
/
schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const Joi = require("@hapi/joi");
const arn = Joi.alternatives().try(
Joi.string().regex(/^arn:aws/, "ARN"),
Joi.object().keys({
Ref: Joi.string()
}),
Joi.object().keys({
"Fn::GetAtt": Joi.array().items(Joi.string())
}),
Joi.object().keys({
"Fn::ImportValue": Joi.alternatives().try(Joi.string(), Joi.object())
}),
Joi.object().keys({
"Fn::Sub": Joi.alternatives().try(Joi.string(), Joi.array().length(2))
})
);
const sns = Joi.alternatives().try(
arn,
Joi.object({
logicalId: Joi.string(),
displayName: Joi.string().required(),
topicName: Joi.string()
})
);
const sqsQueue = Joi.object({
logicalId: Joi.string(),
queueName: Joi.string().required(),
delaySeconds: Joi.number()
.min(0)
.max(900),
visibilityTimeout: Joi.number()
.min(0)
.max(43200),
maximumMessageSize: Joi.number()
.min(1024)
.max(262144),
messageRetentionPeriod: Joi.number()
.min(60)
.max(1209600)
});
const sqs = Joi.alternatives().try(
arn,
sqsQueue.keys({
dlq: sqsQueue.keys({
maxReceiveCount: Joi.number().min(1)
})
})
);
const schema = Joi.object({
sns: sns.required(),
rawMessageDelivery: Joi.bool(),
filterPolicy: Joi.object(),
sqs: sqs.required(),
batchSize: Joi.number()
.min(1)
.max(10)
});
module.exports = schema;