微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将chmod + x权限添加到AWS Elastic Beanstalk平台挂钩?

如何解决如何将chmod + x权限添加到AWS Elastic Beanstalk平台挂钩?

上下文

我正在使用Elastic Beanstalk部署一个非常简单的测试应用程序。我有几个要使用apt安装的软件包。我在01_installations.sh目录中的安装中包含了.platform/hooks/prebuild脚本。当我压缩应用程序并部署到Elastic Beanstalk时,日志会确认预构建脚本已运行,但没有权限

2020/08/12 21:03:46.674234 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/12 21:03:46.674256 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2020/08/12 21:03:46.674296 [INFO] Following platform hooks will be executed in order: [01_installations.sh]
2020/08/12 21:03:46.674302 [INFO] Running platform hook: .platform/hooks/prebuild/01_installations.sh
2020/08/12 21:03:46.674482 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/01_installations.sh Failed with error fork/exec .platform/hooks/prebuild/01_installations.sh: permission denied  

问题

我的理解是,权限被拒绝,因为我没有添加chmod +x来使.sh文件可执行。正如平台挂钩上的AWS文档所述:“使用chmod + x设置挂钩文件的执行权限。” (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html)。 我的问题是:我该怎么做?

我只是将.sh文件放在目录中。我不会在其他任何地方称呼它。我缺少一个简单的步骤吗? AWS文档使它看起来应该很简单。

以前的尝试

我尝试过的事情:

  1. 添加.ebextensions
    • 尝试:使用以下命令在.config目录中创建一个.ebextensions文件,该命令应以chmod + x权限执行.sh文件
    • 结果:发生相同的错误。 Elastic Beanstalk日志根本不表示.config已被处理。
container_commands:
    01_chmod1:
        command: "chmod +x .platform/hooks/prebuild/01_installations.sh"
  1. 更改.sh文件名称
    • 尝试:根据AWS用户的建议,将.sh文件更改为名为“ chmod + x 01_installations.sh”(下面的论坛链接)。删除.ebextensions
    • 结果:发生相同的错误
[RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/chmod +x 01_installations.sh Failed with error fork/exec .platform/hooks/prebuild/chmod +x 01_installations.sh: permission denied 

我已经在这里回顾了这些想法,但实际上它们都没有包含足够完整的示例以供遵循:

解决方法

确保在git中使文件可执行

git update-index --chmod=+x path/to/file

参考来自 How to add chmod permissions to file in GIT?

,

通常,在压缩部署包之前,请先在本地工作站上设置权限。

但是,如果要在EB实例上执行此操作,则不能使用container_commands。原因是container_commands之后 prebuild执行。相反,您应该尝试使用commands

在运行任何配置文件的命令部分中找到的命令之后,并且在运行Buildfile命令之前,运行预构建文件。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?