Skip to content

Commit

Permalink
Merge pull request #6 from HicResearch/dev
Browse files Browse the repository at this point in the history
Create Amplify domain if specified
  • Loading branch information
manics authored Jun 19, 2023
2 parents f66b78a + 9fbcacd commit dae1c9d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
[
"--max-line-length=200",
"--ignore=E203,W503",
"--max-cognitive-complexity=17",
"--max-cognitive-complexity=18",
"--max-expression-complexity=9",
]
additional_dependencies: [
Expand Down
27 changes: 21 additions & 6 deletions egress_backend/egress_backend_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@
)


def from_bool_string(s, rtype):
def convert_bool(s, rtype):
"""
Returns:
rtype=str: 'true' or 'false'
type=bool: true or false
"""
if rtype not in (str, bool):
raise ValueError(f"Invalid return type: {rtype}")
if s.lower() == "true":
if (isinstance(s, str) and s.lower() == "true") or s is True:
if rtype == str:
return "true"
return True
if s.lower() == "false":
if (isinstance(s, str) and s.lower() == "false") or s is False:
if rtype == str:
return "false"
return False
Expand Down Expand Up @@ -137,7 +137,7 @@ def __init__(
)

# Customised SWB with access points
use_s3_access_points = from_bool_string(
use_s3_access_points = convert_bool(
self.node.try_get_context(env_id).get("use_s3_access_points"), bool
)

Expand Down Expand Up @@ -524,6 +524,21 @@ def __init__(
branch_name=amplify_branch_name,
)

if convert_bool(custom_domain_config.get("is_enabled"), bool):
amplify.CfnDomain(
self,
"EgressFrontendAppDomain",
app_id=amplify_app.attr_app_id,
domain_name=custom_domain_config.get("domain_name"),
sub_domain_settings=[
amplify.CfnDomain.SubDomainSettingProperty(
prefix="",
branch_name=amplify_branch_name,
)
],
enable_auto_sub_domain=False,
)

egress_app_url = (
f"https://{amplify_branch_name}.{amplify_app.attr_app_id}.amplifyapp.com"
)
Expand Down Expand Up @@ -1242,7 +1257,7 @@ def __init__(
logout_ur_ls.append(
f"https://{custom_amplify_distribution.amplify_app_distribution.distribution_domain_name}"
)
if custom_domain_config.get("is_enabled"):
if convert_bool(custom_domain_config.get("is_enabled"), bool):
callback_ur_ls.append(f"https://{custom_domain_config.get('domain_name')}")
logout_ur_ls.append(f"https://{custom_domain_config.get('domain_name')}")

Expand Down Expand Up @@ -1961,7 +1976,7 @@ def __init__(
self,
"EgressAppURL",
value=f"https://{custom_domain_config.get('domain_name')}"
if custom_domain_config.get("is_enabled")
if convert_bool(custom_domain_config.get("is_enabled"), bool)
else egress_app_url,
description="The URL for the Egress App.",
)
Expand Down

0 comments on commit dae1c9d

Please sign in to comment.