diff --git a/tools/c7n_mailer/c7n_mailer/email_delivery.py b/tools/c7n_mailer/c7n_mailer/email_delivery.py index e25ff7d1a97..a9382b6f3d4 100644 --- a/tools/c7n_mailer/c7n_mailer/email_delivery.py +++ b/tools/c7n_mailer/c7n_mailer/email_delivery.py @@ -43,10 +43,10 @@ def get_valid_emails_from_list(self, targets): # gcp doesn't support the '@' character in their label values so we # allow users to specify an email_base_url to append to the end of their # owner contact tags - if not is_email(target) and self.config.get('email_base_url'): - target = "%s@%s" % (target, self.config['email_base_url']) - if is_email(target): - emails.append(target) + if not is_email(email) and self.config.get('email_base_url'): + full_email = "%s@%s" % (email, self.config['email_base_url']) + if is_email(full_email): + emails.append(full_email) return emails def get_event_owner_email(self, targets, event): # TODO: GCP-friendly diff --git a/tools/c7n_mailer/tests/test_email.py b/tools/c7n_mailer/tests/test_email.py index d4d07b3fc34..51529844166 100644 --- a/tools/c7n_mailer/tests/test_email.py +++ b/tools/c7n_mailer/tests/test_email.py @@ -363,3 +363,12 @@ def test_get_ldap_connection(self): ) patched.assert_called() self.assertEqual(delivery.config['ldap_bind_password'], "a password") + + def test_get_valid_emails_from_list_gcp(self): + delivery = EmailDelivery( + {'ldap_uri': 'foo', 'email_base_url': 'example.com'}, + self.aws_session, MagicMock()) + result = delivery.get_valid_emails_from_list(['resource-owner', 'foo:bar']) + self.assertEqual(len(result), 2) + self.assertTrue('foo@example.com' in result) + self.assertTrue('bar@example.com' in result)