-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplate.yaml
113 lines (105 loc) · 3.38 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: >
budgetcategorizer
SAM Template for budgetcategorizer app
Parameters:
InputBucketName:
Type: String
ConfigBucketName:
Type: String
ConfigObjectKey:
Type: String
OutputQueueName:
Type: String
LogLevel:
Type: String
Default: debug
AllowedValues:
- debug
- info
- warn
- error
- dpanic
- panic
- fatal
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Runtime: provided.al2023
Timeout: 60
MemorySize: 512
Architectures:
- arm64
Resources:
InputS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref InputBucketName
AccessControl: Private
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
VersioningConfiguration:
Status: Suspended
LifecycleConfiguration:
Rules:
- ExpirationInDays: 1
Status: Enabled
BudgetCategorizerFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: ./
Handler: bootstrap
Tracing: Active # https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
CONFIGURATION_FILE_BUCKET: !Ref ConfigBucketName
CONFIGURATION_FILE_OBJECT_KEY: !Ref ConfigObjectKey
PROFILING_S3_BUCKET: !Ref InputBucketName
REGION: !Ref "AWS::Region"
SQS_QUEUE_URL: !Join
- ''
- - 'https://sqs.'
- !Ref AWS::Region
- '.amazonaws.com/'
- !Ref 'AWS::AccountId'
- '/'
- !Ref OutputQueueName
LOG_LEVEL: !Ref LogLevel
Policies:
- S3FullAccessPolicy:
BucketName: !Ref InputBucketName
- S3ReadPolicy:
BucketName: !Ref ConfigBucketName
- SQSSendMessagePolicy:
QueueName: !Ref OutputQueueName
Events:
FileUpload:
Type: S3
Properties:
Bucket: !Ref InputS3Bucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: suffix
Value: '.csv'
LambdaLogGroup:
Type: AWS::Logs::LogGroup
DependsOn: [ BudgetCategorizerFunction ]
Properties:
RetentionInDays: 3
LogGroupName: !Join ['', ['/aws/lambda/', !Ref BudgetCategorizerFunction]]
Outputs:
BudgetCategorizerFunction:
Description: "Budget Categorizer Lambda Function ARN"
Value: !GetAtt BudgetCategorizerFunction.Arn
BudgetCategorizerFunctionIamRole:
Description: "Implicit IAM Role created for Budget Categorizer function"
Value: !GetAtt BudgetCategorizerFunctionRole.Arn
S3BucketName:
Description: "Transactions S3 bucket"
Value: !Ref InputS3Bucket