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.
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.
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: