我有以下設定
- 單個 VPC
- 跨 2 個可用區的 2 個公共子網(包含公開 api 的 AWS Beanstalk 應用程式)
- 跨 2 個可用區的 2 個私有子網(包含 Lambda 函式)
- 1 Elastic beanstalk 的介面 VPC 端點(服務名稱 com.amazonaws.us-east-2.elasticbeanstalk)
我不想為我的 lambda 函式創建一個 NAT 網關以便能夠通過互聯網訪問 AWS Beanstalk 應用程式 api,而是想創建一個 VPC 端點,以便我可以從我的 lambda 函式訪問 AWS 內部網路中的 aws beanstalk。
公共子網具有允許 Web 流量(埠 80/443)的安全組
VPC 終端節點與私有子網關聯,其安全組允許 Web 流量(埠 80/443)。
lambda 函式還與私有子網相關聯,其安全組允許網路流量(埠 80/443)。
DNS 決議和 DNS 主機名在 VPC 級別啟用。
我復制了端點 dns 名稱以形成 lambda 函式正在呼叫的 url,我得到了超時
即使在我嘗試了上述所有步驟之后,AWS Lambda 也無法訪問 beanstalk 應用程式 api。
簡化的 lambda 函式:
def lambda_handler(event, context):
http = urllib3.PoolManager()
r = http.request('GET', 'http://vpce-**********.elasticbeanstalk.us-east-2.vpce.amazonaws.com/')
print(r.data)
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Elastic beanstalk 應用程式可通過互聯網獲得 http://sample-app-dev.******.us-east-2.elasticbeanstalk.com/
我在這里缺少什么?
uj5u.com熱心網友回復:
如果我理解正確的話,您設法創建了一個 VPC 終端節點,它可以讓您訪問 Elastic Beanstalk AWS 服務(您可以在其中管理您的 EB 實體)。您沒有公開使用 Elastic Beanstalk 部署的應用程式本身。
我這么說是因為為了從 VPC 公開您的 EB 應用程式,首先您必須創建一個連接到網路負載均衡器的
如果您找到了您的服務,您可以將 Endpoint 放入您可以連接的消費者 VPC。
不過,如果您的兩個 VPC 都在同一個 AWS 賬戶中,那么通過 PrivateLink 公開服務可能有點過頭了。可能
- 將負載均衡器從 EB 應用程式注冊到目標組。

- 確保為網路負載均衡器選擇之前創建的目標組。

- 等到負載均衡器提供。它應該在
active狀態。

- Go to
VPC->Endpoint Serviceand create a newEndpoint Service(PrivateLink). You will have to give the name of the load balancer here:

- Grab the Endpoint Service name:

- Go to
Endpointsand search for the endpoint name:

- Attach a security group for the
Endpointwhich allows HTTP/HTTPS inbound traffic from the VPC:

- Create the
Endpoints:

It might require acceptance, so go back to the Endpoint Service and accept the request.

This should also go from pending to available.
- At this point you should be able to access the EB application using the DNS from the
Endpoint.
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/352773.html
標籤:亚马逊网络服务 aws-lambda 亚马逊弹性豆茎 aws-私人链接
上一篇:APIGetaway上的洗掉函式
