-
Notifications
You must be signed in to change notification settings - Fork 35
/
template.yaml
136 lines (124 loc) · 4.01 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A bare bones example of deploying an API Gateway API with one Lambda using an OpenAPI 3.0.1 example spec file as in-line yaml.
Parameters:
Name:
Type: String
Description: The name of the API to create, also used as the stack name.
Resources:
Api:
Type: AWS::Serverless::Api
Properties:
Name: !Ref Name
StageName: live
OpenApiVersion: 3.0.1
DefinitionBody:
openapi: 3.0.1
info:
title: Hello World API
description: This is a swagger example.
contact:
email: [email protected]
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
paths:
/hello/world:
get:
summary: get hello world
description: |
Invokes hello world lambda function example.
responses:
"200":
description: search results matching criteria
"400":
description: bad input parameter
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${AddLambdaFunction.Arn}/invocations
responses:
default:
statusCode: "200"
passthroughBehavior: when_no_match
httpMethod: POST
contentHandling: CONVERT_TO_TEXT
type: aws_proxy
AddLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: add.lambda_handler
Runtime: python3.8
CodeUri: ./lambdas/add
Description: Add
AutoPublishAlias: live
CleanInputLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: cleaninput.lambda_handler
Runtime: python3.8
CodeUri: ./lambdas/cleaninput
Description: Clean Input
AutoPublishAlias: live
DivideLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: divide.lambda_handler
Runtime: python3.8
CodeUri: ./lambdas/divide
Description: Divide
AutoPublishAlias: live
MultiplyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: multiply.lambda_handler
Runtime: python3.8
CodeUri: ./lambdas/multiply
Description: Multiply
AutoPublishAlias: live
SubtractLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: subtract.lambda_handler
Runtime: python3.8
CodeUri: ./lambdas/subtract
Description: Subtract
AutoPublishAlias: live
StateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Name: !Sub statemachine-${AWS::StackName}
DefinitionUri: sm_def.yaml
DefinitionSubstitutions:
AddLambdaFunction: !Ref AddLambdaFunction
CleanInputLambdaFunction: !Ref CleanInputLambdaFunction
DivideLambdaFunction: !Ref DivideLambdaFunction
MultiplyLambdaFunction: !Ref MultiplyLambdaFunction
SubtractLambdaFunction: !Ref SubtractLambdaFunction
Role: !GetAtt StateMachineRole.Arn
StateMachineRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub statemachine-role-${AWS::StackName}
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: states.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
InvokeFunctionPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub statemachine-invoke-function-policy-${AWS::StackName}
Roles:
- !Ref StateMachineRole
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: '*'