-
Notifications
You must be signed in to change notification settings - Fork 3
/
sam.yml
90 lines (88 loc) · 2.8 KB
/
sam.yml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Parameters:
AppName:
Type: String
Default: demo-app
Stage:
Type: String
Default: dev_local
Resources:
ApiRole:
Type: AWS::IAM::Role
Properties:
Path:
Fn::Sub: /${Stage}/${AppName}/serviceRoles/
RoleName:
Fn::Sub: ${AppName}-api-execution-role-${Stage}
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- apigateway.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName:
Fn::Sub: ${AppName}-api-execution-role-policy-${Stage}
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource:
- Fn::Sub: ${TestFunction.Arn}
- Fn::Sub: ${DocsFunction.Arn}
Api:
Type: AWS::Serverless::Api
Properties:
MethodSettings:
- LoggingLevel: INFO
ResourcePath: '/*' # allows for logging on any resource
HttpMethod: '*' # allows for logging on any method
AccessLogSetting:
Format: '{ "requestId":"$context.requestId", "ip": "$context.identity.sourceIp", "caller":"$context.identity.caller", "user":"$context.identity.user","requestTime":"$context.requestTime", "httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath", "status":"$context.status","protocol":"$context.protocol", "responseLength":"$context.responseLength" }'
TracingEnabled: true
Name:
Fn::Sub: ${AppName}-api-${Stage}
StageName: !Ref Stage
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: swagger.yml
Variables:
Stage:
Fn::Sub: ${Stage}
Domain:
CertificateArn: arn:aws:acm:us-east-2:01234567890:certificate/4a3152c3-29a5-4ab6-994c-2a53d5ba9942
DomainName: www.serverless-swagger-demo.com
Route53:
DistributionDomainName: www.serverless-swagger-demo.com
HostedZoneId: <your id here>
TestFunction:
Type: AWS::Serverless::Function
Properties:
Tracing: Active
Runtime: nodejs12.x
PackageType: Zip
FunctionName:
Fn::Sub: ${AppName}-test-func-${Stage}
Description: Test Function
CodeUri: ./
Handler: index.handler
DocsFunction:
Type: AWS::Serverless::Function
Properties:
Tracing: Active
Runtime: nodejs12.x
PackageType: Zip
FunctionName:
Fn::Sub: ${AppName}-docs-func-${Stage}
CodeUri: ./
Handler: docs.handler
Environment:
Variables:
stage: !Ref Stage