-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
LambdaSample.yaml
83 lines (74 loc) · 2.17 KB
/
LambdaSample.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
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: !Sub lambda-function-${EnvName}
Description: LambdaFunction using python3.12.
Runtime: python3.12
Code:
ZipFile: |
import json
def lambda_handler(event, context):
print(json.dumps(event))
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Handler: !Sub ${LambdaHandlerPath}
MemorySize: 128
Timeout: 10
Role: !GetAtt LambdaRole.Arn
Environment:
Variables:
ENV: !Ref EnvName
TZ: UTC
Outputs:
LambdaRoleARN:
Description: Role for Lambda execution.
Value: !GetAtt LambdaRole.Arn
Export:
Name: LambdaRole
LambdaFunctionName:
Value: !Ref LambdaFunction
LambdaFunctionARN:
Description: Lambda function ARN.
Value: !GetAtt LambdaFunction.Arn
Export:
Name: !Sub LambdaARN-${EnvName}