0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

miriwoお一人様Advent Calendar 2023

Day 2

AWS CodeDeploy EC2「No such file or directory」というエラーが出てデプロイが失敗する

Last updated at Posted at 2023-12-01

概要

CodeDeployでデプロイ中にNo such file or directory - /opt/codedeploy-agent/deployment-root/[ID]/[デプロイグループ名]/deployment-archive/testというエラーが/var/log/aws/codedeploy-agent/codedeploy-agent.logに出てデプロイが失敗した。
筆者の場合の原因を簡単にまとめる

原因究明までの道のり

  1. EC2インスタンスにssh接続し、下記コマンドを実行した。

    less /var/log/aws/codedeploy-agent/codedeploy-agent.log
    
  2. エラー内容は下記だった。

    No such file or directory - /opt/codedeploy-agent/deployment-root/[ID]/[デプロイグループ名]/deployment-archive/test
    
  3. 本当に当該のディレクトリ内部にtestディレクトリが存在していないか確認する。

    ll /opt/codedeploy-agent/deployment-root/[ID]/[デプロイグループ名]/deployment-archive/
    
  4. deployment-archiveディレクトリ内部にはデプロイ対象のGithubのルートディレクトリと同じファイル郡が存在していたが確かにtestディレクトリは存在しなかった。

原因

appspec.ymlのsourceの記載に誤りがあった。

  • appspec.yml
    version: 0.0
    os: linux
    files:
      - source: test
        destination: /var/www/html/test
    hooks:
      ApplicationStop:
        - location: scripts/application_stop.sh
          timeout: 60
          runas: root
      BeforeInstall:
        - location: scripts/before_install.sh
          timeout: 60
          runas: root
      AfterInstall:
        - location: scripts/after_install.sh
          timeout: 60
          runas: root
      ApplicationStart:
        - location: scripts/application_start.sh
          timeout: 60
          runas: root
      ValidateService:
        - location: scripts/validate_service.sh
          timeout: 60
          runas: root
    
  • appspec.yml
    version: 0.0
    os: linux
    files:
      - source: ./
        destination: /var/www/html/test
    hooks:
      ApplicationStop:
        - location: scripts/application_stop.sh
          timeout: 60
          runas: root
      BeforeInstall:
        - location: scripts/before_install.sh
          timeout: 60
          runas: root
      AfterInstall:
        - location: scripts/after_install.sh
          timeout: 60
          runas: root
      ApplicationStart:
        - location: scripts/application_start.sh
          timeout: 60
          runas: root
      ValidateService:
        - location: scripts/validate_service.sh
          timeout: 60
          runas: root
    
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?