-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yml
79 lines (74 loc) · 2.14 KB
/
template.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
AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Description: Codebuild AWS Lambda deployment
Parameters:
AppName:
Type: String
Description: "Specifies the name of the app and the dns name for the apigw(ex: https://appname.apigw_addess/appversion/)"
AllowedPattern: "[a-z0-9]+"
AppVersion:
Type: String
Description: "Specifies the version of the app and the stage for the apigw ('.' will be replaced by '_')"
AllowedPattern: "[A-Za-z0-9.-_]+"
DNSZoneId:
Type: String
Description: "DNS Zone Id"
DNSZoneName:
Type: String
Description: "DNS Zone HostName"
Resources:
DNSZoneCertificate:
Type: AWS::CertificateManager::Certificate
Properties:
DomainName: !Sub '${AppName}.${DNSZoneName}'
DomainValidationOptions:
- DomainName: !Sub '${AppName}.${DNSZoneName}'
HostedZoneId: !Ref DNSZoneId
ValidationMethod: DNS
ApiGW:
Type: AWS::Serverless::Api
Properties:
OpenApiVersion: 3.0.1
StageName: !Join [ '_', !Split [ '.', !Ref AppVersion ] ]
Domain:
CertificateArn: !Ref DNSZoneCertificate
DomainName: !Sub '${AppName}.${DNSZoneName}'
Route53:
HostedZoneId: !Ref DNSZoneId
SecurityPolicy: TLS_1_2
LambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: app.handler
Runtime: nodejs14.x
CodeUri: src/
Description: Codebuild aws lambda example
MemorySize: 128
Timeout: 30
Environment:
Variables:
DEBUG: "beameio:*"
APP_VERSION: !Ref AppVersion
Events:
RootApi:
Type: Api
Properties:
RestApiId: !Ref ApiGW
Path: /
Method: get
ProxyOptions:
Type: Api
Properties:
RestApiId: !Ref ApiGW
Path: /{proxy+}
Method: options
ProxyAny:
Type: Api
Properties:
RestApiId: !Ref ApiGW
Path: /{proxy+}
Method: any
Outputs:
ApiUrl:
Description: URL of your API endpoint
Value: !Sub https://${AppName}.${DNSZoneName}/