We are working behind a corporate proxy. Unfortunately amplify does not seem to make use of the proxy server and we did not find any argument to pass in any proxy settings.
An argument or setting to set the proxy server to use would be nice.
The workaround we are currently using in linux is the tool proxychains, that is able to force any traffic of a command line tool through a configured proxy.
Auto detecting the proxy settings from the same ones the AWS CLI uses would be helpful.
Here is some research I did for a similar issue: https://github.com/netlify/cli/issues/170#issuecomment-435083607
Meanwhile I use the following workaround:
Find the amplify-provider-awscloudformation
package directory (on Windows it maybe %APPDATA%\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation
).
Install the proxy-agent
package as a dependency for your amplify-provider-awscloudformation
: npm install proxy-agent
.
Edit the file lib/initializer.js
: find the getConfiguredAwsCfnClient
function (probably on line 56
) and add the following code before returning the aws
object:
const httpProxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
if (httpProxy) {
const proxyAgent = require('proxy-agent');
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy)
}
});
}
src/aws-utils/aws.js
: add the previous code before module.exports = aws;
Then the cli will automatilcally detect the HTTP_PROXY
or HTTPS_PROXY
environment variables.
@lemol you just saved my day!! Thank you so much for this!
This is definitely a big issue for me at work.
Proxy support has been added in @aws-amplify/[email protected]
I tried v1.6.10 but still doesn't work. I get following error:
Initializing project in the cloud...An error occurred when creating the CloudFormation stack
Root stack creation failed
init failed
Error: connect ETIMEDOUT 54.239.55.216:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1163:14)
message: 'connect ETIMEDOUT 54.239.55.216:443',
errno: 'ETIMEDOUT',
code: 'NetworkingError',
syscall: 'connect',
address: '54.239.55.216',
port: 443,
region: 'eu-central-1',
hostname: 'cloudformation.eu-central-1.amazonaws.com',
retryable: true,
time: 2019-05-22T10:31:08.349Z }
At the same time, I've set HTTP_PROXY and HTTPS_PROXY and aws cli works smoothly. I'm using Windows 7
Getting the same error on Linux, any thoughts about troubleshooting (debug mode)? Would be great if there is simple Amplify command line to verify proxy is working.
amplify -v
1.6.10
amplify init
...
â ‡ Initializing project in the cloud...An error occurred when creating the CloudFormation stack
✖ Root stack creation failed
init failed
Error: connect ETIMEDOUT 54.239.29.24:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1054:14) {
message: 'connect ETIMEDOUT 54.239.29.24:443',
errno: 'ETIMEDOUT',
code: 'NetworkingError',
syscall: 'connect',
address: '54.239.29.24',
port: 443,
region: 'us-east-1',
hostname: 'cloudformation.us-east-1.amazonaws.com',
retryable: true,
time: 2019-05-23T23:49:24.919Z
}
Also getting the same error with 1.7.0
I took a look at #1464 and noticed that httpOptions
is missing in the awsConfig object in initializer.js
and system-config-manager.js
awsConfig = {
...awsConfig, agent: proxyAgent(httpProxy),
};
I edited the two files in my local npm directory like below, and amplify init
finished successfully.
awsConfig = {
...awsConfig, httpOptions: { agent: proxyAgent(httpProxy) },
};
Proxy wasn't being found - needed
const httpProxy =
process.env.HTTP_PROXY ||
process.env.HTTPS_PROXY ||
process.env.http_proxy ||
process.env.https_proxy
Thanks @r-yoneya
That's the fix for this issue and I've submitted a PR based on your comments.
Is there a support for a MITM proxy too? I getting TLS errors during the installation behind a corp proxy.
Hi! I think I'm having some proxy/ssl issues using Amplify from my work laptop. I'm attaching a screen shot of the error I'm getting. Let me know if I should include more information
Thanks!
I'm using the latest version of the amplify-cli and I'm still getting the above error. Can anyone guide me what might the issue be ?
@arikog I'm still running into the same problem on 4.27.3. Any luck?
Most helpful comment
@lemol you just saved my day!! Thank you so much for this!