-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
115 lines (101 loc) · 3.36 KB
/
template.yaml
File metadata and controls
115 lines (101 loc) · 3.36 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
my-first-serverless-app
Sample SAM Template for my-first-serverless-app
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
Parameters:
TableName:
Type: String
Description: The DynamoDB table for storing URLs information.
Default: 'UrlsTable'
RegionName:
Type: String
Description: Default region for deployment.
Default: 'us-east-1'
DomainName:
Type: String
Description: Domain name.
Default: 'example.com'
CertificateARN:
Description: Certificate ARN for your domain.
Type: String
Default: 'cert-arn-in-us-east-1'
HostedZoneName:
Description: Hosted zone name
Type: String
Default: 'example.com.'
Resources:
UrlsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Ref TableName
AttributeDefinitions:
- AttributeName: Id
AttributeType: S
KeySchema:
- AttributeName: Id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
FrontEnd:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: ./frontend/dist/lambda/
Handler: server.lambdaHandler
Runtime: nodejs12.x
Environment:
Variables:
AWS_REGION_NAME: !Ref RegionName
Events:
RootEndPoint:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /
Method: any
BackendApi:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: ./backend/dist/lambda/
Handler: server.lambdaHandler
Runtime: nodejs12.x
Environment:
Variables:
TABLE_NAME: !Ref TableName
AWS_REGION_NAME: !Ref RegionName
Policies: AmazonDynamoDBFullAccess
Events:
EverythingElse:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /{proxy+}
Method: any
APIDomainName:
Type: AWS::ApiGateway::DomainName
Properties:
CertificateArn: !Ref CertificateARN
DomainName: !Ref DomainName
APIBasePathMapping:
Type: AWS::ApiGateway::BasePathMapping
Properties:
DomainName: !Ref APIDomainName
RestApiId: !Ref ServerlessRestApi
Stage: Prod
APIDomain:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: !Ref HostedZoneName
RecordSets:
- Name: !Ref DomainName
Type: A
AliasTarget:
DNSName: !GetAtt APIDomainName.DistributionDomainName
HostedZoneId: Z2FDTNDATAQYW2 # static ID for CloudFront aliases
# Outputs:
# ProdDataEndpoint:
# Description: 'API Prod stage endpoint'
# Value: !Sub 'https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/'