-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathLambdaSample.json
122 lines (122 loc) · 3.99 KB
/
LambdaSample.json
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
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template for Lambda Sample.",
"Parameters": {
"EnvName": {
"Description": "Name of an environment. 'dev', 'staging', 'prod' and any name.",
"Type": "String",
"AllowedPattern": "^.*[^0-9]$",
"ConstraintDescription": "Must end with non-numeric character."
},
"LambdaHandlerPath": {
"Description": "Path of a Lambda Handler.",
"Type": "String",
"AllowedPattern": "^.*[^0-9]$",
"ConstraintDescription": "Must end with non-numeric character."
}
},
"Resources": {
"LambdaRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": "lambda-role",
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/AWSLambdaExecute",
"arn:aws:iam::aws:policy/AmazonS3FullAccess",
"arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess",
"arn:aws:iam::aws:policy/AmazonKinesisFullAccess"
],
"Path": "/"
}
},
"LambdaFunction": {
"Type": "AWS::Lambda::Function",
"Metadata": {
"guard": {
"SuppressedRules": [
"LAMBDA_INSIDE_VPC",
"LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED"
]
}
},
"Properties": {
"FunctionName": {
"Fn::Sub": "lambda-function-${EnvName}"
},
"Description": "LambdaFunction using python3.12.",
"Runtime": "python3.12",
"Code": {
"ZipFile": "import json\n\ndef lambda_handler(event, context):\n print(json.dumps(event))\n return {\n 'statusCode': 200,\n 'body': json.dumps('Hello from Lambda!')\n }\n"
},
"Handler": {
"Fn::Sub": "${LambdaHandlerPath}"
},
"MemorySize": 128,
"Timeout": 10,
"Role": {
"Fn::GetAtt": [
"LambdaRole",
"Arn"
]
},
"Environment": {
"Variables": {
"ENV": {
"Ref": "EnvName"
},
"TZ": "UTC"
}
}
}
}
},
"Outputs": {
"LambdaRoleARN": {
"Description": "Role for Lambda execution.",
"Value": {
"Fn::GetAtt": [
"LambdaRole",
"Arn"
]
},
"Export": {
"Name": "LambdaRole"
}
},
"LambdaFunctionName": {
"Value": {
"Ref": "LambdaFunction"
}
},
"LambdaFunctionARN": {
"Description": "Lambda function ARN.",
"Value": {
"Fn::GetAtt": [
"LambdaFunction",
"Arn"
]
},
"Export": {
"Name": {
"Fn::Sub": "LambdaARN-${EnvName}"
}
}
}
}
}