I have a cron job that needs to be run under ec2-user
on my EC2 instance and it needs to be able to write to the standard log files for my web app. However, the log files are owned by webapp
(as per normal).
I've successfully changed the permissions on the log files so that they are accessible by both the owner and the group webapp:webapp
. But where I'm running into trouble is when I try to add the ec2-user
to the webapp
group.
I can do it fine in SSH with sudo usermod -a -G webapp ec2-user
but when I try to add this command via EB container-commands, I get an error saying that you must have a tty to run sudo
. Running the command without sudo gives me /bin/sh: usermod: command not found
.
Anybody know of any other way to be able to add ec2-user
to the webapp
group via the Elastic Beanstalk deployment config.
You should not use sudo, the deploy script is ran by root.
Also, this is a server command, do it in the commands section instead of container commands section.
commands:
01_set_user_role:
command: "usermod -a -G webapp ec2-user"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With