-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtemplate.yaml
127 lines (120 loc) · 3.69 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
This application syncs BUNQ transactions to YNAB. You need to add your BUNQ api_token
and YNAB accesstoken.
Metadata:
AWS::ServerlessRepo::Application:
Name: bunq-ynab-aws-lambda
Description: >
This application syncs BUNQ transactions to YNAB. You need to run the function
to list your accounts and budgets. Next add these to your SSM parameter json.
Finally set the LIST_MODE environment variable to 0. Full instructions in the
README file.
Author: Wessel Troost and Javy de Koning and Nick Strijbos
ReadmeUrl: README.md
SpdxLicenseId: GPL-2.0-only
LicenseUrl: LICENSE
Labels: ["Bunq", "Ynab"]
HomePageUrl: https://github.com/wesselt/bunq2ynab
SemanticVersion: 1.4.4
SourceCodeUrl: https://github.com/wesselt/bunq2ynab
Parameters:
BunqApiToken:
Type: String
Description: Your BUNQ API Token
YnabAccessToken:
Type: String
Description: Your YNAB access token
YnabBudget:
Type: String
Description: Name of your YNAB budget (use * for all budgets)
Resources:
Bunq2YnabLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: aws-layer-content
CompatibleRuntimes:
- python3.12
Metadata:
BuildMethod: makefile
Bunq2YnabFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Metadata:
BuildMethod: makefile
Properties:
CodeUri: ./
Handler: lambda_function.lambda_handler
Runtime: python3.12
Layers:
- !Ref Bunq2YnabLayer
MemorySize: 512
Timeout: 180 # 3 minutes
Environment:
Variables:
LOG_LEVEL: "INFO"
Policies:
- Statement:
- Sid: SSMGetConfig
Effect: Allow
Action:
- ssm:GetParameter
Resource:
[
!Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/bunq2ynab-config",
]
- Sid: SSMGetPutState
Effect: Allow
Action:
- ssm:GetParameter
- ssm:PutParameter
Resource:
[
!Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/bunq2ynab-state",
]
Events:
CloudWatchCronEvent:
Type: Schedule
Properties:
Schedule: rate(8 hours)
HttpApiEvent:
Type: HttpApi
Properties:
ApiId: !Ref HttpApi
Path: /bunq2ynab-lambda
Method: POST
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
DefaultRouteSettings:
ThrottlingBurstLimit: 1 # 1 request per second
ThrottlingRateLimit: 0.1 # 1 request per 10 seconds
ConfigJSON:
Type: AWS::SSM::Parameter
Properties:
Name: bunq2ynab-config
Type: String
Value: !Sub >
{
"api_token": "${BunqApiToken}",
"personal_access_token": "${YnabAccessToken}",
"accounts": [
{
"ynab_budget_name": "${YnabBudget}"
}
]
}
StateJSON:
Type: AWS::SSM::Parameter
Properties:
Name: bunq2ynab-state
Type: String
Value: !Sub >
{
"private_key": "",
"private_key_for_api_token": "",
"installation_token": "",
"device_registered": "",
"session_token": "",
"aws_callback": "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com/bunq2ynab-lambda"
}