Skip to content

Commit

Permalink
[integ-tests] Backport Allow fetching of deprecated Centos 7 images
Browse files Browse the repository at this point in the history
Backport #4536

Signed-off-by: chenwany <[email protected]>
  • Loading branch information
chenwany committed Nov 14, 2022
1 parent dcef719 commit 9308b59
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/integration-tests/tests/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

OS_TO_OFFICIAL_AMI_NAME_OWNER_MAP = {
"alinux2": {"name": "amzn2-ami-hvm-*.*.*.*-*-gp2", "owners": ["amazon"]},
"centos7": {"name": "CentOS 7.*", "owners": ["125523088429"]},
# TODO: use marketplace AMI if possible
"centos7": {"name": "CentOS 7.*", "owners": ["125523088429"], "includeDeprecated": True},
"ubuntu1804": {
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-*-server-*",
"owners": ["099720109477", "513442679011", "837727238323"],
Expand Down Expand Up @@ -74,6 +75,7 @@ def retrieve_latest_ami(region, os, ami_type="official", architecture="x86_64"):
response = boto3.client("ec2", region_name=region).describe_images(
Filters=[{"Name": "name", "Values": [ami_name]}, {"Name": "architecture", "Values": [architecture]}],
Owners=AMI_TYPE_DICT.get(ami_type).get(os).get("owners"),
IncludeDeprecated=AMI_TYPE_DICT.get(ami_type).get(os).get("includeDeprecated", False),
)
# Sort on Creation date Desc
amis = sorted(response.get("Images", []), key=lambda x: x["CreationDate"], reverse=True)
Expand Down

0 comments on commit 9308b59

Please sign in to comment.