如何通过CDK列出VPC中的所有NAT网关?

发布于 2025-01-23 20:27:25 字数 130 浏览 3 评论 0 原文

在CDK中,我看到NAT网关表示为 cfnnatgateway 。我只是有什么方法可以列出所有 cfnnatgateway

我的目的是通过CDK将这些NAT网关的弹性IP白色。

In CDK, i see that NAT gateways are represented as CfnNatGateway. I am just whether there is any way to list all the CfnNatGateway.

My purpose is to whitelist the elastic ips of those NAT gateways through CDK.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北音执念 2025-01-30 20:27:25

您可以使用,执行“在云部署过程中进行任意查找或修改。” 一个自定义资源本质上是在堆栈部署期间调用的lambda,您将用于调用<< a href =“ https://docs.aws.amazon.com/awsec2/apireference/api_describenatgateways.html” rel =“ nofollow noreferrer”> defuctenatgateway api api api,提取IPS并输出结果。

您是否应该这样做是一个不同的问题。使用自定义资源查找IPS引入部署时间副作用。取而代之的是,CDK最佳实践是确定性部署

确定性是成功的AWS CDK部署的关键。每当将其部署到给定环境时,AWS CDK应用程序本质上应具有相同的结果。

CDK会让您在合成时查询IPS:

由于您的AWS CDK应用程序是用通用编程语言编写的,因此可以执行任意代码,使用任意库并进行任意网络调用。例如,您可以使用AWS SDK在合成应用程序的同时从AWS帐户中检索一些信息...

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:

Determinism is key to successful AWS CDK deployments. A AWS CDK app should have essentially the same result whenever it is deployed to a given environment.

The CDK would have you lookup the IPs at synth-time:

Since your AWS CDK app is written in a general-purpose programming language, it can execute arbitrary code, use arbitrary libraries, and make arbitrary network calls. For example, you could use an AWS SDK to retrieve some information from your AWS account while synthesizing your app...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文