Tyler Zika
Tyler Zika

Reputation: 1224

Can't deploy go lang app to AWS Elastic Beanstalk

Here is how my files are organized before I zip the file.

├── app
│   ├── main.go
│   ├── Procfile
│   ├── Buildfile
│   ├── build.sh

Buildfile

make: ./build.sh

build.sh

#!/usr/bin/env bash

# Install dependencies.
go get ./...

# Build app
go build ./ -o bin/application

Procfile

web: bin/application

The error I get

[Instance: i-03f3c230e7b575431] Command failed on instance. Return code: 1 Output: (TRUNCATED)... inflating: /var/app/staging/app/main.go Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable. Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/01_configure_application.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

More error logs

Application update failed at 2018-10-02T01:33:44Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/01_configure_application.sh failed.

Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
Archive: /opt/elasticbeanstalk/deploy/appsource/source_bundle
creating: /var/app/staging/app/
inflating: /var/app/staging/app/Buildfile
inflating: /var/app/staging/app/build.sh
inflating: /var/app/staging/app/Procfile
inflating: /var/app/staging/app/main.go
Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.
Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.
Incorrect application version ".01" (deployment 29). Expected version ".01" (deployment 18).

My main.go file has third-party packages. I'm using

port := os.Getenv("PORT")
if port == "" {
    port = "5000"
    log.Println("[-] No PORT environment variable detected. Setting to ", port)
}

like the docs say in the example app. It compiles and runes locally no problem.

Upvotes: 2

Views: 2046

Answers (1)

4lbertyson
4lbertyson

Reputation: 31

As you can see in your error message:

Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.

Your Procfile, Buildfile and build.sh should be in the root of the project, like this:

├── app
│   ├── main.go
│   Procfile
│   Buildfile
│   build.sh

Upvotes: 3

Related Questions