0

I'm executing sample powershell scripts as part of deployment via CodeDeploy. Below is content of appsec.yml

version: 0.0
os: windows
files:
  - source: \
    destination: C:\Users\Administrator\testapp
hooks:
  ApplicationStop:
    - location: C:\Users\Administrator\testapp\stop.ps1
      timeout: 300

  BeforeInstall:
    - location: C:\Users\Administrator\testapp\copy.ps1
      timeout: 300

  ApplicationStart:
    - location: C:\Users\Administrator\testapp\start.ps1
      timeout: 300

  ValidateService:
    - location: C:\Users\Administrator\testapp\validate.ps1
      timeout: 300

But when I'm starting deployment with code deploy, getting below error:

Error code
ScriptMissing
Script name
C:\Users\Administrator\testapp\copy.ps1
Message
Script does not exist at specified location: C:/ProgramData/Amazon/CodeDeploy/85c23e0a-90f5-474e-9675-df3301a3b8f9/d-CODHEXCG5/deployment-archive/C:/Users/Administrator/testapp/copy.ps1
  

When I checked location C:/ProgramData/Amazon/CodeDeploy/85c23e0a-90f5-474e-9675-df3301a3b8f9/d-CODHEXCG5/deployment-archive, I see artifacts are downloaded from S3 buckets.

Artifacts directory structure:

+ deployment-archive
  + scripts
     - copy.ps1
     - stop.ps1
     - start.ps1
     - validate.ps1
  - appsec.yml

I think files are not getting copied from Deployment Archive to destination I mentioned in appsec file. But why its not getting copied, not able to understand. Please guide

1
  • Arent you forgetting about scripts, i.e., C:\Users\Administrator\testapp\scripts\stop.ps1`? Commented Aug 2, 2020 at 22:33

1 Answer 1

2

Your files section is totally correct (see AppSpec 'files' section), and the problem is the scripts in hooks section.

In this official documentation AppSpec 'hooks' section, it said:

The location of scripts you specify in the 'hooks' section is relative to the root of the application revision bundle.

So, you need to change the absolute path to a relative path, like:

hooks:
  ApplicationStop:
    - location: scripts\stop.ps1
      timeout: 300

And your error log also tells you the same issue:

Script does not exist at specified location: C:/ProgramData/Amazon/CodeDeploy/85c23e0a-90f5-474e-9675-df3301a3b8f9/d-CODHEXCG5/deployment-archive/C:/Users/Administrator/testapp/copy.ps1

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for the help, I modified hook section as you suggested and it worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.