-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
113 lines (106 loc) · 3.27 KB
/
template.yaml
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
113
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
AWS
Lambda Function Template for getting amount information using Zaim
Globals:
Function:
Timeout: 60
Resources:
LambdaForZaim:
Type: AWS::Serverless::Function
Properties:
CodeUri: LambdaForZaim
Handler: lambdaForZaim.App::handleRequest
Runtime: java11
MemorySize: 256
Environment:
Variables:
CONSUMER_KEY: !Ref ConsumerKey
CONSUMER_SECRET: !Ref ConsumerSecret
ACCESS_TOKEN: !Ref AccessToken
ACCESS_TOKEN_SECRET: !Ref AccessTokenSecret
Events:
LambdaForZaim:
Type: Api
Properties:
Path: /api/moneyinfo
Method: GET
ZaimToSlack:
Type: AWS::Serverless::Function
Properties:
CodeUri: ZaimToSlack
Handler: zaimtoslack.App::handleRequest
Runtime: java11
MemorySize: 256
Environment:
Variables:
SLACK_BOT_USER_ACCESS_TOKEN: !Ref SlackBotUserAccessToken
SLACK_CHANNEL_ID: !Ref SlackChannelId
Role: !GetAtt ZaimToSlackRole.Arn
Events:
ZaimToSlack:
Type: Api
Properties:
Path: /moneyinfo
Method: POST
ZaimToSlackRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "sts:AssumeRole"
Principal:
Service: lambda.amazonaws.com
Policies:
- PolicyName: "zaim-to-slack"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "execute-api:Invoke"
- "execute-api:ManageConnections"
Resource: "*"
- Effect: "Allow"
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
- "lambda:ListFunctions"
- "lambda:InvokeFunction"
Resource: "*"
Parameters:
ConsumerKey:
Type: String
ConsumerSecret:
Type: String
AccessToken:
Type: String
AccessTokenSecret:
Type: String
SlackBotUserAccessToken:
Type: String
SlackChannelId:
Type: String
Outputs:
LambdaForZaimApi:
Description: "API Gateway endpoint URL for Prod stage for getting amount information function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/api/moneyinfo"
LambdaForZaim:
Description: "Lambda Function for Zaim ARN"
Value: !GetAtt LambdaForZaim.Arn
LambdaForZaimIamRole:
Description: "Implicit IAM Role created for getting amount information function"
Value: !GetAtt LambdaForZaimRole.Arn
ZaimToSlackApi:
Description: "API Gateway endpoint URL for Prod stage for getting amount information function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/moneyinfo"
ZaimToSlack:
Description: "Lambda Function for Zaim ARN"
Value: !GetAtt ZaimToSlack.Arn
ZaimToSlackIamRole:
Description: "Implicit IAM Role created for getting amount information function"
Value: !GetAtt ZaimToSlackRole.Arn