Reputation: 467
I use EC2 instances to host my sites, and I'm currently (attempting) to set up an autodeployment pipeline using the webhook library and Github Webhooks. I'm following the guides on webhook's repo as well as this blogpost (which I understand is for use with digital ocean stuff, but I figure the same stuff generally applies).
I am able to set up the proper configuration files on my EC2 instance – I had to specify that the webhook library serve/consume content from the instance's private IP address, which is (based on my understanding) NATed to automatically by the elastic IP assigned to the instance. Here is my current hooks.json
file:
[{
"id": "autodeploy",
"execute-command": "/home/ubuntu/webhooks/autodeploy/deploy.sh",
"command-working-directory": "/home/ubuntu/site",
"response-message": "Executing deploy script..."
}]
According to the documentation, this tells webhook that, when a certain endpoint is hit with a GET
/POST
request, the script at the path denoted by execute-command
will be executed. To actually start the server to receive these GET
/POST
requests, I run the below command (and get the below output):
ubuntu@ip-xxx-xx-xx-xxx:~/webhooks$ webhook -hooks hooks.json -ip "xxx-xx-xx-xxx" -verbose
[webhook] 2019/12/22 08:30:48 version 2.5.0 starting
[webhook] 2019/12/22 08:30:48 setting up os signal watcher
[webhook] 2019/12/22 08:30:48 attempting to load hooks from hooks.json
[webhook] 2019/12/22 08:30:48 found 1 hook(s) in file
[webhook] 2019/12/22 08:30:48 loaded: autodeploy
[webhook] 2019/12/22 08:30:48 serving hooks on http://xxx-xx-xx-xxx:9000/hooks/{id}
[webhook] 2019/12/22 08:30:48 os signal watcher ready
Now, xxx-xx-xx-xxx
is the private IP to which the webhook server is bound. I've associated an elastic/public IP with the EC2 instance, but whenever I send a GET
request to http://XX-XXX-XXX-XX:9000/hooks/autodeploy
, I get no response back (where XX-XXX-XXX-XX
denotes the instance's elastic IP); furthermore, when I try to use Github Webhooks to send a POST
request to this endpoint automatically, I get a "could not deliver to endpoint" error.
Any ideas as to what this could be?
Upvotes: 3
Views: 3531
Reputation: 467
Okay so I'm totally an idiot and didn't create a security rule that allowed my instance to be accessed at port 9000. Total dummy move.
(To set up this rule, go to Network and Security > Security Groups and add a new security group that opens port 9000 for TCP access, then associate this rule to the EC2 instance you're working with.)
Upvotes: 6