diff --git a/senza/aws.py b/senza/aws.py
index 1284ba3..c7f0468 100644
--- a/senza/aws.py
+++ b/senza/aws.py
@@ -55,13 +55,12 @@ def is_status_complete(status: str):
 def get_security_group(region: str, sg_name: str):
     ec2 = boto3.resource('ec2', region)
     try:
-        sec_groups = list(ec2.security_groups.filter(
-            Filters=[{'Name': 'group-name', 'Values': [sg_name]}]
-        ))
-        if not sec_groups:
-            return None
-        # FIXME: What if we have 2 VPC, with a SG with the same name?!
-        return sec_groups[0]
+        # first try by tag name then by group-name (cannot be changed)
+        for _filter in [{'Name': 'tag:Name', 'Values': [sg_name]}, {'Name': 'group-name', 'Values': [sg_name]}]:
+            sec_groups = list(ec2.security_groups.filter(Filters=[_filter]))
+            if sec_groups:
+                # FIXME: What if we have 2 VPC, with a SG with the same name?!
+                return sec_groups[0]
     except ClientError as e:
         error_code = extract_client_error_code(e)
         if error_code == 'InvalidGroup.NotFound':
diff --git a/senza/subcommands/root.py b/senza/subcommands/root.py
index 9162122..e5dab09 100644
--- a/senza/subcommands/root.py
+++ b/senza/subcommands/root.py
@@ -6,6 +6,7 @@ from typing import Optional
 import click
 import requests
 import senza
+import sys
 from clickclick import AliasedGroup, warning
 
 from ..arguments import GLOBAL_OPTIONS, region_option
