-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathuntagResource.js
40 lines (34 loc) · 1.14 KB
/
untagResource.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
exports.types = {
ResourceArn: {
type: 'String',
},
TagKeys: {
type: 'List',
children: 'String',
},
}
exports.custom = function (data, store) {
if (data.ResourceArn == null) {
return 'Invalid TableArn'
}
if (!/^.+:.+:.+:.+:.+:.+\/.+$/.test(data.ResourceArn)) {
var username = 'dynalite'
var accessDeniedError = new Error
accessDeniedError.statusCode = 400
accessDeniedError.body = {
__type: 'com.amazon.coral.service#AccessDeniedException',
Message: 'User: arn:aws:iam::' + store.tableDb.awsAccountId + ':' + username + ' is not authorized to perform: ' +
'dynamodb:UntagResource on resource: ' + (data.ResourceArn || '*'),
}
throw accessDeniedError
}
if (data.TagKeys == null) {
return '1 validation error detected: Value null at \'tagKeys\' failed to satisfy constraint: Member must not be null'
}
if (!/^arn:aws:dynamodb:.+:\d+:table\/[^/]{2}[^/]+$/.test(data.ResourceArn)) {
return 'Invalid TableArn: Invalid ResourceArn provided as input ' + data.ResourceArn
}
if (!data.TagKeys.length) {
return 'Atleast one Tag Key needs to be provided as Input.'
}
}