Can’t install amazon-linux-extras pm AWS EC2 Amazon Linux AMI instance

amazon-linuxamazon-web-services

I'm trying to install amazon-linux-extras using the instructions here:

sudo yum install -y amazon-linux-extras

And I get the following error:

amzn-main                                                                                                                             | 2.1 kB  00:00:00     
amzn-updates                                                                                                                          | 3.8 kB  00:00:00     
839 packages excluded due to repository priority protections
No package amazon-linux-extras available.
Error: Nothing to do

Why is the package not available?

I have EPEL installed, so I don't understand what's going on.

UPDATE

Output of

sudo yum repolist

Loaded plugins: priorities, update-motd, upgrade-helper
843 packages excluded due to repository priority protections
repo id                       repo name                                               status
!amzn-main/latest             amzn-main-Base                                               5,934
!amzn-updates/latest          amzn-updates-Base                                            4,722
epel/x86_64                   Extra Packages for Enterprise Linux 7 - x86_64          12,517+843
repolist: 23,173

Best Answer

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