From 86f661a8afab8fd93146c6af649ae82dd2388422 Mon Sep 17 00:00:00 2001 From: Hossein Shafagh Date: Mon, 23 Sep 2019 12:36:08 -0700 Subject: [PATCH 1/2] With NLBs the DNS formatting has changed, which resulted in Lemur not getting the region correctly parsed --- lemur/plugins/lemur_aws/plugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lemur/plugins/lemur_aws/plugin.py b/lemur/plugins/lemur_aws/plugin.py index 4414a62c..d4a4a6d4 100644 --- a/lemur/plugins/lemur_aws/plugin.py +++ b/lemur/plugins/lemur_aws/plugin.py @@ -40,7 +40,11 @@ from lemur.plugins.lemur_aws import iam, s3, elb, ec2 def get_region_from_dns(dns): - return dns.split(".")[-4] + # XXX.REGION.elb.amazonaws.com + if dns.endswith(".elb.amazonaws.com"): + return dns.split(".")[-4] + else: # NLBs have a different pattern on the dns XXXX.elb.REGION.amazonaws.com + return dns.split(".")[-3] def format_elb_cipher_policy_v2(policy): From 477db836f4ba7bbf3f029a2e1ebb86be23f1290f Mon Sep 17 00:00:00 2001 From: Hossein Shafagh Date: Mon, 23 Sep 2019 12:52:17 -0700 Subject: [PATCH 2/2] lint --- lemur/plugins/lemur_aws/plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lemur/plugins/lemur_aws/plugin.py b/lemur/plugins/lemur_aws/plugin.py index d4a4a6d4..cf6c8643 100644 --- a/lemur/plugins/lemur_aws/plugin.py +++ b/lemur/plugins/lemur_aws/plugin.py @@ -40,10 +40,11 @@ from lemur.plugins.lemur_aws import iam, s3, elb, ec2 def get_region_from_dns(dns): - # XXX.REGION.elb.amazonaws.com + # XXX.REGION.elb.amazonaws.com if dns.endswith(".elb.amazonaws.com"): return dns.split(".")[-4] - else: # NLBs have a different pattern on the dns XXXX.elb.REGION.amazonaws.com + else: + # NLBs have a different pattern on the dns XXXX.elb.REGION.amazonaws.com return dns.split(".")[-3]