-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
112 lines (104 loc) · 3.08 KB
/
template.yml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS API Gateway with a Lambda Integration
Parameters:
ImageUri:
Type: String
SlackToken:
Type: String
NoEcho: true
SlackSigningSecret:
Type: String
NoEcho: true
Resources:
ReslSlackListenerApiFunction:
Type: AWS::Serverless::Function
Properties:
Description: This lambda listens to Slack
FunctionName: 'resl_slack_listener'
Handler: slack_listener
Role: !GetAtt ReslSlackListenerLambdaIamRole.Arn
CodeUri: ./
Runtime: go1.x
Timeout: 30
Environment:
Variables:
SLACK_RESP_ARN: !GetAtt ReslSlackResponderLambda.Arn
SLACK_TOKEN: !Ref SlackToken
SLACK_SIGNING_SECRET: !Ref SlackSigningSecret
Events:
ApiEvent:
Type: HttpApi
Path: /run
Method: POST
ReslCodeExecLambda:
Type: AWS::Serverless::Function
Properties:
Description: the resl lang lambda
FunctionName: 'resl_code_exec'
PackageType: Image
ImageUri: !Ref ImageUri
Timeout: 15
ReslSlackResponderLambda:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
CODE_EXEC_LAMBDA_ARN: !GetAtt ReslCodeExecLambda.Arn
Description: This lambda calls the code execution lambda and responds to Slack
FunctionName: 'resl_slack_responder'
Handler: slack_responder
Role: !GetAtt ReslSlackResponderLambdaIamRole.Arn
CodeUri: ./
Runtime: go1.x
Timeout: 30
ReslSlackResponderLambdaIamRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
Service:
- 'lambda.amazonaws.com'
Action:
- 'sts:AssumeRole'
Path: '/'
Policies:
- PolicyName: InvokeLangLambdaPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Action:
- 'lambda:InvokeFunction'
- 'lambda:InvokeAsync'
Resource: !GetAtt ReslCodeExecLambda.Arn
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
ReslSlackListenerLambdaIamRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
Service:
- 'lambda.amazonaws.com'
Action:
- 'sts:AssumeRole'
Path: '/'
Policies:
- PolicyName: InvokeLangLambdaPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Action:
- 'lambda:InvokeFunction'
- 'lambda:InvokeAsync'
Resource: !GetAtt ReslSlackResponderLambda.Arn
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Transform: AWS::Serverless-2016-10-31