-1

I've got a userdata file that uses the aws and jq commands, but since these aren't ubuntu 18.04 AMI. How can I make software available for userdata?

  1. I tried making a new AMI with those installed. It lets me use aws and jq when I log in, but the logs from userdata still say "aws: command not found" and "jq: command not found".

  2. I checked to see if the logs were left over from the AMI creation, but no. An instance started without userdata doesn't have this log file at all.

  3. I don't want to explicitly install them from apt in userdata itself in case the repositories change in a way that breaks the servers.

I'm still pretty sure that AMIs are the way to go, (older custom AMIs other people have made seem to work fine with this userdata), but if the commands are available to bash, why aren't they available to userdata?

Tim
  • 31,888
  • 7
  • 52
  • 78
  • 1
    I'd have installed them in userdata, but you said you don't want to do that. The risk of repos changing is fairly low. So I guess you need to create an AMI and work out why the commands aren't available. Could be as simple as needing to use explicit path. – Tim Feb 20 '19 at 18:56
  • The advantage of installing in userdata is you don't need to create a new AMI as the OS is updated. You can of course run "yum update -f" (or whatever) in user data. – Tim Feb 20 '19 at 21:20

1 Answers1

0

I've had this issue. The answer is: it depends.
Q: Is the AWSCLI package available, but not installed on your AMI?
A: Install it in userdata.

Q: Is the AWSCLI package non-existent on your AMI?
A: Create an instance with a minimal (or non-existent) userdata script. Copy the AWSCLI & JQ files to your AMI and install them. Use this instance to create a new AMI to use going forward.

Q: Is the AWSCLI package installed and cannot be found?
A1: Hard code the path of AWS & JG in your userdata script.
A2: Modify the PATH in your userdata script or your login profile.

Hope that helps!

Scottie H
  • 227
  • 2
  • 10
  • 1
    Turns out it was the path thing! The script worked with the software installed with `apt`, but I was installing it with `snap`, which puts its files in /snap instead of /bin or /usr/bin or /usr/sbin or something like that. – Christopher Waugh Feb 22 '19 at 14:28