-
Notifications
You must be signed in to change notification settings - Fork 2
/
apigateway_template.yaml
68 lines (62 loc) · 1.53 KB
/
apigateway_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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: The Axelra test api gateway template
Parameters:
Environment:
Type: String
Default: local
ApiHost:
Type: String
ApiPort:
Type: String
MongoDB:
Type: String
Globals:
Function:
Timeout: 3
Environment:
Variables:
ENV: !Ref Environment
Resources:
TestApiGateway:
Type: AWS::Serverless::Api
Properties:
Name: "axelra-interview-challenge-api"
StageName: !Ref Environment
# Cors:
# AllowMethods: "'OPTIONS,GET,POST,PUT,DELETE'"
# AllowHeaders: "'*'"
# AllowOrigin: "'*'"
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs8.10
Timeout: 10
Environment:
Variables:
API_HOST: !Ref ApiHost
API_PORT: !Ref ApiPort
MONGO_DB: !Ref MongoDB
Events:
GetRequest:
Type: Api
Properties:
Path: /hello
Method: get
RestApiId: !Ref TestApiGateway
# this function is used for cors problems. it is triggered on all OPTIONS calls
OptionsFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: options-handler/
Handler: app.lambdaHandler
Runtime: nodejs8.10
Events:
OptionsRequest:
Type: Api
Properties:
Path: /{cors+}
Method: options
RestApiId: !Ref TestApiGateway