From 4ca130b93d569be411f3356cb1b6e9850149dfad Mon Sep 17 00:00:00 2001 From: chenwany Date: Mon, 14 Nov 2022 09:47:38 -0800 Subject: [PATCH] [integ-tests] Backport Allow fetching of deprecated Centos 7 images Backport https://github.com/aws/aws-parallelcluster/pull/4536 Signed-off-by: chenwany --- tests/integration-tests/tests/common/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration-tests/tests/common/utils.py b/tests/integration-tests/tests/common/utils.py index 4b029223f8..a412047daa 100644 --- a/tests/integration-tests/tests/common/utils.py +++ b/tests/integration-tests/tests/common/utils.py @@ -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"], @@ -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)