【问题标题】:Deciphering AWS CodeDeploy's config and appspec pathing解密 AWS CodeDeploy 的配置和 appspec 路径
【发布时间】:2021-11-08 06:24:14
【问题描述】:

我有一个 appspec.yml 文件位于我从 CodeCommit 部署的修订(工件)的根目录中:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ec2-user/app/aws
file_exists_behavior: OVERWRITE
hooks:
  ApplicationStart:
    - location: /home/ec2-user/app/aws/update_wheel.sh
      timeout: 300
      runas: root

我在我的 ec2 实例上更改了我的 codedeployagent.yml(为了解决这个问题;手动更改 :root_dir: 并不是一个理想的解决方案,即使它可以工作):

/etc/codedeploy-agent/conf/codedeployagent.yml
---
:log_aws_wire: false
:log_dir: '/var/log/aws/codedeploy-agent/'
:pid_dir: '/opt/codedeploy-agent/state/.pid/'
:program_name: codedeploy-agent
:root_dir: '/home/ec2-user/'
:verbose: false
:wait_between_runs: 1
:proxy_uri:
:max_revisions: 2

但我仍然收到这样的错误:

/home/ec2-user/app/aws/update_wheel.sh
Script does not exist at specified location: /home/ec2-user/xxxxxx-cb84-4ef6-966b-xxxxxxxxx/d-xxxxx/deployment-archive/home/ec2-user/app/aws/update_wheel.sh

我真的不明白为什么我将files 复制到destination,然后预计不会使用这些文件,或者为什么我不应该期望那些(shell 脚本)文件使用它们的原始路径。我应该将source files 复制到什么destination,为什么我不能让hooks 期待我在代码代理配置中设置的:root_dir

【问题讨论】:

    标签: amazon-web-services amazon-ec2 aws-code-deploy cicd aws-code-deploy-appspec


    【解决方案1】:

    location 始终相对于您的bundle

    。修订版本的脚本文件包中的位置。您在 hooks 部分中指定的脚本位置相对于应用程序修订包的根目录

    由于您将其更改为root_dir: '/home/ec2-user/',所有部署都将存储在该文件夹中。这需要使用特定于 CodeDeploy 的 Deployment IDExecution ID 值。

    因此,您仍应仅使用包的相对路径。你可以试试:

    location: run_in_home_folder.sh
    

    run_in_home_folder.sh 在哪里

    #!/bin/bash
    
    cd /home/ec2-user/app/aws && sh ./update_wheel.sh
    

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 2018-02-26
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      • 2018-02-04
      • 2019-09-27
      • 1970-01-01
      相关资源
      最近更新 更多