-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
83 lines (74 loc) · 2.16 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: 'api-gateway-test
Sample SAM Template for api-gateway-test
'
Globals:
Api:
OpenApiVersion: '3.0.1'
Parameters:
ApiBasePath:
Default: v1
Description: Base path of the api. 'v1' - example.co.uk/v1/endpoints
Type: String
DomainName:
Default: api.esource.roweitdev.co.uk
Description: Domain name to call the api from.
Type: String
HostedZoneName:
Default: esource.roweitdev.co.uk.
Description: Name of the desired hosted zone.
Type: String
SSMCertificateArn:
Description: 'Arn of the esource certificate created via terraform.'
Type: AWS::SSM::Parameter::Value<String>
Default: '/esource/config/ESOURCE_api_certificate_arn'
Resources:
GetUsersFunction:
Properties:
CodeUri: src/
Handler: app.getAllUsers
Runtime: nodejs10.x
Type: AWS::Serverless::Function
GetUsersLambdaPermission:
Type: AWS::Lambda::Permission
DependsOn:
- ServerlessRestAPI
- GetUsersFunction
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref GetUsersFunction
Principal: apigateway.amazonaws.com
GetUserFunction:
Properties:
CodeUri: src/
Handler: app.getUser
Runtime: nodejs10.x
Type: AWS::Serverless::Function
GetUserLambdaPermission:
Type: AWS::Lambda::Permission
DependsOn:
- ServerlessRestAPI
- GetUserFunction
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref GetUserFunction
Principal: apigateway.amazonaws.com
ServerlessRestAPI:
Type: AWS::Serverless::Api
Properties:
StageName: dev
EndpointConfiguration: REGIONAL
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: './openapi3.yaml'
APIBasePathMapping:
DependsOn: ServerlessRestAPIdevStage #Required - Needs to wait for SAM to create stage before mapping {LOGICAL_API_NAME}{Stage}Stage
Type: AWS::ApiGateway::BasePathMapping
Properties:
DomainName: !Ref DomainName
RestApiId: !Ref ServerlessRestAPI
Stage: dev
BasePath: !Ref ApiBasePath