-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
114 lines (104 loc) · 3.09 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
114
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
lambda-demo-scripts
SAM Template for AWS lambda
Globals:
Function:
Timeout: 3
Parameters:
SSMDocumentPath:
Type: String
Default: /dev/tokens
Resources:
ScriptsStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionUri: workflows/workflow.json
DefinitionSubstitutions:
AWSLambdaFunction: !GetAtt AWSLambdaFunction.Arn
Policies: # Find out more about SAM policy templates: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html
- LambdaInvokePolicy:
FunctionName: !Ref AWSLambdaFunction
AWSLambdaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: lambdas/
Handler: lambda_demo.lambda_handler
ReservedConcurrentExecutions: 2
Runtime: python3.8
Timeout: 900
Role: !GetAtt AWSLambdaFunctionRole.Arn
Environment:
Variables:
SSMPATH: !Ref SSMDocumentPath
AWSStepLambdaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: lambdas/
Handler: lambda_with_step_function.lambda_handler
ReservedConcurrentExecutions: 2
Runtime: python3.8
Timeout: 900
Role: !GetAtt AWSLambdaFunctionRole.Arn
Environment:
Variables:
SSMPATH: !Ref SSMDocumentPath
STEP_FUNCTION_ARN: !GetAtt ScriptsStateMachine.Arn
AWSLambdaFunctionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Version: '2012-10-17'
Policies:
- PolicyDocument:
Statement:
- Action:
- ssm:Get*
- ssm:List*
- ssm:Describe*
Effect: Allow
Resource:
"*"
Version: '2012-10-17'
PolicyName: ScrpitsParameterStoreAccess
- PolicyDocument:
Statement:
- Action:
- states:*
Effect: Allow
Resource:
"*"
Version: '2012-10-17'
PolicyName: ScriptsStatemachineRole
- PolicyDocument:
Statement:
- Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Effect: Allow
Resource:
"*"
Version: '2012-10-17'
PolicyName: CloudWatchLogs
Outputs:
AWSLambdaFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt AWSLambdaFunction.Arn
AWSLambdaFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt AWSLambdaFunction.Arn
AWSStepLambdaFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt AWSStepLambdaFunction.Arn
AWSStepLambdaFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt AWSStepLambdaFunction.Arn