2.4. appspecファイルの作成

目的

appspecファイルを作成します。

対象

  • アプリケーションコード

パラメータ

パラメータの指定

0.1. アプリケーション用ディレクトリの指定

変数の設定:

DIR_APP="${HOME}/environment/handson-cli-repository"

パラメータの確認

変数の確認:

cat << ECHO

  # 0.1. DIR_APP:"${HOME}/environment/handson-cli-repository"
         DIR_APP="${DIR_APP}"

ECHO

実施

appspecファイルの作成

コマンド:

cat << EOF > ${DIR_APP}/appspec.yml
version: 0.0
os: linux
files:
  - source: /
    destination: /home/ec2-user/python-flask-service/
hooks:
  AfterInstall:
   - location: scripts/install_dependencies
     timeout: 300
     runas: root
   - location: scripts/start_server
     timeout: 300
     runas: root
  ApplicationStop:
   - location: scripts/stop_server
     timeout: 300
     runas: root
EOF

cat ${DIR_APP}/appspec.yml

結果(例):

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ec2-user/python-flask-service/
hooks:
  AfterInstall:
   - location: scripts/install_dependencies
     timeout: 300
     runas: root
   - location: scripts/start_server
     timeout: 300
     runas: root
  ApplicationStop:
   - location: scripts/stop_server
     timeout: 300
     runas: root

備考