amazon-web-services - 通过 Amazon Web Service CodeDeploy 使用 appspec.yml 设置目录所有者和权限

标签 amazon-web-services yaml continuous-deployment codeship aws-code-deploy

我正在部署 Node.js 通过Codeship申请使用 CodeDeploy AWS部署系统 .

我正在使用 appspec.yml 文件来设置部署目录之一的所有者和权限。

我要允许读/写 对于将在部署的指定文件夹中创建的任何文件。 Web 应用程序开始运行后将创建文件。

目前我的 appspec.yml 包含以下内容:

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/APPLICATION_NAME
permissions:
  - object: /var/www/APPLICATION_NAME/tmpfiles
    mode: 644
    owner: ec2-user
    type:
      - directory

最佳答案

我发现 appspec.yml 文件真的很难处理。

我的文件夹结构非常大且复杂,尝试使用 appspec.yml 文件设置权限令人头疼。由于这个原因,我利用“钩子(Hook)”来调用小 bash 脚本来设置我的权限

这是我拥有的示例 appspec.yml 文件:

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www
hooks:
  AfterInstall:
    - location: scripts/set-permissions.sh

以下是 set-permissions.sh 文件的示例:
#!/bin/bash
# Set ownership for all folders
chown -R www-data:www-data /var/www/
chown -R root:root /var/www/protected

# set files to 644 [except *.pl *.cgi *.sh]
find /var/www/ -type f -not -name ".pl" -not -name ".cgi" -not -name "*.sh" -print0 | xargs -0 chmod 0644

# set folders to 755
find /var/www/ -type d -print0 | xargs -0 chmod 0755

关于amazon-web-services - 通过 Amazon Web Service CodeDeploy 使用 appspec.yml 设置目录所有者和权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28320199/

相关文章:

java - 通过命令行上传 Java Elastic Beanstalk 应用程序

amazon-web-services - 亚马逊机器学习模型重建的可能性

templates - 在 helm 图表中附加 yaml anchor

continuous-integration - Bitrise 在代码推送上运行部署工作流程(当不应该时)

amazon-web-services - 您可以通过 API 添加亚马逊购物车的地址吗?

amazon-web-services - 无法从 EC2 中运行的 docker 容器连接到 elasticache redis

yaml - 在无服务器框架中找不到导出名称 XYZ

azure-devops - 无法使用 | AzureFunctionApp appSettings 中的字符 :

azure-devops - 如何从 Azure DevOps 构建 .NET Core 辅助角色服务并将其部署到本地环境

c# - 从一个解决方案持续部署多个项目c#