Failed to build apache kudu because unable to connect to

When trying to build kudu in my ec2, I got an error “HTTP/1.1 403 Forbidden”. My connection was opened through a proxy. The domain that we are trying to connect to here is “service”. This can be accessed through HTTPS. Here the build is run using the gradle wrapper jar (v6.8.3). Here, a 403 Forbidden error of the above type kept appearing. It lookes like the connection is trying to use HTTP instead of HTTPS.

This problem is not occurring when the build is run in an environment without a proxy

It is not trying to use HTTP.
As you can see in the first stack frame above the org.gradle. frames, it is an HttpsURLConnection.
That further up you have HttpURLConnection is just because HttpsURLConnection extends HttpURLConnection as most things are the same, connection is just additionally encrypted.

Your proxy says “403 Forbidden”, so I’d say that either your proxy is configured wrongly, or the proxy settings in the ec2 machine are configured wrongly.