ElasticBeanstalk - 将ec2-user添加到另一个组

ric*_*ard 9 linux amazon-ec2 amazon-web-services amazon-elastic-beanstalk

我有一个需要ec2-user在我的EC2实例上运行的cron作业,它需要能够写入我的Web应用程序的标准日志文件.但是,日志文件由webapp(按照正常情况下)拥有.

我已成功更改了日志文件的权限,以便所有者和组都可以访问它们webapp:webapp.但是当我遇到麻烦的时候,我试图将其添加ec2-userwebapp组中.

我可以在SSH中做得很好sudo usermod -a -G webapp ec2-user但是当我尝试通过EB 容器命令添加此命令时,我得到一个错误说you must have a tty to run sudo.没有sudo运行命令给了我/bin/sh: usermod: command not found.

任何人都知道有任何其他方式可以通过Elastic Beanstalk部署配置添加ec2-userwebapp组中.

Joe*_*man 8

不确定sudoers文件的问题,但通常更简洁的方法将用户添加到组(而不是手动执行命令)是使用文件的users部分.ebextensions.例如,在.ebextensions/something.config:

users:
  ec2-user:
    groups:
      - webapp
Run Code Online (Sandbox Code Playgroud)


Mat*_*can 0

在使用 sudo 执行任何命令之前,您需要从 container_command 运行此命令:

echo Defaults:root \!requiretty >> /etc/sudoers
Run Code Online (Sandbox Code Playgroud)

在上下文中(在 .ebextensions/yourconf.config 中)

container_commands:
  001-enableroot:
    command: echo Defaults:root \!requiretty >> /etc/sudoers #disables error related to needing a tty for sudo, allows running without cli
Run Code Online (Sandbox Code Playgroud)