无法从EC2连接到ParamStore

时间:2017-12-15 16:09:19

标签: amazon-web-services amazon-ec2

当我尝试使用此代码从AWS ParamStore获取值时:

Unhandled Exception: Amazon.Runtime.AmazonServiceException: A WebException with status ConnectFailure was thrown. ---> 
System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 52.94.225.93:443

我得到了这个例外:

52.94.225.93

ParamStore的AWS服务器是def clean_with_puncutation(text): from string import punctuation import re punctuation_token={p:'<PUNC_'+p+'>' for p in punctuation} punctuation_token['<br/>']="<TOKEN_BL>" punctuation_token['\n']="<TOKEN_NL>" punctuation_token['<EOF>']='<TOKEN_EOF>' punctuation_token['<SOF>']='<TOKEN_SOF>' #punctuation_token regex = r"(<br/>)|(<EOF>)|(<SOF>)|[\n\!\@\#\$\%\^\&\*\(\)\[\]\ {\}\;\:\,\.\/\?\|\`\_\\+\\\=\~\-\<\>]" ###Always put new sequence token at front to avoid overlapping results #text = '<EOF>!@#$%^&*()[]{};:,./<>?\|`~-= _+\<br/>\n <SOF>\ ' text_="" matches = re.finditer(regex, text) index=0 for match in matches: #print(match.group()) #print(punctuation_token[match.group()]) #print ("Match at index: %s, %s" % (match.start(), match.end())) text_=text_+ text[index:match.start()] +" " +punctuation_token[match.group()]+ " " index=match.end() return text_ 吗?我假设SDK正在尝试连接到ParamStore但是失败了,因为EC2机器的安全组可能不允许它。

可能导致此错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

通过配置代理服务器(如果我理解正确的话,可以使用VPC出口代理)修复错误。

代理主机和端口已经以某种方式作为环境变量可用。

var proxyHost = Environment.GetEnvironmentVariable("ProxyServer");
var proxyPort = Environment.GetEnvironmentVariable("ProxyPort");
var config = new AmazonSimpleSystemsManagementConfig
{
    ProxyHost = proxyHost,
    ProxyPort = Int32.Parse(proxyPort)
};
var client = new AmazonSimpleSystemsManagementClient(config);