List AWS instances, optionally filtered by owner.
(
owners: list[str] | None = None, all: bool = False
)
| 670 | |
| 671 | |
| 672 | def list_instances( |
| 673 | owners: list[str] | None = None, all: bool = False |
| 674 | ) -> list[Instance]: |
| 675 | """List AWS instances, optionally filtered by owner.""" |
| 676 | filters: list[FilterTypeDef] = [] |
| 677 | if not all: |
| 678 | if not owners: |
| 679 | owners = [whoami()] |
| 680 | filters.append({"Name": "tag:LaunchedBy", "Values": owners}) |
| 681 | return list(boto3.resource("ec2").instances.filter(Filters=filters)) |
| 682 | |
| 683 | |
| 684 | def get_old_instances() -> list[InstanceTypeDef]: |
no test coverage detected