@@ -103,18 +103,10 @@ def __init__(self, scope: Construct, id: str, props, **kwargs) -> None:
103
103
stage_name = 'prod'
104
104
))
105
105
106
- custom_domain_name = gateway .add_domain_name ("DomainName" ,
107
- domain_name = props ["custom_domain_name" ],
108
- security_policy = SecurityPolicy .TLS_1_2 ,
109
- certificate = Certificate .from_certificate_arn (self , "APIGWCert" ,
110
- cert .certificate_arn )
111
- )
112
-
113
- # gateway.add_domain_name("AddDomain", domain_name=custom_domain_name.domain_name, security_policy=SecurityPolicy.TLS_1_2,
114
- # certificate=cert)
106
+ custom_domain_name = self .apigw_custom_domain (cert , gateway , props )
115
107
116
- path_mapping = BasePathMapping (self , "APIGwMapping" , base_path = props ["namespace" ],
117
- domain_name = custom_domain_name , rest_api = gateway )
108
+ BasePathMapping (self , "APIGwMapping" , base_path = props ["namespace" ],
109
+ domain_name = custom_domain_name , rest_api = gateway )
118
110
119
111
# Give our gateway permissions to interact with SNS
120
112
api_gw_sns_role = Role (self , 'DefaultLambdaHanderRole' ,
@@ -226,5 +218,15 @@ def __init__(self, scope: Construct, id: str, props, **kwargs) -> None:
226
218
# Add the DNS record
227
219
self .r53_dns_record (gateway , route53_zone_import )
228
220
229
- def r53_dns_record (self , gateway , route53_zone_creation ):
230
- ARecord (self , "AliasRecord" , zone = route53_zone_creation , target = RecordTarget .from_alias (ApiGateway (gateway )))
221
+ def apigw_custom_domain (self , cert , gateway , props ):
222
+ custom_domain_name = gateway .add_domain_name ("DomainName" ,
223
+ domain_name = props ["custom_domain_name" ],
224
+ security_policy = SecurityPolicy .TLS_1_2 ,
225
+ certificate = Certificate .from_certificate_arn (self , "APIGWCert" ,
226
+ cert .certificate_arn )
227
+ )
228
+ return custom_domain_name
229
+
230
+ def r53_dns_record (self , gateway , route53_zone_creation , props ):
231
+ ARecord (self , "AliasRecord" , zone = route53_zone_creation , target = RecordTarget .from_alias (ApiGateway (gateway )),
232
+ record_name = props ["custom_domain_name" ])
0 commit comments