-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_lambda.txt
105 lines (105 loc) · 3.52 KB
/
install_lambda.txt
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
{
"Description": "CloudFormation template to deploy lambda function",
"Parameters": {
"s3Bucket": {
"Default": "datameetgeo",
"Description": "s3 bucket name of the lambda",
"Type": "String"
},
"s3Key": {
"Default": "lambda_function.zip",
"Description": "s3 bucket key of the lambda",
"Type": "String"
}
},
"Resources": {
"TerminateEMRLambdaFunction": {
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "s3Bucket"
},
"S3Key": {
"Ref": "s3Key"
}
},
"FunctionName": "dailyCost",
"Handler": "lambda_function.lambda_handler",
"MemorySize": 128,
"Role": {
"Fn::GetAtt": [
"GetCost",
"Arn"
]
},
"Runtime": "python2.7",
"Timeout": "60"
},
"Type": "AWS::Lambda::Function"
},
"GetCost": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
]
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": "*",
"Effect": "Allow",
"Resource": "*",
"Sid":"GenericAccess"
}
],
"Version": "2012-10-17"
},
"PolicyName": "DailyCostPolicy"
}
],
"RoleName": "DailyCostRole"
},
"Type": "AWS::IAM::Role"
},
"TerminateEMRSNSTopic": {
"Properties": {
"DisplayName": "Kill Idle EMR",
"Subscription": [
{
"Endpoint": {
"Fn::GetAtt": [
"TerminateEMRLambdaFunction",
"Arn"
]
},
"Protocol": "lambda"
}
],
"TopicName": "TerminateEMRSNSTopic"
},
"Type": "AWS::SNS::Topic"
},
"LambdaInvokePermission":{
"Properties": {
"Action": "lambda:InvokeFunction",
"Principal": "sns.amazonaws.com",
"SourceArn": { "Ref": "TerminateEMRSNSTopic" },
"FunctionName": {
"Fn::GetAtt": [ "TerminateEMRLambdaFunction", "Arn" ]
}
},
"Type": "AWS::Lambda::Permission"
}
}
}