diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml deleted file mode 100644 index 78523d2..0000000 --- a/.github/workflows/gitleaks.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: gitleaks - -on: [pull_request] - -jobs: - gitleaks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: gitleaks-action - uses: zricethezav/gitleaks-action@master diff --git a/efopen/ef_aws_resolver.py b/efopen/ef_aws_resolver.py index 23a7fad..abad518 100644 --- a/efopen/ef_aws_resolver.py +++ b/efopen/ef_aws_resolver.py @@ -209,14 +209,23 @@ def ec2_security_group_security_group_id(self, lookup, default=None): """ try: response = EFAwsResolver.__CLIENTS["ec2"].describe_security_groups(Filters=[{ - 'Name':'group-name', 'Values':[lookup] + 'Name': 'group-name', 'Values': [lookup] }]) - except: - return default - if len(response["SecurityGroups"]) > 0: - return response["SecurityGroups"][0]["GroupId"] - else: - return default + if len(response["SecurityGroups"]) > 0: + return response["SecurityGroups"][0]["GroupId"] + except Exception as e: + print("Error occurred while searching by group name: {}".format(e)) + + try: + response = EFAwsResolver.__CLIENTS["ec2"].describe_security_groups(Filters=[{ + 'Name': 'tag:Name', 'Values': [lookup] + }]) + if len(response["SecurityGroups"]) > 0: + return response["SecurityGroups"][0]["GroupId"] + except Exception as e: + print("Error occurred while searching by tag name: {}".format(e)) + + return default def ec2_subnet_subnet_id(self, lookup, default=None): """ diff --git a/efopen/ef_config.py b/efopen/ef_config.py index 3fc1a46..f7e2c7f 100644 --- a/efopen/ef_config.py +++ b/efopen/ef_config.py @@ -37,6 +37,7 @@ class EFConfig(object): EF_REPO_BRANCH = _ef_site_config["EF_REPO_BRANCH"] ENV_ACCOUNT_MAP = _ef_site_config["ENV_ACCOUNT_MAP"] EPHEMERAL_ENVS = _ef_site_config["EPHEMERAL_ENVS"] + NEW_ENV_MAP = _ef_site_config.get("NEW_ENV_MAP", {}) S3_CONFIG_BUCKET = _ef_site_config["S3_CONFIG_BUCKET"] S3_VERSION_BUCKET = _ef_site_config["S3_VERSION_BUCKET"] SERVICE_GROUPS = set(_ef_site_config["SERVICE_GROUPS"]) diff --git a/efopen/ef_template_resolver.py b/efopen/ef_template_resolver.py index 1ba9f84..b03cfdd 100644 --- a/efopen/ef_template_resolver.py +++ b/efopen/ef_template_resolver.py @@ -174,6 +174,7 @@ def __init__(self, {{ENV}} - environment: mgmt, prod, staging, proto, etc. {{ENV_SHORT}} - env with or account trimmed: mgmt, prod, staging, proto, etc. {{ENV_FULL}} - env fully qualified: prod, staging, proto, mgmt., etc. + {{ENV_NEW}} - parallel new env name {{FUNCTION_NAME}} - only for lambdas {{INSTANCE_ID}} - only for ec2 {{REGION}} - the region currently being worked in @@ -188,6 +189,7 @@ def __init__(self, "ACCOUNT": None, "ACCOUNT_ALIAS": None, "ENV": None, + "ENV_NEW": None, "ENV_SHORT": None, "ENV_FULL": None, "FUNCTION_NAME": None, @@ -321,6 +323,11 @@ def __init__(self, else: self.resolved["ENV_FULL"] = self.resolved["ENV"] + if self.resolved["ENV_SHORT"] in EFConfig.NEW_ENV_MAP: + self.resolved["ENV_NEW"] = EFConfig.NEW_ENV_MAP[self.resolved["ENV_SHORT"]] + else: + self.resolved["ENV_NEW"] = self.resolved["ENV_SHORT"] + if self.verbose: print(repr(self.resolved), file=sys.stderr) @@ -454,6 +461,8 @@ def render(self): if isinstance(resolved_symbol, list): # Using old style of string formatting here due to str.format() interaction with curly braces self.template = re.sub(r'{{\.?%s}}' % re.escape(symbol), "\n".join(resolved_symbol), self.template) + elif resolved_symbol.lower() == "novalue": + self.template = re.sub(r'"{{\.?%s}}"' % re.escape(symbol), '{ "Ref": "AWS::NoValue" }', self.template) else: self.template = re.sub(r'{{\.?%s}}' % re.escape(symbol), resolved_symbol, self.template) go_again = True