Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Filter out opt-in AWS regions temporarily #40

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/rhelocator/update_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ def get_aws_regions() -> list[str]:
List of AWS regions as strings.
"""
ec2 = boto3.client("ec2", region_name="us-east-1")
raw = ec2.describe_regions(AllRegions=True)
# TODO(mhayden): Remove the opt-in-status filter below once AWS enables the
# additional regions for the account. The opt-in was requested on 2022-10-11 but
# it could take time before they are enabled.
raw = ec2.describe_regions(
Filters=[
{"Name": "opt-in-status", "Values": ["opt-in-not-required", "opted-in"]}
],
AllRegions=True,
)
return sorted([x["RegionName"] for x in raw["Regions"]])


Expand Down
10 changes: 9 additions & 1 deletion tests/test_update_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ def test_get_aws_regions() -> None:
with patch("botocore.client.BaseClient._make_api_call") as boto:
update_images.get_aws_regions()

boto.assert_called_with("DescribeRegions", {"AllRegions": True})
boto.assert_called_with(
"DescribeRegions",
{
"AllRegions": True,
"Filters": [
{"Name": "opt-in-status", "Values": ["opt-in-not-required", "opted-in"]}
],
},
)


def test_aws_describe_images() -> None:
Expand Down