I am trying to deploy a Go app to Elastic beanstalk (through the UI)
What I've done:
- Created a single application.go file which listens on Port 5000
- Compiled for Linux (set GOOS=linux and GOARCH=amd64) using the command found here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html
- go build -o bin/application application.go
- zipped the bin folder and uploaded it to Elastic Beanstalk (I've also tried uploading the file without the bin folder)
For development I'm using go version go1.18.1 windows/amd64
Under Platform in Elastic Beanstalk I see: Go 1 running on 64bit Amazon Linux 2/3.5.1
According to https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.go go v. 1.18.1 is supported
My Code:
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", index)
fmt.Println("Now serving!!!")
http.ListenAndServe(":5000", nil)
}
func index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "My Res !!! %s", time.Now())
}
The Application health is "no data".
With the most recent event of "Environment health has transitioned from Pending to No Data. None of the instances are sending data."
When I look in chrome dev tools and try to open the link, I just get (failed) net:ERR_CONNECTION_RESET. "Failed to load response data: No Resource with given identifier found"
Potential Issues:
- When I look at the configuration tab, I see that this environment is not part of a VPC. Could that be the issue?
Some Potential Next Steps:
- Test running on WSL
- Test deploying on a standalone EC2
- Try deploying through the CLI
- Try wrapping in a docker container and deploying docker (though this wouldn't actually solve my problem, I'd like to be able to deploy without docker)
CodePudding user response:
I tried to replicate your issue using your code, but everything is fine. My EB environment works and deploys perfectly with your code.
The only thing I can think of is that I used linux to create my binary, while you've used windows/amd64
. I don't think those binaries are interchangeable.