-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloudformation.yml
91 lines (87 loc) · 2.73 KB
/
cloudformation.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
AWSTemplateFormatVersion: 2010-09-09
Parameters:
LambdaCodeBucket:
Type: String
Description: S3 bucket in which custom lambda code is stored
LambdaCodeKey:
Type: String
Description: Jar file name in which custom lambda code is stored
Default: deliSHAs_crawler-1.0-SNAPSHOT-all.jar
Lambdahandler:
Type: String
Description: Python file name which is packed inside the zip file
Default: Crawler::handleRequest
JdbcUrl:
Type: String
Description: Jdbc url which lambda function would use
JdbcPassword:
Type: String
Description: Jdbc password for db connection
WasUrl:
Type: String
Description: WAS Url
Resources:
LambdaIAMRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: root
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 's3:*'
Resource: '*'
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: 'arn:aws:logs:*:*:*'
CustomResourceLambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
Handler: !Ref Lambdahandler
Role: !GetAtt LambdaIAMRole.Arn
FunctionName: 'bapmuksha_crawler'
Code:
S3Bucket: !Ref LambdaCodeBucket
S3Key: !Ref LambdaCodeKey
Runtime: java11
Timeout: 60
Environment:
Variables:
BASE_CRAWL_URL: 'http://snuco.snu.ac.kr/ko/foodmenu'
JDBC_DRIVER: 'com.mysql.cj.jdbc.Driver'
JDBC_PASSWORD: !Ref JdbcPassword
JDBC_URL: !Ref JdbcUrl
JDBC_USERNAME: 'root'
WAS_URL: !Ref WasUrl
MemorySize: 512
ScheduledRule:
Type: AWS::Events::Rule
Properties:
Description: "Scheduled Rule"
ScheduleExpression: "cron(0 17 1/3 * ? *)"
State: "DISABLED"
Targets:
- Arn: !GetAtt CustomResourceLambdaFunction.Arn
Id: "TargetFunctionV1"
PermissionForEventsToInvokeLambda:
Type: AWS::Lambda::Permission # 타 AWS 리소스 혹은 AWS 계정에 해당 함수를 사용할 권한을 부여한다.
Properties:
FunctionName: !GetAtt CustomResourceLambdaFunction.Arn
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn: !GetAtt ScheduledRule.Arn # ScheduledRule 리소스에 함수를 invoke할 권한을 부여함