Skip to content

Commit b43f999

Browse files
committed
working through an issue with DNS
1 parent 7b23279 commit b43f999

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

api_gw/api_gw_stack.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,10 @@ def __init__(self, scope: Construct, id: str, props, **kwargs) -> None:
103103
stage_name='prod'
104104
))
105105

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)
115107

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)
118110

119111
# Give our gateway permissions to interact with SNS
120112
api_gw_sns_role = Role(self, 'DefaultLambdaHanderRole',
@@ -226,5 +218,15 @@ def __init__(self, scope: Construct, id: str, props, **kwargs) -> None:
226218
# Add the DNS record
227219
self.r53_dns_record(gateway, route53_zone_import)
228220

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

Comments
 (0)