-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathauthorize.ts
36 lines (31 loc) · 1.18 KB
/
authorize.ts
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
import { SmartThingsCommand, lambdaAuthFlags } from '@smartthings/cli-lib'
import { addSchemaPermission } from '../../lib/aws-utils'
export default class SchemaAppAuthorizeCommand extends SmartThingsCommand<typeof SchemaAppAuthorizeCommand.flags> {
static description = 'authorize calls to your ST Schema Lambda function from SmartThings'
static flags = {
...SmartThingsCommand.flags,
...lambdaAuthFlags,
}
static args = [
{
name: 'arn',
description: 'the ARN of the AWS Lambda function',
required: true,
},
]
static examples = [
'$ smartthings schema:authorize arn:aws:lambda:us-east-1:1234567890:function:your-test-app',
'',
'Note that this command is the same as running the following with the AWS CLI:',
'',
'$ aws lambda add-permission --region us-east-1 \\',
' --function-name arn:aws:lambda:us-east-1:1234567890:function:your-test-app \\',
' --statement smartthings --principal 148790070172 --action lambda:InvokeFunction',
'',
'It requires your machine to be configured to run the AWS CLI',
]
async run(): Promise<void> {
const message = await addSchemaPermission(this.args.arn, this.flags.principal, this.flags.statement)
this.log(message)
}
}