-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
81 lines (72 loc) · 1.93 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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Parameters:
Stage:
Type: String
Default: dev
Globals:
Function:
Timeout: 60
Resources:
invokeApi:
Type: AWS::Serverless::HttpApi
invoke:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: main.main
Runtime: python3.9
Events:
HttpApi:
Type: HttpApi
Properties:
ApiId: !Ref invokeApi
Path: /v1/invoke
Method: POST
Policies:
- Statement:
- Sid: SSMGetPolicy
Effect: Allow
Action:
- ssm:GetParameter
Resource: !Sub arn:aws:ssm:us-east-1:${AWS::AccountId}:parameter/${Stage}/discord/starfinder/public/key
- Sid: EBPutEvents
Effect: Allow
Action:
- events:PutEvents
Resource:
- !GetAtt starfinderEventBus.Arn
lookup:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: lookup.main
Runtime: python3.9
starfinderEventBus:
Type: AWS::Events::EventBus
Properties:
Name: !Sub discord-starfinder-${Stage}
starfinderDiscoverer:
Type: AWS::EventSchemas::Discoverer
Properties:
Description: Discovers starfinder eventbus events
SourceArn: !GetAtt starfinderEventBus.Arn
lookupEventRule:
Type: AWS::Events::Rule
Properties:
Description: Forwards starfinder lookup events
EventBusName: !Ref starfinderEventBus
EventPattern:
source:
- discord.lookup
State: ENABLED
Targets:
- Arn: !GetAtt lookup.Arn
Id: lookup
LookupEventLambdaPermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
FunctionName: !Ref lookup
Principal: events.amazonaws.com
SourceArn: !GetAtt lookupEventRule.Arn