Getting file existing error mesage on codedeploy Install event

0

I am getting this error message during Install event in codedeploy: The deployment failed because a specified file already exists at this location: /var/www/api/app-name/.prettierrc

Here are my yaml and sh scripts

after_install.sh

#!/bin/bash

echo "Executing after_install.sh script..."

Navigate to app folder

cd /var/www/api/app-name

Ensure the latest code is checked out and dependencies are installed

git checkout origin/main git pull origin main npm install npm run build

before_install.sh

#!/bin/bash

Install node.js and PM2 globally

sudo apt-get update sudo apt-get install nodejs sudo apt-get install npm -y sudo npm install pm2 -g

===================== start_server.sh

echo "Executing start_server.sh script..."

pm2 restart 0 --name "api-sound" pm2 save

========================

appspec.yaml

version: 0.0

os: linux

files:

  • source: / destination: /var/www/api/app-name overwrite: true

hooks: BeforeInstall: - location: scripts/before_install.sh timeout: 300 runas: root

AfterInstall: - location: scripts/after_install.sh timeout: 300 runas: root

ApplicationStart: - location: scripts/start_server.sh timeout: 300 runas: root

any idea why i am encounterinf this during codedeploy?

Enter image description here

code2go
asked 2 months ago151 views
1 Answer
0

Hello.

Try adding "file_exists_behavior: OVERWRITE" to appspec.yml.
This will overwrite any duplicate files.
https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-files.html

profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • will try thank you so much