I ran into the same error message when attempting to create an Amazon Linux 2 instance using the AWS CDK. The CDK currently defaults to Amazon Linux instead of Amazon Linux 2. When you accidentally use an Amazon Linux AMI from 2018, surprise surprise, all sorts of facilities are not available. I posted an easy way to check your version in another answer.

In CDK (and Cloud Formation) make sure to declare your intended generation in your AmazonLinuxImage properties

generation: AmazonLinuxGeneration.AMAZON_LINUX_2
Answer from Derek Bennett on serverfault.com
🌐
Stack Overflow
stackoverflow.com › questions › 62335429 › how-to-install-amazon-linux-extras-on-ec2-ubuntu-18-0
how to install amazon-linux-extras on EC2 Ubuntu 18.0 - Stack Overflow
TL;DR The amazon-linux-extras command is a distribution specific feature of Amazon Linux 2, it's not available with Ubuntu AMIs. If you need install specific tools for the local VM's OS (or you're building a Ubuntu container), you'll need to ...
🌐
Amazon Web Services
aws.amazon.com › compute › amazon linux 2 › faqs
Amazon Linux 2 FAQs
1 week ago - Extras is a mechanism in Amazon Linux 2 to enable the consumption of new versions of application software on a stable operating system. Extras help alleviate the compromise between the stability of the OS and freshness of available software. For example, now you can install newer versions of ...
Discussions

node.js - sudo: amazon-linux-extras: command not found - Stack Overflow
I tried to install sudo amazon-linux-extras install nginx1 but it is not working. I'm using MobaXterm to deploy node.js app to AWS EC2. When I try the command sudo amazon-linux-extras install nginx... More on stackoverflow.com
🌐 stackoverflow.com
Amazon Linux 2 Python incompatibility woes
I didn’t have any issue with 3.9 and epel on al2. But I rarely use it. As someone else said pyenv or i generally take it a step further and just use docker since all of our stuff is already set up to easily run a container anywhere. I am generally so over touching python in the host os at all, or php, or really anything. Having to depend on their repos and all of that. No thanks. Take a few minutes and just forget what your host os is and containerize it where you will never again have those issues. I personally start with alpine but there are some good official and updated bases you can use to get you a full python environment on alpine in seconds. And customize anything else you need. That also makes sure if you ever change a host os that doesn’t have the same default modules installed you don’t even have to care. I would say forget packaging your software with rpm and go docker. Same concept. You publish a repo and version and all that. It just doesn’t have to care about the host os. At all (well, mostly ;)) More on reddit.com
🌐 r/aws
12
13
September 14, 2023
Amazon Linux 2023 Officially Released
By default, any instances launched with the AL2023 AMI will require the use of IMDSv2-only The amount of users who are about to be shocked that curl http://169.254.169.254/latest/meta-data/ no longer works will be numerous. More on reddit.com
🌐 r/aws
90
246
March 16, 2023
When AWS says that the Amazon Linux kernel is optimized for EC2, they're not kidding
I would not expect such a big difference across two different flavors of linux. It would be interesting to see other variables here - which version of imagemagick is being used, do they all have the same compilation flags and how do other cpu heavy tasks differ across distributions. More on reddit.com
🌐 r/aws
65
324
December 26, 2021
🌐
AWS re:Post
repost.aws › knowledge-center › ec2-install-extras-library-software
Install software from the Extras Library on an AL2 EC2 instance | AWS re:Post
June 18, 2025 - Example output: $ sudo amazon-linux-extras enable php8 .1Topic php8.1 has end-of-support date of 2024-11-25 2 httpd_modules available [ =1.0 =stable ] 3 memcached1.5 available \ [ =1.5.1 =1.5.16 =1.5.17 ] 9 R3.4 available [ =3.4.3 =stable ] ...
🌐
JOE TECH
tech.joellemena.com › home
Install Amazon Linux Extras Ubuntu - JOE TECH
April 10, 2024 - No, Amazon Linux Extras is specific to Amazon Linux 2 and cannot be directly used on Ubuntu. However, you can find equivalent packages in Ubuntu's
🌐
Super User
superuser.com › questions › 1487748 › unable-to-find-or-install-amazon-linux-extras
Unable to find or install amazon-linux-extras - Super User
Generally, if you need to install on Amazon Linux 2 you should build from source. The code below is generally the method today, but it is typical to add/want extra modules which may modify the flags for ./auto/configure, for example.
🌐
AWS
docs.aws.amazon.com › amazon linux › user guide › al2 extras library
AL2 Extras Library - Amazon Linux 2
Describes AL2 Extras. Find out about lifespan, support, and package changes.
Find elsewhere
🌐
devopszones
devopszones.com › 2023 › 04 › how-to-install-extras-repository-in.html
How to Install Extras Repository in Amazon Linux 2 - devopszones
Next, select the desired software package from the list of available packages, enable it, and then use yum to install it. Use the which command to confirm that the amazon-linux-extras package is installed:
🌐
Bobcares
bobcares.com › blog › install-a-software-package-from-the-extras-library-on-ec2
Install a software package from the Extras Library on EC2
August 15, 2021 - $ sudo amazon-linux-extras enable php7.3 0 ansible2 available [ =2.4.2 =2.4.6 ] 2 httpd_modules available [ =1.0 ] 3 memcached1.5 available [ =1.5.1 ] 4 nginx1.12 available [ =1.12.2 ] 5 postgresql10 available [ =10 ] 6 redis4.0 available [ =4.0.5 =4.0.10 ] 7 R3.4 available [ =3.4.3 ] 8 rust1 ...
🌐
Medium
mavisec.medium.com › install-a-software-package-from-the-extras-library-on-an-ec2-instance-f0ecdb6b94b2
Install a software package from the Extras Library on an EC2 instance - mavisec - Medium
November 21, 2021 - Then, list the available software packages, enable the one you’re looking for, and then install the package using yum. Connect to your EC2 Linux Instance using SSH. 2. Confirm if the amazon-linux-extras package has been installed using the ...
🌐
CloudKatha
cloudkatha.com › home › can you install amazon-linux-extras in amazon linux 2023?
Can you Install amazon-linux-extras in Amazon Linux 2023? - CloudKatha
July 31, 2023 - Short answer is No. amazon-linux-extras is not available in Amazon Linux 2023. However you can install any newer version of package from the
🌐
YouTube
youtube.com › amazon web services
How do I install a software package in the Extras Library on an EC2 instance running Amazon Linux 2? - YouTube
Skip directly to the demo: 0:26For more details on this topic, see the Knowledge Center article associated with this video: https://repost.aws/knowledge-cent...
Published   March 21, 2024
Views   428
🌐
GitHub
github.com › awsdocs › amazon-ec2-user-guide › blob › master › doc_source › ec2-lamp-amazon-linux-2.md
amazon-ec2-user-guide/doc_source/ec2-lamp-amazon-linux-2.md at master · awsdocs/amazon-ec2-user-guide
December 19, 2021 - Install the lamp-mariadb10.2-php7.2 and php7.2 Amazon Linux Extras repositories to get the latest versions of the LAMP MariaDB and PHP packages for Amazon Linux 2.
Author   awsdocs
🌐
Amazon Web Services
docs.amazonaws.cn › 亚马逊云科技 › amazon linux 2 › user guide › al2 on amazon ec2 › al2 tutorials › tutorial: install a lamp server on al2
Tutorial: Install a LAMP server on AL2 - Amazon Linux 2
If any of the required packages are not listed in your output, install them with the sudo yum install package command. Also verify that the php7.2 and lamp-mariadb10.2-php7.2 extras are enabled in the output of the amazon-linux-extras command.