gruntwork-io / terratest

Terratest is a Go library that makes it easier to write automated tests for your infrastructure code.
https://terratest.gruntwork.io/
Apache License 2.0
7.39k stars 1.32k forks source link

[aws][ami]Amazon Linux 1 AMI No Longer Available #1386

Closed ryehowell closed 5 months ago

ryehowell commented 5 months ago

Describe the bug Amazon Linux 1 ended support on 12/31/2023 and it looks like the AMI is no longer available for use. Functions that query for the Amazon Linux AMI's are returning empty lists now due to the hardcoded name "*amzn-, such as:

func GetAmazonLinuxAmiE(t testing.TestingT, region string) (string, error) {
    filters := map[string][]string{
        "name":                             {"*amzn-ami-hvm-*-x86_64*"},
        "virtualization-type":              {"hvm"},
        "architecture":                     {"x86_64"},
        "root-device-type":                 {"ebs"},
        "block-device-mapping.volume-type": {"gp2"},
    }

    return GetMostRecentAmiIdE(t, region, AmazonAccountId, filters)
}

The name needs to be updated to Amazon Linux 2 to continue to work.

Example: amzn2-ami-hvm-*-x86_64*

To Reproduce Query the AWS API:

# This returns empty list
 aws ec2 describe-images --owners amazon --filters "Name=root-device-type,Values=ebs" "Name=architecture,Values=x86_64" "Name=block-device-mapping.volume-type,Values=gp2" "Name=virtualization-type,Values=hvm" "Name=name,Values=*amzn-ami-hvm-*-x86_64*"

# This returns list of available AMI ID's
 aws ec2 describe-images --owners amazon --filters "Name=root-device-type,Values=ebs" "Name=architecture,Values=x86_64" "Name=block-device-mapping.volume-type,Values=gp2" "Name=virtualization-type,Values=hvm" "Name=name,Values=*amzn2-ami-hvm-*-x86_64*"

Expected behavior Update the aws ami module to use Amazon Linux 2 AMI's

Nice to have

Versions

Additional context Add any other context about the problem here.