4

I have a CodeDeploy which deploys application on Windows instances. I have a Python script which is running as part of ValidateService hooks. Below is the code I have in that script:

print("hello")

So, I have removed everything and just printing hello as part of this script. When this script is called by CodeDeploy I get below error:

error

My appspec.yml file:

  ...
  ValidateService:
    - location: scripts/verify_deployment.py
      timeout: 900

I tried getting some help on Google but got nothing. Can someone please help me here.

Thanks

5
  • What is your appspec.yml? What instances are you using? Ubuntu? Commented Sep 17, 2021 at 6:16
  • It's a Windows instance. Commented Sep 17, 2021 at 6:42
  • Please share your appspec.yml file in the question. At the very least, the parts where you configure the ValidateService hook. Commented Sep 23, 2021 at 8:53
  • @OluwafemiSule I have added now, please have a look. Thanks. Commented Sep 23, 2021 at 8:57
  • Where did you find that you can use python scripts verify_deployment.py in CodeDeploy? Commented Sep 24, 2021 at 2:20

2 Answers 2

4
+25

As Marcin already answered in a comment, I don't think you can simply run python scripts in CodeDeploy. At least not natively.

The error you see means that Windows does not know how to execute the script you have provided. AFAIK Windows can't run python natively (like most linux distros can).

I am not very accustomed to CodeDeploy, but given the example at https://github.com/aws-samples/aws-codedeploy-samples/tree/master/applications/SampleApp_Windows, I think you have to install python first.

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

3 Comments

I can't find any documentation that explicitly states that it only uses shell, but it's implied in the samples above and it explains how to run other scripts here: docs.aws.amazon.com/codedeploy/latest/userguide/…
@thetillhoff I already have Python installed on servers and I have set Python in environment path as well.
@GeoffreyBurdett you are right. The document says "You can run any type of script as long as it is supported by the operating system running on the instances" and I have Python installed so it should have worked for me.
0

After so much of investigations, I found my answer. The issue is little misleading, there is nothing to do with Code format or ENOEXEC. The issue was due to Python path. While executing my script, CodeDeploy was unable to find Python (Though I had already added python.exe in Environment variable path).

Also, I found that CodeDeploy is unable to execute .py file due to Python path issue. So, I created a PowerShell script and invoking Python script from there. Like below:

C:\Users\<username>\AppData\Local\Programs\Python\Python37-32\python.exe C:\Users\<username>\Documents\verify_deployment.py

It executed Python script successfully and gave me below output:

hello

Comments

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.