英文:
How to lookup NAT Gateway by the tag name in AWS CDK
问题
我正在尝试将VPC在Lambda函数的API Gateway资源策略中使用的NAT网关的公共IP地址列入白名单。我的AWS帐户已经有一个作为VPC的一部分的NAT网关。我的主要目标是能够获取NAT网关的公共IP地址。
我正在使用fromLookup()
方法来导入VPC到CDK中。
我已经查阅了文档并注意到NAT网关构造没有fromLookup()
方法。我还尝试通过VPC属性访问NAT网关,但似乎找不到。
这个帖子似乎有希望:(stackoverflow post),但我无法弄清楚如何实现建议。
英文:
I am trying to whitelist the public IP of the NAT gateway that the VPC uses in the API Gateway resource policy of the lambda function. My AWS Account has a NAT Gateway which is already a part of the VPC. My main goal is to be able to get the public IP address of the NAT Gateway.
I am using fromLookup()
to import VPC into the cdk.
I've looked through was documentation and noticed that NAT Gateway construct doesn't have the fromLookup()
method. Also tried to access NAT Gateway through VPC attributes but seems like it's not there.
This post seems promising: (stackoverflow post), but I can't figure out how to implement the suggestion.
答案1
得分: 1
以下是翻译好的部分:
"使用 fromLookup()
查找现有的 NAT 网关确实是不可能的。
您需要结合 CDK 和 SDK。
您需要执行以下操作来安装 SDK:npm install aws-sdk
然后使用 getNATGatewayPublicIP()
函数来获取公共 IP 地址。"
英文:
It is indeed impossible to look up existing NAT GW using fromLookup()
.
What you will have to do is combine CDK and SDK.
What you need to do is install SDK :npm install aws-sdk
And then use getNATGatewayPublicIP()
function to fetch the public IP.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论