我的内部网络位于AWS VPC(10.0.0.0/16)中,我想在此专用网络中创建AWS API Gateway,因此没有公共主机名/ ip。
这是我尝试过的
service: apollo-lambda1
provider:
name: aws
runtime: nodejs8.10
role: arn:aws:iam::xxx:role/admin-api-lambda-role
region: ap-southeast-1
private: true
vpc:
securityGroupIds:
- sg-xxxxx
subnetIds:
- subnet-xxx
sg-xxxxx是一个安全组,仅允许10.0.0.0/16中的ip。这无济于事。
我也尝试添加,但是它仍然向世界公开了公共IP ...
resourcePolicy:
- Effect: Allow
Principal: "*"
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
Condition:
IpAddress:
aws:SourceIp:
- "10.0.0.0/16"
UPD:尝试过这种组合,没有奏效。现在DNS名称无法解析
endpointType: PRIVATE
resourcePolicy:
- Effect: Allow
Principal: '*'
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
Condition:
IpAddress:
aws:SourceIp:
- some ip here
答案 0 :(得分:0)
我知道问这个问题已经有一段时间了,但是我还是想写一个答案。
使用资源策略:
provider:
name: aws
runtime: nodejs12.x
region: us-west-2
stage: dev
resourcePolicy:
- Effect: Allow
Principal: "*"
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
Condition:
IpAddress:
aws:SourceIp:
- "10.0.0.0/16"
使用具有资源策略和VPC端点的专用端点
provider:
name: aws
runtime: nodejs12.x
region: us-west-2
stage: dev
endpointType: PRIVATE
vpcEndpointIds:
- vpce-XXXXX
resourcePolicy:
- Effect: Allow
Principal: "*"
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
Condition:
IpAddress:
aws:SourceIp:
- "10.0.0.0/16"
在编写此解决方案时,我正在使用带有额外IP地址的第一个示例,因为这是我为了在没有QA小组的情况下测试来自固定IP地址的Endint的解决方案。我希望该解决方案可以帮助某人。