Skip to content

Userdata script not working in AL2023 but working in Amazon Linux 2

0

I am deploying a workload in AWS using Terraform. I would like to install packages like kubectl, helm, nginx and so on. The script was working fine using Amazon Linux 2. Once I upgraded to AL2023 it is not working anymore even tough I replaced yum with dnf. Can someone provide some guidance? When I put simple statements like echo "This is a test ..." it works fine however, when I write dnf install -y nginx, the script fails. When I check var/log/cloud-init-output.log it says the userdata script failed.

asked 2 years ago1.2K views

1 Answer
4

Hello,

  • Have you tried running the command directly in the terminal without using Userdata? What's the outcome?
  • Are you in a private VPC, and do you use VPC endpoints? If so, you might need to allow the s3:GetObject action for this ARN: arn:aws:s3:::al2023-repos-<AWS_REGION>-de612dc2. Here is a doc that might help

Hope this helps 😊

EXPERT

answered 2 years ago

  • Hi Jordan, Thank you for your help. No the EC2 instance is actually in a public subnet and I do not have a VPC endpoint. Also yes these commands work directly in the console once the instance boots up. However my question was this script worked fine in Amazon Linux 2, it is the same configuration so I expected that to work with AL2023.

  • What do the dnf logs show when running the user-data script? (Check the file /var/log/dnf.log) Can you try to get more detailed logs and identify the first command that fails?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.