@@ -81,6 +82,8 @@ def check_senza_version(current_version: str):
     Checks if senza is updated and prints a warning with instructions to update
     if it's not.
     """
+    if not sys.stdout.isatty():
+        return
     current_version = LooseVersion(current_version)
     try:
         latest_version = get_latest_version()

Senza version warning should not be printed for non-TTYs (piping result to awk etc)
The Senza version check currently destroys popular shell scripting such as:

```
senza li -o tsv | tail -n +2 | awk '{ print $1 }'
```

We should only print the warning if `sys.stdout` is a TTY.
diff --git a/tests/test_aws.py b/tests/test_aws.py
index 4ca762a..8dd5b44 100644
--- a/tests/test_aws.py
+++ b/tests/test_aws.py
@@ -14,6 +14,21 @@ def test_get_security_group(monkeypatch):
     assert results == get_security_group('myregion', 'group_inexistant')
 
 
+def test_get_security_group_by_tag_name(monkeypatch):
+
+    def mock_filter(Filters):
+        if Filters[0]['Name'] == 'tag:Name' and Filters[0]['Values'] == ['my-sg']:
+            sg = MagicMock()
+            sg.id = 'sg-123'
+            return [sg]
+
+    ec2 = MagicMock()
+    ec2.security_groups.filter = mock_filter
+    monkeypatch.setattr('boto3.resource', MagicMock(return_value=ec2))
+
+    assert get_security_group('myregion', 'my-sg').id == 'sg-123'
+
+
 def test_resolve_security_groups(monkeypatch):
     ec2 = MagicMock()
     ec2.security_groups.filter = MagicMock(side_effect=[
diff --git a/tests/test_subcommands/test_root.py b/tests/test_subcommands/test_root.py
index 796d6c9..86f5a4f 100644
--- a/tests/test_subcommands/test_root.py
+++ b/tests/test_subcommands/test_root.py
@@ -34,8 +34,23 @@ def mock_warning(monkeypatch):
     return mock
 
 
+@fixture()
+def mock_tty(monkeypatch):
+    # check_senza_version only prints if we have a TTY
+    monkeypatch.setattr('sys.stdout.isatty', lambda: True)
+
+
+def test_check_senza_version_notty(monkeypatch, mock_get_app_dir, mock_get, mock_warning):
+    with TemporaryDirectory() as temp_dir:
+        mock_get_app_dir.return_value = temp_dir
+        monkeypatch.setattr("senza.subcommands.root.__file__",
+                            '/home/someuser/pymodules/root.py')
+        check_senza_version("0.40")
+        mock_warning.assert_not_called()
+
+
 def test_check_senza_version(monkeypatch,
-                             mock_get_app_dir, mock_get, mock_warning):
+                             mock_get_app_dir, mock_get, mock_warning, mock_tty):
 
     with TemporaryDirectory() as temp_dir_1:
         mock_get_app_dir.return_value = temp_dir_1
@@ -72,7 +87,7 @@ def test_check_senza_version(monkeypatch,
         )
 
 
-def test_check_senza_version_timeout(mock_get_app_dir, mock_get, mock_warning):
+def test_check_senza_version_timeout(mock_get_app_dir, mock_get, mock_warning, mock_tty):
     with TemporaryDirectory() as temp_dir:
         mock_get_app_dir.return_value = temp_dir
         mock_get.side_effect = Timeout
@@ -83,7 +98,8 @@ def test_check_senza_version_timeout(mock_get_app_dir, mock_get, mock_warning):
 def test_check_senza_version_outdated_cache(monkeypatch,  # noqa: F811
                                             mock_get_app_dir,
                                             mock_get,
-                                            mock_warning):
+                                            mock_warning,
+                                            mock_tty):
     monkeypatch.setattr("senza.subcommands.root.__file__",
                         '/usr/pymodules/root.py')
     with TemporaryDirectory() as temp_dir:
@@ -106,7 +122,8 @@ def test_check_senza_version_outdated_cache(monkeypatch,  # noqa: F811
 def test_check_senza_version_exception(monkeypatch,
                                        mock_get_app_dir,
                                        mock_get,
-                                       mock_warning):
+                                       mock_warning,
+                                       mock_tty):
     mock_sentry = MagicMock()
     monkeypatch.setattr("senza.subcommands.root.sentry", mock_sentry)
     with TemporaryDirectory() as temp_dir:

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
boto3==1.37.23
botocore==1.37.23
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
clickclick==20.10.2
coverage==7.8.0
dnspython==1.15.0
dnspython3==1.15.0
exceptiongroup==1.2.2
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
jmespath==1.0.1
packaging==24.2
pluggy==1.5.0
pystache==0.6.8
pytest==8.3.5
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
PyYAML==6.0.2
raven==6.10.0
requests==2.32.3
s3transfer==0.11.4
six==1.17.0
stups-cli-support==1.1.22
stups-pierone==1.1.56
-e git+https://github.com/zalando-stups/senza.git@56e263195218e3fe052e95221b2d9528c4343264#egg=stups_senza
stups-tokens==1.1.19
stups-zign==1.2
tomli==2.2.1
typing==3.7.4.3
urllib3==1.26.20
zipp==3.21.0

name: senza
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - boto3==1.37.23
      - botocore==1.37.23
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - click==8.1.8
      - clickclick==20.10.2
      - coverage==7.8.0
      - dnspython==1.15.0
      - dnspython3==1.15.0
      - exceptiongroup==1.2.2
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - jmespath==1.0.1
      - packaging==24.2
      - pluggy==1.5.0
      - pystache==0.6.8
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - raven==6.10.0
      - requests==2.32.3
      - s3transfer==0.11.4
      - six==1.17.0
      - stups-cli-support==1.1.22
      - stups-pierone==1.1.56
      - stups-tokens==1.1.19
      - stups-zign==1.2
      - tomli==2.2.1
      - typing==3.7.4.3
      - urllib3==1.26.20
      - zipp==3.21.0
prefix: /opt/conda/envs/senza

tests/test_aws.py::test_get_security_group_by_tag_name tests/test_subcommands/test_root.py::test_check_senza_version_notty
tests/test_aws.py::test_get_security_group tests/test_aws.py::test_resolve_security_groups tests/test_aws.py::test_create tests/test_aws.py::test_encrypt tests/test_aws.py::test_list_kms_keys tests/test_aws.py::test_get_vpc_attribute tests/test_aws.py::test_get_account_id tests/test_aws.py::test_get_account_alias tests/test_aws.py::test_resolve_referenced_resource tests/test_aws.py::test_resolve_referenced_resource_with_update_complete_status tests/test_aws.py::test_resolve_referenced_output_when_stack_is_in_update_complete_status tests/test_aws.py::test_parse_time tests/test_aws.py::test_required_capabilities tests/test_aws.py::test_resolve_topic_arn tests/test_aws.py::test_matches_any tests/test_aws.py::test_get_tag tests/test_subcommands/test_root.py::test_check_senza_version tests/test_subcommands/test_root.py::test_check_senza_version_timeout tests/test_subcommands/test_root.py::test_check_senza_version_outdated_cache tests/test_subcommands/test_root.py::test_check_senza_version_exception tests/test_subcommands/test_root.py::test_version
senza/subcommands/root.py senza/aws.py
senza/subcommands/root.py senza/aws.py