-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I have a use case where I'd like to install the SAM CLI on an EC2 instance via CloudFormation userdata. This is for a lab environment.
The first snag I'm hitting is the installation of Linuxbrew
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
which prompts to Press RETURN to continue or any other key to abort
. It also warns not to run as root.
So the issue here is that because the install will run in userdata, it's running as root. It would need to install as root, but into a different (predefined) user's environment.
Is there any guidance on performing an unattended install of SAM CLI, and possibly on a systemwide basis?
A standard yum package would be wonderful.
So far, this kind of thing seems to work (Amazon Linux 2):
UserData:
Fn::Base64: |
#!/bin/bash -xe
yum update -y
yum groupinstall 'Development Tools' -y
git clone https://github.com/Homebrew/brew /home/linuxbrew/.linuxbrew/Homebrew
mkdir /home/linuxbrew/.linuxbrew/bin
ln -s /home/linuxbrew/.linuxbrew/Homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin
chown -R labuser /home/linuxbrew/
/home/linuxbrew/.linuxbrew/bin/brew shellenv >> ~labuser/.bash_profile
brew config
brew tap aws/tap
brew install aws-sam-cli
sam --version