如何通过CDK列出VPC中的所有NAT网关?
在CDK中,我看到NAT网关表示为 cfnnatgateway
。我只是有什么方法可以列出所有 cfnnatgateway
。
我的目的是通过CDK将这些NAT网关的弹性IP白色。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在CDK中,我看到NAT网关表示为 cfnnatgateway
。我只是有什么方法可以列出所有 cfnnatgateway
。
我的目的是通过CDK将这些NAT网关的弹性IP白色。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
您可以使用,执行“在云部署过程中进行任意查找或修改。” 一个自定义资源本质上是在堆栈部署期间调用的lambda,您将用于调用<< a href =“ https://docs.aws.amazon.com/awsec2/apireference/api_describenatgateways.html” rel =“ nofollow noreferrer”> defuctenatgateway api api api,提取IPS并输出结果。
您是否应该这样做是一个不同的问题。使用自定义资源查找IPS引入部署时间副作用。取而代之的是,CDK最佳实践是确定性部署:
CDK会让您在合成时查询IPS:
You could use a Custom Resource, which perform "arbitrary lookups or modifications during a CloudFormation deployment." A Custom Resource is in essence a Lambda that is called during the stack deployments, which you would use to call DescribeNatGateway API, extract the IPs and output the result.
Whether you should do this is a different question. Using a Custom Resource to lookup IPs introduces deploy-time side-effects. Instead, the CDK best practice is deterministic deploys:
The CDK would have you lookup the IPs at synth-time: