MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / addPermission

Function addPermission

src/lib/aws-util.ts:4–36  ·  view source on GitHub ↗
(
		arn: string,
		principal = '906037444270',
		statementId = 'smartthings',
)

Source from the content-addressed store, hash-verified

2
3
4export const addPermission = async (
5 arn: string,
6 principal = '906037444270',
7 statementId = 'smartthings',
8): Promise<string> => {
9 const segments = arn.split(':')
10 if (segments.length < 7) {
11 return 'Invalid Lambda ARN'
12 }
13
14 try {
15 const region = segments[3]
16 const client = new LambdaClient({ region })
17
18 const params: AddPermissionRequest = {
19 Action: 'lambda:InvokeFunction',
20 FunctionName: arn,
21 Principal: principal,
22 StatementId: statementId,
23 }
24
25 const command = new AddPermissionCommand(params)
26
27 await client.send(command)
28
29 return 'Authorization added'
30 } catch (error) {
31 if (error.name === 'ResourceConflictException') {
32 return 'Already authorized'
33 }
34 throw error
35 }
36}
37
38export const schemaAWSPrincipal = '148790070172'
39export const addSchemaPermission = (

Callers 4

handlerFunction · 0.85
addSchemaPermissionFunction · 0.85
authorizeAppFunction · 0.85
aws-util.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected