dalton5
dalton5

Reputation: 935

Publish beanstalk environment hook issues

I have an issue with my script. I use beanstalk to deploy my ASP.NET Core code. And in my post deploy I have this code:

#!/usr/bin/env bash
file1=sudo cat /opt/elasticbeanstalk/config/ebenvinfo/region
file2=/opt/elasticbeanstalk/bin/get-config container -k environment_name
file3=$file2.$file1.elasticbeanstalk.com
echo $file3
sudo certbot -n -d $file3 --nginx --agree-tos --email [email protected]

It works perfectly if I launch it on the instance but in the postdeploy script I have the error:

[ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPostDeployHooks]. Stop running the command. Error: Command .platform/hooks/postdeploy/00_get_certificate.sh failed with error fork/exec .platform/hooks/postdeploy/00_get_certificate.sh: exec format error

PS: My script has .ebextension which allows exec rights

container_commands:
  00_permission_hook:
    command: "chmod +x .platform/hooks/postdeploy/00_get_certificate.sh"

What's wrong?

Upvotes: 0

Views: 724

Answers (1)

mahmouds12
mahmouds12

Reputation: 31

I had the same issue and added

#!/bin/bash

to the top of the sh file and also ran "chmod +x" to the sh file and it was solved

Upvotes: 1

Related Questions