将VPC中的Lambda连接到SQS

时间:2017-09-24 22:48:06

标签: java aws-lambda amazon-vpc

我目前有一个Lambda函数。我想在VPC下运行它。我按照这个github repo的说明开始使用 - https://gist.github.com/reggi/dc5f2620b7b4f515e68e46255ac042a7

以下是我遵循的以下步骤:

  1. 为测试目的创建了一个新的vpc。
  2. 在VPC下创建了2个新子网 - 一个用于连接NAT,另一个用于连接IGW。
  3. 创建了一个互联网网关和一个NAT,因为需要将路由表附加到它们。
  4. 我也创建了两个新的路由表 - 一个指向目的地址为0.0.0.0/0的NAT,另一个指向目标地址为0.0.0.0/0的Internet网关。
  5. 将两个路由表手动关联到相应的子网。
  6. 创建了一个默认安全组并将其分配给VPC - 我没有更改任何传入或传出规则。

  7. 分配在上面步骤中创建的vpc,在上面步骤中创建的两个子网以及我拥有的lambda函数的安全组。

  8. 我不断得到AmazonSDK超时连接到SQS的异常:

    com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to sqs.us-east-1.amazonaws.com:443 [sqs.us-east-1.amazonaws.com/54.239.28.81] failed: connect timed out
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1113)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1063)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
    at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:1740)
    at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:1716)
    at com.amazonaws.services.sqs.AmazonSQSClient.executeReceiveMessage(AmazonSQSClient.java:1380)
    at com.amazonaws.services.sqs.AmazonSQSClient.receiveMessage(AmazonSQSClient.java:1356)
    

    我做错了什么?

0 个答案:

没有答案