-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
97 lines (91 loc) · 2.35 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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: dima
Globals:
Api:
OpenApiVersion: 3.0.2
Parameters:
ApplicationName:
Description: Application name
Type: String
Default: dima
SashaTableName:
Description: DynamoDB table name of sasha
Type: String
APIDomainName:
Description: API domain name
Type: String
CertificateArn:
Description: ACM certificate arn
Type: String
Route53HostedZoneId:
Description: Route53 hostzone id for the APIDomainName
Type: String
DaysToRetainLogs:
Description: days to retain logs in CloudWatch
Type: Number
Default: 30
Resources:
RestAPI:
Type: AWS::Serverless::Api
Properties:
Name: !Ref ApplicationName
StageName: api
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: api/openapi.yml
Domain:
BasePath: /
CertificateArn: !Ref CertificateArn
DomainName: !Ref APIDomainName
EndpointConfiguration: EDGE
Route53:
HostedZoneId: !Ref Route53HostedZoneId
Function:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: go1.x
Properties:
FunctionName: !Ref ApplicationName
CodeUri: .
Handler: bootstrap
Runtime: provided.al2023
MemorySize: 128
Timeout: 30
Tracing: PassThrough
Policies:
- AmazonDynamoDBFullAccess
Environment:
Variables:
TABLE_NAME: !Ref SashaTableName
Events:
Root:
Type: Api
Properties:
Path: /
Method: GET
RestApiId: !Ref RestAPI
Matches:
Type: Api
Properties:
Path: /matches
Method: GET
RestApiId: !Ref RestAPI
FunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${Function}
RetentionInDays: !Ref DaysToRetainLogs
Outputs:
FunctionArn:
Value: !GetAtt Function.Arn
FunctionName:
Value: !Ref Function
CustomEndpointURL:
Value: !Sub "https://${APIDomainName}/"
EndpointURL:
Value: !Sub "https://${RestAPI}.execute-api.${AWS::Region}.${AWS::URLSuffix}/api/"
RestAPIId:
Value: !Ref RestAPI