/
template.yaml
59 lines (47 loc) · 1.31 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Serverless patterns - Amazon API Gateway Custom Domain Name
Parameters:
DomainName:
Type: String
CertificateArn:
Type: String
PublicHostedZoneId:
Type: String
ApiId:
Type: String
Stage:
Type: String
Resources:
CustomDomainRegional:
Type: AWS::ApiGatewayV2::DomainName
Properties:
DomainName: !Ref DomainName
DomainNameConfigurations:
- SecurityPolicy: TLS_1_2
CertificateArn: !Ref CertificateArn
EndpointType: REGIONAL
MappingRegional:
Type: AWS::ApiGatewayV2::ApiMapping
DependsOn:
- CustomDomainRegional
Properties:
DomainName: !Ref DomainName
ApiId: !Ref ApiId
Stage: !Ref Stage
Route53AliasRecordRegional:
Type: AWS::Route53::RecordSet
DependsOn:
- CustomDomainRegional
Properties:
Name: !Ref DomainName
Type: A
HostedZoneId: !Ref PublicHostedZoneId
AliasTarget:
DNSName: !GetAtt CustomDomainRegional.RegionalDomainName
HostedZoneId: !GetAtt CustomDomainRegional.RegionalHostedZoneId
Outputs:
# Custom Domain Name endpoint to be used during tests
CustomDomainNameEndpoint:
Description: Custom Domain Name endpoint
Value: !Sub "https://${DomainName}"